M-File Help: Vehicle | View code for Vehicle |
Car-like vehicle class
This class models the kinematics of a car-like vehicle (bicycle model). For given steering and velocity inputs it updates the true vehicle state and returns noise-corrupted odometry readings. veh = Vehicle object with odometry covariance v, where v is a 2x2 matrix corresponding to the odometry vector [dx dtheta].init | initialize vehicle state |
f | predict next state based on odometry |
step | move one time step and return noisy odometry |
control | generate the control inputs for the vehicle |
update | update the vehicle state |
run | run for multiple time steps |
Fx | Jacobian of f wrt x |
Fv | Jacobian of f wrt odometry noise |
gstep | like step() but displays vehicle |
plot | plot/animate vehicle on current figure |
plot_xy | plot the true path of the vehicle |
add_driver | attach a driver object to this vehicle |
display | display state/parameters in human readable form |
char | convert state/parameters to human readable string |
x | true vehicle state 3x1 |
V | odometry covariance |
odometry | distance moved in the last interval |
dim | dimension of the robot's world |
robotdim | dimension of the robot (for drawing) |
L | length of the vehicle (wheelbase) |
alphalim | steering wheel limit |
maxspeed | maximum vehicle speed |
T | sample interval |
verbose | verbosity |
x_hist | history of true vehicle state Nx3 |
driver | reference to the driver object |
x0 | initial state, init() sets x := x0 |
v = Vehicle( diag([0.1 0.01].^2 );and display its initial state
vnow apply a speed (0.2m/s) and steer angle (0.1rad) for 1 time step
odo = v.update([0.2, 0.1])where odo is the noisy odometry estimate, and the new true vehicle state
vWe can add a driver object
v.add_driver( RandomPath(10) )which will move the vehicle within the region -10<x<10, -10<y<10 which we can see by
v.run(1000)which will show an animation of the vehicle moving between randomly selected wayoints.
Jacobian df/dv
J = V.Vehicle.F, Vehicle.FxJacobian df/dx
J = V.Vehicle.F, Vehicle.FvVehicle object constructor
v = Vehicle object with actual odometry covariance vact, where vact is a 2x2 matrix corresponding to the odometry vector [dx dtheta]. Default parameters are:alphalim | 0.5 |
maxspeed | 5 |
L | 1 |
robotdim | 0.2 |
x0 | (0,0,0) |
Add a driver for the vehicle
V.demand(); that returns a speed and steer angle.Convert vehicle parameters and state to a string
s = V.Compute the control input to vehicle
u = V.control input (speed,steer) based on provided controls speed,steer to which speed and steering angle limits have been applied. u = V.control input (speed,steer) from a "driver" if one is attached, the driver's DEMAND() method is invoked. If no driver is attached then speed and steer angle are assumed to be zero.Display vehicle parameters and state
V.display vehicle parameters and state in compact human readable form.Predict next state based on odometry
xn = V.f(x, odo, w) predict next state xn based on current state x, odometry odo, and odometry noise w.Reset state of vehicle object
V.Plot vehicle
V.Plot true path followed by vehicle
V.plot_xy(ls) as above but the line style arguments ls are passed to plot.Run the vehicle simulation
V.run the vehicle simulation for n timesteps. p = V.run the vehicle simulation for n timesteps and return the state history as an Nx3 matrix.Move the vehicle model ahead one time step
odo = V.step() updates the vehicle state for one timestep of motion and returns noisy odometry. If a "driver" is attached then its DEMAND() method is invoked to compute speed and steer angle. If no driver is attached then speed and steer angle are assumed to be zero.Vehicle.control, Vehicle.update, Vehicle.add_driver
Update the vehicle state
odo = V.© 1990-2011 Peter Corke.