Kinematic Bicycle
commonroad_control.vehicle_dynamics.kinematic_bicycle.kinematic_bicycle
KinematicBicycle
Bases: VehicleModelInterface
Kinematic bicycle model. Reference point for the vehicle dynamics: center of gravity.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kinematic_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 | |
_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/kinematic_bicycle/kinematic_bicycle.py
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 | |
_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[KBInput, KBInput]
|
lower and upper bound on the inputs - KBInputs |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kinematic_bicycle.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
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[KBState, sym, array]
|
state - StateInterface/ CasADi symbolic/ array of dimension (self._nx,) |
required |
u
|
Union[KBInput, 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/kinematic_bicycle/kinematic_bicycle.py
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 | |
factory_method(params, delta_t)
classmethod
Factory method to generate class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
VehicleParameters
|
CommonRoad-Control vehicle parameters |
required |
delta_t
|
float
|
sampling time |
required |
Returns:
| Type | Description |
|---|---|
KinematicBicycle
|
instance |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kinematic_bicycle.py
29 30 31 32 33 34 35 36 37 | |
commonroad_control.vehicle_dynamics.kinematic_bicycle.kb_state
KBState
dataclass
Bases: StateInterface
Dataclass storing the states of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_state.py
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 | |
dim
property
Returns:
| Type | Description |
|---|---|
int
|
state 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/kinematic_bicycle/kb_state.py
45 46 47 48 49 50 51 52 53 54 55 56 57 | |
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/kinematic_bicycle/kb_state.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
to_cr_initial_state(time_step)
Convert to CommonRoad initial state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_step
|
int
|
time step |
required |
Returns:
| Type | Description |
|---|---|
InitialState
|
CommonRoad InitialState |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_state.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
KBStateIndices
dataclass
Bases: StateInterfaceIndex
Indices of the states of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_state.py
12 13 14 15 16 17 18 19 20 21 22 23 | |
commonroad_control.vehicle_dynamics.kinematic_bicycle.kb_input
KBInput
dataclass
Bases: InputInterface
Dataclass storing the control input of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_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/kinematic_bicycle/kb_input.py
38 39 40 41 42 43 44 45 46 47 48 | |
KBInputIndices
dataclass
Bases: InputInterfaceIndex
Indices of the control inputs of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_input.py
11 12 13 14 15 16 17 18 19 | |
commonroad_control.vehicle_dynamics.kinematic_bicycle.kb_trajectory
KBTrajectory
dataclass
Bases: TrajectoryInterface
Kinematic bicycle model Trajectory.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_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 68 | |
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/kinematic_bicycle/kb_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 68 | |
commonroad_control.vehicle_dynamics.kinematic_bicycle.kb_disturbance
KBDisturbance
dataclass
Bases: DisturbanceInterface
Dataclass storing the disturbances of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_disturbance.py
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 | |
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/kinematic_bicycle/kb_disturbance.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
KBDisturbanceIndices
dataclass
Bases: DisturbanceInterfaceIndex
Indices of the disturbances of the kinematic bicycle model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_disturbance.py
11 12 13 14 15 16 17 18 19 20 21 22 | |
commonroad_control.vehicle_dynamics.kinematic_bicycle.kb_noise
KBNoise
dataclass
Bases: FullStateNoiseInterface
Full state noise of the kinematic bicycle model - required for the full state feedback sensor model.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_noise.py
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 | |
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/kinematic_bicycle/kb_noise.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
KBNoiseIndices
dataclass
Bases: FullStateNoiseInterfaceIndex
Indices of the noise variables.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_noise.py
11 12 13 14 15 16 17 18 19 20 21 22 | |
commonroad_control.vehicle_dynamics.kinematic_bicycle.kb_sidt_factory
KBSIDTFactory
Bases: StateInputDisturbanceTrajectoryFactoryInterface
Factory for creating kinematic bicycle model State, Input, Disturbance, and Trajectory.
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
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 | |
disturbance_from_args(position_x=0.0, position_y=0.0, velocity=0.0, heading=0.0, steering_angle=0.0)
staticmethod
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 |
0.0
|
position_y
|
float
|
position y of center of gravity |
0.0
|
velocity
|
float
|
velocity |
0.0
|
heading
|
float
|
heading |
0.0
|
steering_angle
|
float
|
steering angle |
0.0
|
Returns:
| Type | Description |
|---|---|
Union['KBDisturbance']
|
KBDisturbance |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_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 | |
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['KBDisturbance']
|
KBDisturbance |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
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
|
steering angle velocity |
required |
Returns:
| Type | Description |
|---|---|
Union['KBInput']
|
KBInput |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
66 67 68 69 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['KBInput']
|
KBInput |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
state_from_args(position_x, position_y, velocity, heading, 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
|
float
|
velocity |
required |
heading
|
float
|
heading |
required |
steering_angle
|
float
|
steering angle |
required |
Returns:
| Type | Description |
|---|---|
Union['KBState']
|
KBState |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
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 | |
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['KBState']
|
KBState |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
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 |
|---|---|
'KBTrajectory'
|
KBTrajectory |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
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 | |
trajectory_from_points(trajectory_dict, mode, t_0, delta_t)
classmethod
Create State, Input, or Disturbance Trajectory from list of KB points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory_dict
|
Union[Dict[int, KBState], Dict[int, KBInput]]
|
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 |
|---|---|
'KBTrajectory'
|
KBTrajectory |
Source code in commonroad_control/vehicle_dynamics/kinematic_bicycle/kb_sidt_factory.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |