Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers | Privacy policy

Not logged in
Log in | Help
 

Follow

From DGC Wiki

Contents

Follow is a simplified version of trajFollower that is intended for use in CDS 110b. Follow reads in states from astate plus trajectories from TBD and commands adrive based on the output of a control algorithm. Follow is implemented using the Falcon library. The block diagram for follow is basically the same as for trajFollower:

Detailed Overview/Implementation Description

follow can be used for essentially two tasks: controlling vehicle motion, and taking logged data on vehicle state for use when developing controllers.

follow controls vehicle motion in two ways:

follow estimates vehicle motion using an EKF at discrete time steps:

Important files needed for running follow:

Logging Format

follow has the ability to log state data in an ASCII format to a file for later use. The format of the file is:

unixtime t1 enabled? v1 φ1 v_{ref_1} \phi_{ref_1} x1 y1 θ1 \dot{x}_1 \dot{y}_1 \dot{\theta}_1 \ddot{x}_1 \ddot{y}_1 \ddot{\theta}_1 x_{ref_1} y_{ref_1} \theta_{ref_1} \dot{x}_{ref_1} \dot{y}_{ref_1} \dot{\theta}_{ref_1} \ddot{x}_{ref_1} \ddot{y}_{ref_1} \ddot{\theta}_{ref_1} obsv_enabled? x_{meas_1} y_{meas_1} \dot{\theta}_{meas_1} γ1 x1 y1 θ1 \dot{x}_1 \dot{y}_1 \dot{\theta}_1 \ddot{x}_1 \ddot{y}_1 \ddot{\theta}_1

unixtime t2 enabled? v2 φ2 v_{ref_2} \phi_{ref_2} x2 y2 θ2 \dot{x}_2 \dot{y}_2 \dot{\theta}_2 \ddot{x}_2 \ddot{y}_2 \ddot{\theta}_2 x_{ref_2} y_{ref_2} \theta_{ref_2} \dot{x}_{ref_2} \dot{y}_{ref_2} \dot{\theta}_{ref_2} \ddot{x}_{ref_2} \ddot{y}_{ref_2} \ddot{\theta}_{ref_2} obsv_enabled? x_{meas_2} y_{meas_2} \dot{\theta}_{meas_2} γ2 x2 y2 θ2 \dot{x}_2 \dot{y}_2 \dot{\theta}_2 \ddot{x}_2 \ddot{y}_2 \ddot{\theta}_2

...

A listing of variables, column positions, and descriptions is below:

#VarDescription
1unixtimeUnix timestamp, generally you can ignore this
2t1Time since the controller was enabled
3enabled?0 if control is disabled, 1 if paused, 2 if enabled
4v1Current desired velocity
5φ1Current steering angle; read in from actuator state
6v_{ref_1}Feed-forward velocity
7\phi_{ref_1}Current commanded steering angle (what is being sent to ADrive)
8x1x position (either from AState, or estimated using follow's internal estimator)
9y1y position (either from AState, or estimated using follow's internal estimator)
10θ1theta position (either from AState, or estimated using follow's internal estimator)
11\dot{x}_1x velocity (either from AState, or estimated using follow's internal estimator)
12\dot{y}_1y velocity (either from AState, or estimated using follow's internal estimator)
13\dot{\theta}_1theta rate (either from AState, or estimated using follow's internal estimator)
14\ddot{x}_1x acceleration (either from AState, or estimated using follow's internal estimator)
15\ddot{y}_1y acceleration (either from AState, or estimated using follow's internal estimator)
16\ddot{\theta}_1theta acceleration (either from AState, or estimated using follow's internal estimator)
17x_{ref_1}x position desired
18y_{ref_1}y position desired
19\theta_{ref_1}theta position desired
20\dot{x}_{ref_1}x velocity desired
21\dot{y}_{ref_1}y velocity desired
22\dot{\theta}_{ref_1}theta rate desired
23\ddot{x}_{ref_1}x acceleration desired
24\ddot{y}_{ref_1}y acceleration desired
25\ddot{\theta}_{ref_1}theta acceleration desired
26obsv_enabled?0 if follow's internal observer is disabled, 2 if the observer is enabled (affects whether the states above are from astate or from follow's observer)
27x_{meas_1}raw x position from GPS
28y_{meas_1}raw y position from GPS
29\dot{\theta}_{meas_1}raw theta rate from IMU
30γ1"Goodness" measure of the raw GPS data
31x1x position (from AState only)
32y1y position (from AState only)
33θ1theta position (from AState only)
34\dot{x}_1x velocity (from AState only)
35\dot{y}_1y velocity (from AState only)
36\dot{\theta}_1theta rate (from AState only)
37\ddot{x}_1x acceleration (from AState only)
38\ddot{y}_1y acceleration (from AState only)
39\ddot{\theta}_1theta acceleration (from AState only)
...
49φFFphi feed-forward

Designing a Controller for Follow

As mentioned above, follow determines what controller to use by reading one in from a .mat file, saved using Matlab. (For ease of reference, we will call this controller .mat file controller.mat from now on, although you can specify specifically which file follow should load its controller from.) controller.mat file should contain four matrices, named A, B, C, and D, which describe a state-space realization of the controller follow will implement.

One tricky thing to note is that for follow, the inputs to the state-space system described by A, B, C, and D in controller.mat are the outputs of the plant, while the outputs of the state-space system described in controller.mat are the inputs to the plant. For a more concrete example, assume we can model Alice in open-loop as:

\begin{matrix} \dot{x}_{plant} &= A_{plant}x_{plant} + B_{plant}u \\ y&=C_{plant}x_{plant}+D_{plant}u \end{matrix}

Then we need to make our controller of the form:

\begin{matrix} \dot{x}_{controller} &= Ax_{controller} + By \\ u&=Cx_{controller}+Dy \end{matrix}

A simple state-feedback controller, for example, would have the form:

\begin{matrix} u&=-Ky \end{matrix}

so A, B, and C would be zero matrices (of the correct dimensions), and D = − K. Note: please check that the signs of your gains and matrices are correct! follow will not do any additional sign-changing -- it will simply implement what you give it!

If we wanted to have a feed-forward term, then we need only specify some non-zero ud (see below about how to construct a trajectory file for follow) and then follow would implement:

\begin{matrix} u&=Cx_{controller}+Dy + u_d \end{matrix}

The inputs to follow (e.g. the outputs of the plant, y) are, in this order:

[x y θ \dot{x} \dot{y} \dot{\theta} \ddot{x} \ddot{y} \ddot{\theta} xd yd θd \dot{x}_d \dot{y}_d \dot{\theta}_d \ddot{x}_d \ddot{y}_d \ddot{\theta}_d ]^T

where state elements with the subscript d correspond to reference (e.g. desired) values (and may be zero if they are unspecified -- see below about trajectories). The outputs (e.g. u) is φ, the steering angle.

Designing an Observer for Follow

As mentioned above, follow determines what observer to use by reading one in from a .mat file, saved using Matlab. (For ease of reference, we will call this observer .mat file observer.mat from now on, although you can specify specifically which file follow should load its observer from.) observer.mat file should contain two matrices, named Q, and R, which describe correlation matrices of the disturbances and noise sources for follow's observer to use.

Q should be 2x2 (since there could be disturbances in v or phi) and similarly, R should be 3x3 (since we measure x, y, and theta_dot).

Designing a Reference Trajectory for Follow

As mentioned above, follow determines what sort of reference trajectory to follow by reading one in from a .traj file. The general format of the file is as follows:

n 11

t1 v1 φ1 x1 y1 θ1 \dot{x}_1 \dot{y}_1 \dot{\theta}_1 \ddot{x}_1 \ddot{y}_1 \ddot{\theta}_1

t2 v2 φ2 x2 y2 θ2 \dot{x}_2 \dot{y}_2 \dot{\theta}_2 \ddot{x}_2 \ddot{y}_2 \ddot{\theta}_2

...

tn vn φn xn yn θn \dot{x}_n \dot{y}_n \dot{\theta}_n \ddot{x}_n \ddot{y}_n \ddot{\theta}_n

Where n is the number of points you've plotted along your trajectory, and ti is the time at which the system should achieve the configuration described by the state variables in the ith row. follow will perform a linear interpolation between each configuration, so you will want to make sure that your configurations are spaced relatively closely. (A good rule of thumb is to make your time step similar to the frequency at which you expect to run your controller.)

Also, note that if your controller doesn't use a variable (for example, unless you get really fancy, you probably won't be doing much with a feedforward term in \ddot{x}), just set that value to 0 for all times (so you'd have a column of zeros). The only exception to this is the v column, which must be set to some positive value for the vehicle to move forward.

The format of the waypoint file which will be the input to your trajectory generation script is:

0 y1 x1 2.00 4.00

0 y2 x2 2.00 4.00

...

0 ym xm 2.00 4.00

You can ignore all the numbers besides the x and y -- they're just there because this file is designed to also be used by Alice's built-in trajectory generation algorithm to determine a trajectory that satisfies certain constraints (such as staying inside a certain corridor width, in this case the 2.00, or being beneath a certain speed, in this case the 4.0 -- both things you don't have to worry about).

Using Follow

To use follow, follow the following steps:

Transferring Files to Alice


Executables Needed

Files Needed

Getting Started

ssh yourname@computername
mkdir yourname
cp -R bin/* yourname/.
cd yourname
ln -fs some_file.rddf rddf.dat
relative2
0
relative_X_coord
relative_Y_coord
relative_theta
speed
./simulator --nonoise (if running in simulation, and you don't want noise)
./astate (if running for real - make sure you run it on skynet5!)
./adrive (if running for real - make sure you run it on skynet1!)
./follow (can use the -c and -t flags to specify controller and trajectory files, or load them using the sparrow display)
./gui (optional - try to run it on the same computer you have the terminal open on, usually skynet2)

As Things Are Running

Most of the programs have "sparrow displays", which is just a name for the terminal-based user interface that appears when you run the program. Sparrow displays can show you dynamically changing data about the program (such as state data, or status information), as well as allow you to interact with the program by changing the values of some variables (such as if you want to increase the gains on a controller).

To change a value in a sparrow display, use the arrow keys to navigate to the value you want to change, hit the equals key, and then type in the value you want.

Simulator

Follow

GUI

Logged Data

Testing Schedule

Date Times Who Why/What For?
Friday, 26 Jan 12:00PM - 3:00PM Tully Foote Testing at Santa Anita
Friday, 26 Jan 10:30AM - 12:00PM Matthew Munson In-shop development

Retrieved from "http://kincora.cds.caltech.edu../../../f/o/l/Follow.html"

This page has been accessed 3,313 times. This page was last modified 05:33, 10 November 2006 by DGC Wiki user Lindzey. Based on work by Jessica Gonzalez and Richard Murray and DGC Wiki user(s) Jeremy.


[Main Page]
Main Page
Alice Docs
DGC07
DGC05
Categories
Recent changes
Help

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports