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(dthresh=0.05, seed=0, **kwargs)[source]

Bases: VehicleDriverBase

__init__(dthresh=0.05, seed=0, **kwargs)[source]

Driving agent for random path

Parameters:

dthresh (float, optional) – distance threshold, defaults to 0.05

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 = driver

The waypoints are positioned inside a rectangular region defined by the workspace

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 dthresh to 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=None to have it randomly initialized from the operating system.

Seealso:

Bicycle Unicycle plotvol2()

__str__()[source]

Convert to string

Returns:

driver parameters and state in in a compact human readable format

Return type:

str

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.

driveto(goal)
property vehicle

Set/get the vehicle under control

Getter:

return VehicleBase instance

Setter:

set VehicleBase instance

Note

The setter is invoked by vehicle.control = driver

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

Superclass

class roboticstoolbox.mobile.drivers.VehicleDriverBase(workspace=None, speed=1, headinggain=0.3, goalmarkerstyle=None, verbose=False)[source]

Bases: ABC

Abstract Vehicle driver class

Abtract class that can drive a mobile robot.

Seealso:

RandomPath

__init__(workspace=None, speed=1, headinggain=0.3, goalmarkerstyle=None, verbose=False)[source]

_summary_

Parameters:
  • workspace (scalar, array_like(2), array_like(4)) – dimension of workspace, see spatialmath.base.exand_dims()

  • speed (float, optional) – forward speed, defaults to 1

  • headinggain (float, optional) – _description_, defaults to 0.3

  • verbose (bool, optional) – _description_, defaults to False

The workspace of the robot is a rectangular region defined by workspace that is specified by (see plotvol2):

workspace

x-range

y-range

A (scalar)

-A:A

-A:A

[A, B]

A:B

A:B

[A, B, C, D]

A:B

C:D

abstractmethod demand()[source]

Compute speed and heading

Returns:

speed and steering for VehicleBase

When an instance of a VehicleDriverBase class is attached as the control for an instance of a VehicleBase class, 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.

abstractmethod 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 VehicleBase instance

Setter:

set VehicleBase instance

Note

The setter is invoked by vehicle.control = driver

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

driveto(goal)[source]