# AME 3623: Project 8: Lateral Velocity Control

For the last two projects, you have developed the proportional error and derivative error control pieces. In this project, we bring these two pieces together and tune the parameters so that the craft will orient to and stay at a goal orientation.

• All components of the project are due by Thursday, April 20th at 9:00 am
• Groups are the same as for project 1.
• Discussion within groups is fine.
• Discussion across groups may not be about the specifics of the solution (general programming/circuit issues are fine to discuss).

At the end of this project, you should be able to:

• integrate lateral velocities as sensed by the cameras into the control loop (implementing a velocity control law).

## Component 1: Hardware

There are no new hardware components for this project. However, we are assuming that orientation control is working well and that you have your cameras working properly.

## Component 2: Software

Implement the following functionality:

• Add the following global variables:
```       float velocity_filtered[3];  // x_dot, y_dot, theta_dot
float velocity_goal[3];
```

• Query the cameras.

• Compute the distances traveled in the hovercraft coordinate frame during the last 5ms.

• Compute a low-pass filtered estimate of the hovercraft velocity. One dimension is computed as follows:
```	    fv = fv * (1 - dt / tau) + dx / tau;
```
where fv is a filtered velocity, dt = .005 s, dx is the distance traveled by the hovercraft in the last dt and tau is a filtering parameter (for now, choose .05 s).

• In control_step():

• Update your ddx and ddy terms as follows:
```	    ddx = KLv * (velocity_goal[0] - velocity_filtered[0]);
```

Note: although we are computing filtered_velocity[2] for completeness, we are not using it for this project.

• Produce the following sequence:
• 5 sec: ramp up with velocity_goals = 0. Continually set orientation goal to current orientation.

• 15 sec: hover with velocities_goals = 0

• 10 sec: Set velocity goals to something interesting (e.g., .1, 0)

• 10 sec: Set velocity goals to something in an orthogonal direction (e.g., 0, .1)

• 10 sec: hover with velocities_goals = 0

• 5 sec: ramp down

• The orientation LEDs should continue to display the current heading error.

• The LED bar should continue to reflect orientation rate.

## Component 3: Looking Forward

In class, we will be discussing the implementation of FSMs in C code. For project 9, we will move the sequencing code to a fsm_task. For this project, you may take this step preemptively.

For project 9, we will be using the distance sensors. We recommend that you mount one pointed forward and the other pointed to either the left or right. We will be providing new distance sensor mounts that will allow you to mount the sensors on the front of your hovercrafts.

## What to Hand In

All components of the project are due by Thursday, April 20th at 9:00 am.
• Demonstration/Code Review: All group members must be present. The demonstration must be completed by Tuesday, April 25th.

• Check in the following to your project 8 area of your subversion tree:

• Personal report: There is no personal report due for this project.

Personal programming credit:
• Each person must accumulate at least three personal programming credits over the course of the semester. This project offers one.

• To receive credit, you must be the primary designer, implementer and debugger of the component. This does not mean that your other group members should not be looking over your shoulder. But: you must do the "driving."