Bindings for Automotive systems

class pydrake.automotive.AheadOrBehind

Specifies whether to assess the cars ahead or behind the ego car at its current orientation with respect to its lane.


kAhead :

kBehind :

__init__(self: pydrake.automotive.AheadOrBehind, arg0: int) → None
kAhead = AheadOrBehind.kAhead
kBehind = AheadOrBehind.kBehind

(self – handle) -> str

class pydrake.automotive.ClosestPose

ClosestPose bundles together the RoadOdometry of a particular target along with its distance measure relative to the ego vehicle. Its intended use is as the return argument for PoseSelector member functions.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.automotive.ClosestPose) -> None

Default constructor.

  1. __init__(self: pydrake.automotive.ClosestPose, odom: drake::automotive::RoadOdometry<double>, dist: float) -> None

Constructs the ClosestPose via a full parameterization.

class pydrake.automotive.DrivingCommand


Specializes BasicVector with specific getters and setters.

__init__(self: pydrake.automotive.DrivingCommand) → None

Default constructor. Sets all rows to their default value:

  • steering_angle defaults to 0.0 rad.
  • acceleration defaults to 0.0 m/s^2.
acceleration(self: pydrake.automotive.DrivingCommand) → float

The signed acceleration, positive means speed up; negative means slow down, but should not move in reverse.


acceleration is expressed in units of m/s^2.

set_acceleration(self: pydrake.automotive.DrivingCommand, arg0: float) → None

Setter that matches acceleration().

set_steering_angle(self: pydrake.automotive.DrivingCommand, arg0: float) → None

Setter that matches steering_angle().

steering_angle(self: pydrake.automotive.DrivingCommand) → float

The desired steering angle of a virtual center wheel, positive results in the vehicle turning left.


steering_angle is expressed in units of rad.

class pydrake.automotive.IdmController


IdmController implements the IDM (Intelligent Driver Model) planner, computed based only on the nearest car ahead. See IdmPlanner and PoseSelector for details. The output of this block is an acceleration value passed as a command to the vehicle.

Input Port 0: PoseVector for the ego car. (InputPort getter: ego_pose_input())

Input Port 1: FrameVelocity of the ego car. (InputPort getter: ego_velocity_input())

Input Port 2: PoseBundle for the traffic cars, possibly inclusive of the ego car’s pose. (InputPort getter: traffic_input())

Output Port 0: A BasicVector containing the acceleration request. (OutputPort getter: acceleration_output())

Instantiated templates for the following kinds of T’s are provided:

  • double
  • AutoDiffXd

They are already available to link against in the containing library.

__init__(self: pydrake.automotive.IdmController, road: drake::maliput::api::RoadGeometry, path_or_branches: pydrake.automotive.ScanStrategy, road_position_strategy: pydrake.automotive.RoadPositionStrategy, period_sec: float) → None


Parameter road:
The pre-defined RoadGeometry.
Parameter path_or_branches:
If ScanStrategy::kBranches, performs IDM computations using vehicles detected in confluent branches; if ScanStrategy::kPath, limits to vehicles on the default path. See documentation for PoseSelector::FindSingleClosestPose().
Parameter road_position_strategy:
Determines whether or not to cache RoadPosition. See calc_ongoing_road_position.h.
Parameter period_sec:
The update period to use if road_position_strategy == RoadPositionStrategy::kCache.
acceleration_output(self: pydrake.automotive.IdmController) →[float]
ego_pose_input(self: pydrake.automotive.IdmController) →[float]

See the class description for details on the following input ports.

ego_velocity_input(self: pydrake.automotive.IdmController) →[float]
traffic_input(self: pydrake.automotive.IdmController) →[float]
class pydrake.automotive.LaneDirection

LaneDirection holds the lane that a MaliputRailcar is traversing and the direction in which it is moving. A MaliputRailcar can either travel in the increasing-s direction or in the decreasing-s direction.

__init__(self: pydrake.automotive.LaneDirection, lane: drake::maliput::api::Lane, with_s: bool) → None

Fully parameterized constructor.


True means that the MaliputRailcar’s s coordinate increases when the vehicle has positive speed. False means the opposite.

class pydrake.automotive.PoseSelector

PoseSelector is a class that provides the relevant pose or poses with respect to a given ego vehicle driving within a given maliput road geometry.

Instantiated templates for the following kinds of T’s are provided:

  • double
  • AutoDiffXd

They are already available to link against in the containing library.

FindClosestPair(lane: drake::maliput::api::Lane, ego_pose:, traffic_poses:, scan_distance: float, path_or_branches: pydrake.automotive.ScanStrategy) → Dict[pydrake.automotive.AheadOrBehind, pydrake.automotive.ClosestPose]

Returns the leading and trailing vehicles in a given lane or road that are closest to an ego vehicle along its path, as measured along the s-coordinate of the ego vehicle’s lane. If path_or_branches is ScanStrategy::kPath, only poses in the same path as the ego (ahead or behind) are tracked; if ScanStrategy::kBranches, poses in lanes that eventually merge (converge to the same branch point that is on the default path of lane) are considered in addition to those along the ego car’s default path.

Users should take heed to the fact that ScanStrategy::kBranches does not assess the relationship between traffic and ego vehicle velocity when selecting poses. Thus, cars within the same lane as the ego but with negative net-velocity (approaching the ego car, from the ego’s point-of-view) could be ignored in favor of a car in a branch with positive net-velocity.

The ego vehicle must be within the driveable_bounds of lane (i.e. the road is contiguous with lane along the r-direction). This function is used, for instance, as logic for lane-change planners (e.g. MOBIL). The ego car’s pose (ego_pose) and the poses of the traffic cars (traffic_poses) are provided. The parameter scan_distance determines the distance along the sequence of lanes to scan before declaring that no traffic car is ahead (resp. behind) the ego car.

Returns:A map of AheadOrBehind values to vehicle ClosestPoses (containing RoadOdometries and closest relative distances). Relative distances are always positive, and a distance of positive infinity is returned if no traffic cars are found. Note that when no vehicle is detected in front of (resp. behind) the ego vehicle, the respective RoadPosition within ClosestPoses will contain an s-value of positive (resp. negative) infinity. Any traffic poses that are redundant with ego_pose (i.e. have the same RoadPosition as the ego car and thus the same s and r value) are discarded. If no leading/trailing vehicles are seen within scan-distance of the ego car, s-positions are taken to be at infinite distances away from the ego car. Note also that traffic vehicles having exactly the same s-position as the ego vehicle but with different r-value or are directly perpendicular in a Lane::to_left(), Lane::to_right() lane are taken to be behind the ego vehicle. Note that this implementation is greatly simplified by considering poses as points (i.e. vehicle geometries are ignored).

The RoadGeometry from which lane is drawn is required to have default branches set for all branches in the road network.

FindSingleClosestPose(lane: drake::maliput::api::Lane, ego_pose:, traffic_poses:, scan_distance: float, side: pydrake.automotive.AheadOrBehind, path_or_branches: pydrake.automotive.ScanStrategy) → pydrake.automotive.ClosestPose

Same as PoseSelector::FindClosestPair() except that it returns a single ClosestPose for either the vehicle ahead (AheadOrBehind::kAhead) or behind (AheadOrBehind::kBehind).

Cars in other lanes are only tracked if they are in confluent lanes to a given branch point within the scan_distance; i.e. cars in two side-by-side lanes that never enter a branch point will not be selected. This assumes that the ego car has knowledge of the traffic cars’ default lane.

Note that when no car is detected in front of the ego car, the returned RoadOdometry within ClosestPose will contain an s-value of std::numeric_limits<double>::infinity().

GetSigmaVelocity(arg0: pydrake.automotive.RoadOdometry) → float

Extracts the vehicle’s s-direction velocity based on its RoadOdometry road_odometry in the Lane coordinate frame. Assumes the road has zero elevation and superelevation.

  • RuntimeError if any element of road_odometry.pos is not within
  • the respective bounds of road_odometry.lane.


This function currently only provides exact derivatives for velocity in the s direction when the road is straight (no yaw angle variations).


x.__init__(…) initializes x; see help(type(x)) for signature

class pydrake.automotive.PurePursuitController


PurePursuitController implements a pure pursuit controller. See PurePursuit for details on the approach.

Instantiated templates for the following kinds of T’s are provided:

  • double
  • AutoDiffXd

They are already available to link against in the containing library.

Input Port 0: a LaneDirection representing the requested lane and direction of travel. (InputPort getter: lane_input())

Input Port 1: PoseVector for the ego car. (InputPort getter: ego_pose_input())

Output Port 0: A BasicVector of size one with the commanded steering angle. (OutputPort getter: steering_command_output())

__init__(self: pydrake.automotive.PurePursuitController) → None


ego_pose_input(self: pydrake.automotive.PurePursuitController) →[float]
lane_input(self: pydrake.automotive.PurePursuitController) →[float]

Returns the port to the individual input/output ports.

steering_command_output(self: pydrake.automotive.PurePursuitController) →[float]
class pydrake.automotive.RoadOdometry

RoadOdometry contains the position of the vehicle with respect to a lane in a road, along with its velocity vector in the world frame.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pydrake.automotive.RoadOdometry) -> None

Default constructor.

  1. __init__(self: pydrake.automotive.RoadOdometry, road_position: drake::maliput::api::RoadPosition, frame_velocity: -> None

Fully-parameterized constructor.

  1. __init__(self: pydrake.automotive.RoadOdometry, lane: drake::maliput::api::Lane, lane_position: drake::maliput::api::LanePositionT<double>, frame_velocity: -> None

Fully-parameterized constructor that is T-supported.

class pydrake.automotive.RoadPositionStrategy

If kCache, configures a planning system (e.g. IdmController, MobilPlanner) to declare an abstract state that caches the last-computed RoadPosition. If kExhaustiveSearch, then the system will contain no abstract states. Note that the kCache option is for performance speedup (at the expense of optimizer compatibility) by preventing a potentially sizeable computation within RoadGeometry::ToRoadPosition().


kExhaustiveSearch :

kCache :

__init__(self: pydrake.automotive.RoadPositionStrategy, arg0: int) → None
kCache = RoadPositionStrategy.kCache
kExhaustiveSearch = RoadPositionStrategy.kExhaustiveSearch

(self – handle) -> str

class pydrake.automotive.ScanStrategy

Specifies whether to check ongoing lanes or both ongoing lanes and confluent branches for traffic.


kPath :

kBranches :

__init__(self: pydrake.automotive.ScanStrategy, arg0: int) → None
kBranches = ScanStrategy.kBranches
kPath = ScanStrategy.kPath

(self – handle) -> str

class pydrake.automotive.SimpleCar


SimpleCar models an idealized response to driving commands, neglecting all physics. Note that SimpleCar can move forward, stop, turn left, and turn right but cannot travel in reverse.


  • uses systems::Parameters wrapping a SimpleCarParams

state vector (planar for now):

  • position: x, y, heading; heading is 0 rad when pointed +x, pi/2 rad when pointed +y; heading is defined around the +z axis, so positive-turn-left
  • velocity

input vector:

  • steering angle (virtual center wheel angle); a positive angle means a positive change in heading (left turn); the value must lie within (-pi, +pi).
  • throttle (0-1)
  • brake (0-1)

output port 0: same as state vector. output port 1: A PoseVector containing X_WC, where C is the car frame. output port 2: A FrameVelocity containing Xdot_WC, where C is the car frame.

Template parameter T:
must support certain arithmetic operations; for details, see drake::symbolic::Expression.

Instantiated templates for the following ScalarTypes are provided:

  • double
  • drake::AutoDiffXd
  • drake::symbolic::Expression

They are already available to link against in the containing library.

__init__(self: pydrake.automotive.SimpleCar) → None

Constructs a default car.

pose_output(self: pydrake.automotive.SimpleCar) →[float]
state_output(self: pydrake.automotive.SimpleCar) →[float]
velocity_output(self: pydrake.automotive.SimpleCar) →[float]
class pydrake.automotive.SimpleCarState


Specializes BasicVector with specific getters and setters.

__init__(self: pydrake.automotive.SimpleCarState) → None

Default constructor. Sets all rows to their default value:

  • x defaults to 0.0 with unknown units.
  • y defaults to 0.0 with unknown units.
  • heading defaults to 0.0 with unknown units.
  • velocity defaults to 0.0 with unknown units.
heading(self: pydrake.automotive.SimpleCarState) → float


set_heading(self: pydrake.automotive.SimpleCarState, arg0: float) → None

Setter that matches heading().

set_velocity(self: pydrake.automotive.SimpleCarState, arg0: float) → None

Setter that matches velocity().

set_x(self: pydrake.automotive.SimpleCarState, arg0: float) → None

Setter that matches x().

set_y(self: pydrake.automotive.SimpleCarState, arg0: float) → None

Setter that matches y().

velocity(self: pydrake.automotive.SimpleCarState) → float


x(self: pydrake.automotive.SimpleCarState) → float


y(self: pydrake.automotive.SimpleCarState) → float