M-File Help: Vehicle View code for Vehicle

Vehicle

Abstract vehicle class

This abstract class models the kinematics of a mobile robot moving on a plane and with a pose in SE(2). For given steering and velocity inputs it updates the true vehicle state and returns noise-corrupted odometry readings.

Methods

Vehicle constructor
add_driver attach a driver object to this vehicle
control generate the control inputs for the vehicle
f predict next state based on odometry
init initialize vehicle state
run run for multiple time steps
run2 run with control inputs
step move one time step and return noisy odometry
update update the vehicle state

Plotting/display methods

char convert to string
display display state/parameters in human readable form
plot plot/animate vehicle on current figure
plot_xy plot the true path of the vehicle
Vehicle.plotv plot/animate a pose on current figure

Properties (read/write)

x true vehicle state: x, y, theta (3x1)
V odometry covariance (2x2)
odometry distance moved in the last interval (2x1)
rdim dimension of the robot (for drawing)
L length of the vehicle (wheelbase)
alphalim steering wheel limit
speedmax 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, restored on init()

Examples

If veh is an instance of a Vehicle class then we can add a driver object

veh.add_driver( RandomPath(10) )

which will move the vehicle within the region -10<x<10, -10<y<10 which we can see by

veh.run(1000)

which shows an animation of the vehicle moving for 1000 time steps between randomly selected wayoints.

Notes

Reference

Robotics, Vision & Control, Chap 6 Peter Corke, Springer 2011

See also

Bicycle, Unicycle, RandomPath, EKF


Vehicle.Vehicle

Vehicle object constructor

v = Vehicle(options) creates a Vehicle object that implements the kinematic model of a wheeled vehicle.

Options

'covar', C specify odometry covariance (2x2) (default 0)
'speedmax', S Maximum speed (default 1m/s)
'L', L Wheel base (default 1m)
'x0', x0 Initial state (default (0,0,0) )
'dt', T Time interval (default 0.1)
'rdim', R Robot size as fraction of plot window (default 0.2)
'verbose' Be verbose

Notes


Vehicle.add_driver

Add a driver for the vehicle

V.add_driver(d) connects a driver object d to the vehicle. The driver object has one public method:

[speed, steer] = D.demand();

that returns a speed and steer angle.

Notes

See also

Vehicle.step, RandomPath


Vehicle.char

Convert to string

s = V.char() is a string showing vehicle parameters and state in a compact human readable format.

See also

Vehicle.display


Vehicle.control

Compute the control input to vehicle

u = V.control(speed, steer) is a control input (1x2) = [speed,steer] based on provided controls speed,steer to which speed and steering angle limits have been applied.

u = V.control() as above but demand originates with a "driver" object 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.

See also

Vehicle.step, RandomPath


Vehicle.display

Display vehicle parameters and state

V.display() displays vehicle parameters and state in compact human readable form.

Notes

See also

Vehicle.char


Vehicle.init

Reset state

V.init() sets the state V.x := V.x0, initializes the driver object (if attached) and clears the history.

V.init(x0) as above but the state is initialized to x0.


Vehicle.plot

Plot vehicle

The vehicle is depicted graphically as a narrow triangle that travels "point first" and has a length V.rdim.

V.plot(options) plots the vehicle on the current axes at a pose given by the current robot state. If the vehicle has been previously plotted its pose is updated.

V.plot(x, options) as above but the robot pose is given by x (1x3).

H = V.plotv(x, options) draws a representation of a ground robot as an oriented triangle with pose x (1x3) [x,y,theta]. H is a graphics handle.

V.plotv(H, x) as above but updates the pose of the graphic represented by the handle H to pose x.

Options

'scale', S Draw vehicle with length S x maximum axis dimension
'size', S Draw vehicle with length S
'color', C Color of vehicle.
'fill' Filled
'trail', S Trail with line style S, use line() name-value pairs

Example

veh.plot('trail', {'Color', 'r', 'Marker', 'o', 'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'r', 'MarkerSize', 3})

Vehicle.plot_xy

Plots true path followed by vehicle

V.plot_xy() plots the true xy-plane path followed by the vehicle.

V.plot_xy(ls) as above but the line style arguments ls are passed to plot.

Notes


Vehicle.plotv

Plot ground vehicle pose

H = Vehicle.plotv(x, options) draws a representation of a ground robot as an oriented triangle with pose x (1x3) [x,y,theta]. H is a graphics handle. If x (Nx3) is a matrix it is considered to represent a trajectory in which case the vehicle graphic is animated.

Vehicle.plotv(H, x) as above but updates the pose of the graphic represented by the handle H to pose x.

Options

'scale', S Draw vehicle with length S x maximum axis dimension
'size', S Draw vehicle with length S
'fillcolor', C Color of vehicle.
'fps', F Frames per second in animation mode (default 10)

Example

Generate some path 3xN

p = PRM.plan(start, goal);

Set the axis dimensions to stop them rescaling for every point on the path

axis([-5 5 -5 5]);

Now invoke the static method

Vehicle.plotv(p);

Notes

See also

Vehicle.plot


Vehicle.run

Run the vehicle simulation

V.run(n) runs the vehicle model for n timesteps and plots the vehicle pose at each step.

p = V.run(n) runs the vehicle simulation for n timesteps and return the state history (Nx3) without plotting. Each row is (x,y,theta).

See also

Vehicle.step, Vehicle.run2


Vehicle.run2

Run the vehicle simulation with control inputs

p = V.run2(T, x0, speed, steer) runs the vehicle model for a time T with speed speed and steering angle steer. p (Nx3) is the path followed and each row is (x,y,theta).

Notes

See also

Vehicle.run, Vehicle.step, RRT


Vehicle.step

Advance one timestep

odo = V.step(speed, steer) updates the vehicle state for one timestep of motion at specified speed and steer angle, and returns noisy odometry.

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.

Notes

See also

Vehicle.control, Vehicle.update, Vehicle.add_driver


Vehicle.update

Update the vehicle state

odo = V.update(u) is the true odometry value for motion with u=[speed,steer].

Notes


Vehicle.verbosity

Set verbosity

V.verbosity(a) set verbosity to a. a=0 means silent.


 

© 1990-2014 Peter Corke.