Drivers
These classes define agents thta can drive a mobile robot around a workplace, and are useful for testing localization algorithms.
Random Path
- class roboticstoolbox.mobile.drivers.RandomPath(workspace, speed=1, dthresh=0.05, seed=0, headinggain=0.3, goalmarkerstyle=None)[source]
Bases:
VehicleDriverBase
- __init__(workspace, speed=1, dthresh=0.05, seed=0, headinggain=0.3, goalmarkerstyle=None)[source]
Driving agent for random path
- Parameters:
- Raises:
ValueError – bad workspace specified
Returns a driver object that drives the attached vehicle to a sequence of random waypoints.
The driver is connected to the vehicle by:
Vehicle(control=driver)or:
veh = Vehicle() veh.control = driverThe waypoints are positioned inside a rectangular region defined by the vehicle that is specified by (see
plotvol2):
workspacex-range
y-range
A (scalar)
-A:A
-A:A
[A, B]
A:B
A:B
[A, B, C, D]
A:B
C:D
Note
It is possible in some cases for the vehicle to move outside the desired region, for instance if moving to a waypoint near the edge, the limited turning circle may cause the vehicle to temporarily move outside.
The vehicle chooses a new waypoint when it is closer than
dthreshto the current waypoint.Uses its own random number generator so as to not influence the performance of other randomized algorithms such as path planning. Set
seed=Noneto have it randomly initialized from the operating system.
- Seealso:
BicycleUnicycleplotvol2()
- __str__()[source]
%RandomPath.char Convert to string % % s = R.char() is a string showing driver parameters and state in in % a compact human readable format.
- property workspace
Size of robot driving workspace
- Returns:
workspace bounds [xmin, xmax, ymin, ymax]
- Return type:
ndarray(4)
Returns the bounds of the workspace as specified by constructor option
workspace
- init(ax=None)[source]
Initialize random path driving agent
- Parameters:
ax (Axes, optional) – axes in which to draw via points, defaults to None
Called at the start of a simulation run. Ensures that the random number generated is reseeded to ensure that the sequence of random waypoints is repeatable.
- demand()[source]
- Compute speed and heading for random waypoint
% % [SPEED,STEER] = R.demand() is the speed and steer angle to % drive the vehicle toward the next waypoint. When the vehicle is % within R.dtresh a new waypoint is chosen. % % See also Vehicle.
- property vehicle
Set/get the vehicle under control
- Getter:
return
VehicleBaseinstance- Setter:
set
VehicleBaseinstanceNote
The setter is invoked by
vehicle.control = driver
Superclass
- class roboticstoolbox.mobile.drivers.VehicleDriverBase[source]
Bases:
ABCAbstract Vehicle driver class
Abtract class that can drive a mobile robot.
- Seealso:
- abstract demand()[source]
Compute speed and heading
- Returns:
speed and steering for
VehicleBaseWhen an instance of a
VehicleDriverBaseclass is attached as the control for an instance of aVehicleBaseclass, this method is called at each time step to provide the control input.Has access to the vehicle and its state through the
vehicle()property.
- abstract init()[source]
Initialize driving agent
Called at the start of a simulation run. Used to initialize state including random number generator state.
- property vehicle
Set/get the vehicle under control
- Getter:
return
VehicleBaseinstance- Setter:
set
VehicleBaseinstanceNote
The setter is invoked by
vehicle.control = driver