Dynamic Bicycle
commonroad_control.vehicle_dynamics.dynamic_bicycle.dynamic_bicycle
DynamicBicycle
Bases: VehicleModelInterface
Dynamic bicycle model with linear tyre model. Reference point for the vehicle dynamics: center of gravity.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/dynamic_bicycle.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
_compute_lateral_tyre_forces(x, u)
Computes the lateral tyre forces at the front and rear axle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[sym, array]
|
state - CasADi symbolic/ array of dimension (self._nx,) |
required |
u
|
Union[sym, array]
|
control input - CasADi symbolic/ array of dimension (self._nu,) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[Union[float, sym], Union[float, sym]]
|
lateral tyre forces at front and rear axle - float/ CasADi symbolic |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/dynamic_bicycle.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
_dynamics_cas(x, u, w)
Continuous-time dynamics function of the vehicle model for simulation and symbolic operations using CasADi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[sym, ndarray[tuple[float], dtype[float64]]]
|
state - CasADi symbolic/ array of dimension (self._nx,) |
required |
u
|
Union[sym, ndarray[tuple[float], dtype[float64]]]
|
control input - CasADi symbolic/ array of dimension (self._nu,) |
required |
w
|
Union[sym, ndarray[tuple[float], dtype[float64]]]
|
disturbance - CasADi symbolic/ array of dimension (self._nw,) |
required |
Returns:
| Type | Description |
|---|---|
Union[sym, array]
|
dynamics function evaluated at (x,u,w) - CasADi symbolic/ array of dimension (self._nx,) |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/dynamic_bicycle.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
_set_input_bounds(params)
Extract input bounds from vehicle parameters and returns them as instances of the Input class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
VehicleParameters
|
vehicle parameters |
required |
Returns:
| Type | Description |
|---|---|
Tuple[DBInput, DBInput]
|
lower and upper bound on the inputs - DBInputs |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/dynamic_bicycle.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
compute_normalized_acceleration(x, u)
Computes the normalized longitudinal and lateral acceleration (w.r.t. the maximum acceleration).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[DBState, sym, array]
|
state - StateInterface/ CasADi symbolic/ array of dimension (self._nx,) |
required |
u
|
Union[DBInput, sym, array]
|
control input - InputInterface/ CasADi symbolic/ array of dimension (self._nu,) |
required |
Returns:
| Type | Description |
|---|---|
Tuple[Union[float, sym], Union[float, sym]]
|
normalized longitudinal and lateral acceleration - float/ CasADi symbolic |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/dynamic_bicycle.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
factory_method(params, delta_t)
classmethod
Factory method to generate class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
VehicleParameters
|
CommonRoad-Control vehicle params |
required |
delta_t
|
float
|
sampling time |
required |
Returns:
| Type | Description |
|---|---|
DynamicBicycle
|
instance |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/dynamic_bicycle.py
29 30 31 32 33 34 35 36 37 | |
commonroad_control.vehicle_dynamics.dynamic_bicycle.db_state
DBState
dataclass
Bases: StateInterface
Dataclass storing the states of the dynamic bicycle model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_state.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
dim
property
Returns:
| Type | Description |
|---|---|
int
|
state dimension |
velocity
property
Returns:
| Type | Description |
|---|---|
float
|
absolute value of velocity of the vehicle |
convert_to_array()
Converts instance of class to numpy array.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray of dimension (self.dim,) |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_state.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
to_cr_custom_state(time_step)
Convert to CommonRoad custom state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_step
|
int
|
time step - int |
required |
Returns:
| Type | Description |
|---|---|
CustomState
|
CommonRoad custom state |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_state.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
to_cr_initial_state(time_step)
Convert to CommonRoad initial state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_step
|
int
|
time step - int |
required |
Returns:
| Type | Description |
|---|---|
InitialState
|
CommonRoad InitialState |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_state.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
DBStateIndices
dataclass
Bases: StateInterfaceIndex
Indices of the states of the dynamic bicycle model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_state.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
commonroad_control.vehicle_dynamics.dynamic_bicycle.db_input
DBInput
dataclass
Bases: InputInterface
Dataclass storing the control input of the dynamic bicycle model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_input.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
dim
property
Returns:
| Type | Description |
|---|---|
int
|
control input dimension |
convert_to_array()
Converts instance of class to numpy array.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray of dimension (self.dim,) |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_input.py
38 39 40 41 42 43 44 45 46 47 48 | |
DBInputIndices
dataclass
Bases: InputInterfaceIndex
Indices of the control inputs of the dynamic bicycle model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_input.py
11 12 13 14 15 16 17 18 19 | |
commonroad_control.vehicle_dynamics.dynamic_bicycle.db_trajectory
DBTrajectory
dataclass
Bases: TrajectoryInterface
Dynamic bicycle model Trajectory
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_trajectory.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
to_cr_dynamic_obstacle(vehicle_width, vehicle_length, vehicle_id)
Converts state trajectory to CommonRoad dynamic obstacles for plotting
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vehicle_width
|
float
|
vehicle width |
required |
vehicle_length
|
float
|
vehicle length |
required |
vehicle_id
|
int
|
vehicle id |
required |
Returns:
| Type | Description |
|---|---|
DynamicObstacle
|
CommonRoad dynamic obstacle |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_trajectory.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
commonroad_control.vehicle_dynamics.dynamic_bicycle.db_disturbance
DBDisturbance
dataclass
Bases: DisturbanceInterface
Dataclass storing the disturbances of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_disturbance.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
dim
property
Returns:
| Type | Description |
|---|---|
int
|
disturbance dimension |
convert_to_array()
Converts instance of class to numpy array.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray of dimension (self.dim,) |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_disturbance.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
DBDisturbanceIndices
dataclass
Bases: DisturbanceInterfaceIndex
Indices of the disturbances of the dynamic bicycle model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_disturbance.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
commonroad_control.vehicle_dynamics.dynamic_bicycle.db_noise
DBNoise
dataclass
Bases: FullStateNoiseInterface
Full state noise of the dynamic bicycle model - required for the full state feedback sensor model.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_noise.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
dim
property
Returns:
| Type | Description |
|---|---|
int
|
noise dimension |
convert_to_array()
Converts instance of class to numpy array.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray of dimension (self.dim,) |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_noise.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
DBNoiseIndices
dataclass
Bases: FullStateNoiseInterfaceIndex
Indices of the noise variables.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_noise.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
commonroad_control.vehicle_dynamics.dynamic_bicycle.db_sidt_factory
DBSIDTFactory
Bases: StateInputDisturbanceTrajectoryFactoryInterface
Factory for creating dynamic bicycle model State, Input, Disturbance, and Trajectory.
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
disturbance_from_args(position_x=0.0, position_y=0.0, velocity_long=0.0, velocity_lat=0.0, heading=0.0, yaw_rate=0.0, steering_angle=0.0)
classmethod
Create Disturbance from args - the default value of all variables is zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position_x
|
float
|
position x of center of gravity (Cartesian coordinates) |
0.0
|
position_y
|
float
|
position y of center of gravity (Cartesian coordinates) |
0.0
|
velocity_long
|
float
|
longitudinal velocity (body frame) |
0.0
|
velocity_lat
|
float
|
lateral velocity (body frame) |
0.0
|
heading
|
float
|
heading |
0.0
|
yaw_rate
|
float
|
yaw rate |
0.0
|
steering_angle
|
float
|
steering angle |
0.0
|
Returns:
| Type | Description |
|---|---|
Union[DBDisturbance]
|
DBDisturbance |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
disturbance_from_numpy_array(w_np)
classmethod
Create Disturbance from numpy array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
w_np
|
ndarray[tuple[float], dtype[float64]]
|
disturbance - array of dimension (cls.disturbance_dimension,) |
required |
Returns:
| Type | Description |
|---|---|
Union[DBDisturbance]
|
DBDisturbance |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
input_from_args(acceleration, steering_angle_velocity)
classmethod
Create Input from args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acceleration
|
float
|
longitudinal acceleration |
required |
steering_angle_velocity
|
float
|
lateral acceleration |
required |
Returns:
| Type | Description |
|---|---|
Union[DBInput]
|
DBInput |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
70 71 72 73 74 75 76 77 78 | |
input_from_numpy_array(u_np)
classmethod
Create Input from numpy array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u_np
|
ndarray[tuple[float], dtype[float64]]
|
control input - array of dimension (cls.input_dimension,) |
required |
Returns:
| Type | Description |
|---|---|
Union[DBInput]
|
DBInput |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
state_from_args(position_x, position_y, velocity_long, velocity_lat, heading, yaw_rate, steering_angle)
classmethod
Create State from args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position_x
|
float
|
position x of center of gravity (Cartesian coordinates) |
required |
position_y
|
float
|
position y of center of gravity (Cartesian coordinates) |
required |
velocity_long
|
float
|
longitudinal velocity (body frame) |
required |
velocity_lat
|
float
|
lateral velocity (body frame) |
required |
heading
|
float
|
heading |
required |
yaw_rate
|
float
|
yaw rate |
required |
steering_angle
|
float
|
steering angle |
required |
Returns:
| Type | Description |
|---|---|
Union[DBState]
|
DBState |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
state_from_numpy_array(x_np)
classmethod
Create State from numpy array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_np
|
ndarray[tuple[float], dtype[float64]]
|
state vector - array of dimension (cls.state_dimension,) |
required |
Returns:
| Type | Description |
|---|---|
Union[DBState]
|
DBState |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
trajectory_from_numpy_array(traj_np, mode, time_steps, t_0, delta_t)
classmethod
Create State, Input, or Disturbance Trajectory from numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj_np
|
ndarray[tuple[float, float], dtype[float64]]
|
numpy array storing the values of the point variables |
required |
mode
|
TrajectoryMode
|
type of points (State, Input, or Disturbance) |
required |
time_steps
|
List[int]
|
time steps of the points in the columns of traj_np |
required |
t_0
|
float
|
initial time - float |
required |
delta_t
|
float
|
sampling time - float |
required |
Returns:
| Type | Description |
|---|---|
DBTrajectory
|
DBTrajectory |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
trajectory_from_points(trajectory_dict, mode, t_0, delta_t)
classmethod
Create State, Input, or Disturbance Trajectory from list of DB points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory_dict
|
Union[Dict[int, DBState], Dict[int, DBInput]]
|
dict of time steps to kb points |
required |
mode
|
TrajectoryMode
|
type of points (State, Input, or Disturbance) |
required |
t_0
|
float
|
initial time - float |
required |
delta_t
|
float
|
sampling time - float |
required |
Returns:
| Type | Description |
|---|---|
DBTrajectory
|
DBTrajectory |
Source code in commonroad_control/vehicle_dynamics/dynamic_bicycle/db_sidt_factory.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |