Mobile robot blocks

https://raw.githubusercontent.com/petercorke/bdsim/main/docs/figs/bdsim_logo.png
class Bicycle(L=1, speed_max=inf, accel_max=inf, steer_max=1.413716694115407, x0=None, **blockargs)[source]

Bases: ContinuousBlock

BICYCLE

Vehicle model with Bicycle kinematics.

Inputs:

2

Outputs:

1

States:

3

Port type

Port number

Types

Description

Input

0

float

\(v\), longitudinal velocity

Input

1

float

\(\gamma\), steer angle

Output

0

ndarray(3)

\(\mathit{q} = (x, y, \theta)\), vehicle configuration

Bicycle kinematic model with velocity and steering inputs and vehicle configuration as output.

Various limits are applied to the inputs:

  • velocity limit speed_max

  • acceleration limit accel_max

  • steering limit steer_max

__init__(L=1, speed_max=inf, accel_max=inf, steer_max=1.413716694115407, x0=None, **blockargs)[source]
Parameters:

Deprecated since version 1.4.0: the vlim and slim keywords are deprecated, use speed_max and steer_max instead.

class Unicycle(w=1, speed_max=inf, accel_max=inf, steer_max=inf, x0=None, **blockargs)[source]

Bases: ContinuousBlock

UNICYCLE

Vehicle model with Unicycle kinematics.

Inputs:

2

Outputs:

1

States:

3

Port type

Port number

Types

Description

Input

0

float

\(v\), longitudinal velocity

Input

1

float

\(\omega\), turn rate

Output

0

ndarray(3)

\(\mathit{q} = (x, y, \theta)\), vehicle configuration

Unicycle kinematic model with velocity and steering inputs and vehicle configuration as output.

Various limits are applied to the inputs:

  • velocity limit speed_max

  • acceleration limit accel_max

  • steering limit steer_max

__init__(w=1, speed_max=inf, accel_max=inf, steer_max=inf, x0=None, **blockargs)[source]
Parameters:
class DiffSteer(w=1, R=1, speed_max=inf, accel_max=inf, steer_max=None, x0=None, **blockargs)[source]

Bases: ContinuousBlock

DIFFSTEER

Differential steer vehicle model

Inputs:

2

Outputs:

1

States:

3

Port type

Port number

Types

Description

Input

0

float

\(\omega_L\), left-wheel angular velocity (radians/sec).

Input

1

float

\(\omega_R\), right-wheel angular velocity (radians/sec).

Output

0

ndarray(3)

\(\mathit{q} = (x, y, \theta)\), vehicle configuration

Differential steering kinematic model with wheel velocity inputs and vehicle configuration as output.

Various limits are applied to the inputs:

  • velocity limit speed_max

  • acceleration limit accel_max

  • steering limit steer_max

Note

Wheel velocity is defined such that if both are positive the vehicle moves forward.

__init__(w=1, R=1, speed_max=inf, accel_max=inf, steer_max=None, x0=None, **blockargs)[source]
Parameters:
class VehiclePlot(animation=None, path_style=None, labels=('X', 'Y'), square=True, init_func=None, limits='auto', shape='car', size=None, polygon_style=None, **blockargs)[source]

Bases: GraphicsBlock

VEHICLEPLOT

Vehicle animation

Inputs:

1

Outputs:

0

States:

0

Port type

Port number

Types

Description

Input

0

float

\(\mathit{q} = (x, y, \theta)\), vehicle configuration

Create a vehicle animation similar to the figure below.

example of generated graphic

Example of vehicle display (animated). The label at the top is the block name.

AXES_POLICY = 'subplot'
TIMESTAMP = True
__init__(animation=None, path_style=None, labels=('X', 'Y'), square=True, init_func=None, limits='auto', shape='car', size=None, polygon_style=None, **blockargs)[source]
Parameters:
  • animation (VehicleAnimationBase | None) – Graphical animation of vehicle, a VehicleAnimationBase subclass, defaults to a VehiclePolygon

  • path_style (str | dict[str, Any] | None) – Matplotlib linestyle string or dict of arguments used to plot the path taken by vehicle, defaults to None (no path)

  • labels (tuple[str, str]) – axis labels (xlabel, ylabel), defaults to (“X”, “Y”)

  • square (bool) – Set aspect ratio to 1, defaults to True

  • init_func (Callable[[Axes], None] | None) – function called with the axes to initialize graphics, defaults to None

  • limits (str | ndarray | Sequence[float]) – axis limits: "auto", [min, max] used for both axes, or [xmin, xmax, ymin, ymax], defaults to "auto"

  • shape (str) – shape of vehicle, passed to the default animation, defaults to "car"

  • size (float | ndarray | Sequence[float] | None) – size of vehicle, passed to the default animation, defaults to None (the animation’s default)

  • polygon_style (dict[str, Any] | None) – Matplotlib patch options (color, alpha, edgecolor, …) for the default animation VehiclePolygon, defaults to None. The dict is not modified.

  • blockargs (Any) – common GraphicsBlock options

Raises:

TypeError – animation is not a VehicleAnimationBase

Deprecated since version 1.5.0: the arguments path, init, scale and polyargs are deprecated, use path_style, init_func, limits and polygon_style instead.

Note

  • The init_func function is called after the axes are initialized and can be used to draw application specific detail on the plot. In the example below, this is the dot and star.

  • If an animation object is not provided then a default polygon animation is created. It’s size and shape can be set by the size and shape parameters, which are passed to the animation object, or a dictionary of arguments polygon_style which is passed to the default animation object.

  • A dynamic trail, showing path to date can be animated if the option path_style is set to a linestyle.