You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/2_vehicle_model/2_vehicle_model.md
+30-25Lines changed: 30 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,17 @@
1
1
# 2. Vehicle Model
2
-
In this chapter, I'm gonna explain about a vehicle model definition. The vehicle model is defined as a four wheels vehicle based on Kinematics and Geometry. And then, the vehicle is controlled by acceleration input and yaw rate input.
2
+
This chapter covers the vehicle model definition. The model is structured as follows:
3
+
4
+
- Type: Four-wheeled vehicle based on kinematics and geometry
5
+
- Control inputs: Acceleration [m/s²] and yaw rate [rad/s]
3
6
4
7
## 2.1 Vehicle's state
5
-
A vehicle's state is defined as follow.
8
+
A vehicle's state is defined as follows.
6
9
7
10
* Position (x, y)[m]
8
11
* Yaw angle[rad]
9
12
* Speed[m/s]
10
13
11
-
State class which manages these data is implemented.
14
+
The `State` class which manages these data is implemented.
12
15
[state.py](/src/components/state/state.py)
13
16
14
17
```python
@@ -50,10 +53,12 @@ class State:
50
53
self.y_history = [self.y_m]
51
54
```
52
55
53
-
In this code, an initial state including position (x, y), yaw angle and speed is given to a constructor. Additionally, one more argument, "color" is defined for setting the color of position (x, y) plot. And then, the position is stored into 2 member variables, x_history and y_history to record it at each time steps. Finally, 3 constant values, STOP_SPEED_MPS, MAX_SPEED_MPS and MIN_SPEED_MPS are defined to limit a range of the speed computation.
56
+
In this code snippet, an initial state including position $(x, y)$, yaw angle and speed is given as input to the constructor. Additionally, one more argument, "color" is defined for setting the color of position (x, y) plot. And then, the position is stored into $2$ member variables, `x_history` and `y_history` to record it at each time steps. Finally, $3$ constant values, STOP_SPEED_MPS, MAX_SPEED_MPS and MIN_SPEED_MPS are defined to limit a range of the speed computation.
54
57
55
58
## 2.2 Vehicle's motion and State equation
56
-
I define the vehicle's motion and a state equation in this section. The vehicle's motion is defined as constant acceleration linear motion model. Then, an input given to the vehicle is acceleration[m/s2] and yaw rate[rad/s]. The vehicle's state can be updated with the input based on the motion model. The positive direction of the vehicle's yaw angle is left direction. This model can be implemented as State class's member methos as follow.
59
+
This section defines the vehicle's motion and state equation. The vehicle's motion is defined as constant acceleration linear motion model. Then, an input given to the vehicle is acceleration[m/s2] and yaw rate[rad/s]. The vehicle's state can be updated with the input based on the motion model. The positive direction of the vehicle's yaw angle is the left direction. This model can be implemented as State class's member method as follows.
60
+
61
+
NOTE: The motion model treats yaw angle as updated only by yaw rate with no coupling to speed.
57
62
58
63
```python
59
64
@staticmethod
@@ -87,14 +92,14 @@ I define the vehicle's motion and a state equation in this section. The vehicle'
87
92
This method is defined as a static method. When you want to use this method, you don't need to generate the State class's object. 2 matrix A and B in this code is to represent multiple state variables as a state equation.
88
93
89
94
## 2.3 Updating vehicle's state
90
-
I implement a member method of State class, "update" to compute the vehicle's state at the next time step. The input of acceleration, yaw rate and an interval time per cycle[sec] are given as arguments.
95
+
This section explains the implementation of the member method of the State class, "update" to compute the vehicle's state at the next time step. The input of acceleration, yaw rate and an interval time per cycle[sec] are given as arguments.
@@ -121,20 +126,20 @@ I implement a member method of State class, "update" to compute the vehicle's st
121
126
self.y_history.append(self.y_m)
122
127
```
123
128
124
-
In this code, a new state at the next time step can be computed with the method, "motion_model". If the updated speed was lower than STOP_SPEED_MPS, the speed would be set to 0 to make the vehicle stopped. And then, the speed is limited between MAX_SPEED_MPS and MIN_SPEED_MPS. Finally, the updated position (x, y) is stored to those list of history.
129
+
In this code, a new state at the next time step can be computed with the method, "motion_model". If the updated speed is lower than STOP_SPEED_MPS, the speed would be set to 0 to bring the vehicle to a stop. And then, the speed is clamped between MAX_SPEED_MPS and MIN_SPEED_MPS. Finally, the updated position $(x, y)$ is appended to the position history lists.
125
130
126
131
## 2.4 Vehicle's parts class
127
-
This section provides the explanation of the vehicle's parts class. The vehicle is separated into the following multiple parts and those drawing classes are implemented.
132
+
This section describes the vehicle's parts class. The vehicle is separated into the following multiple parts with a dedicated drawing class implemented for each.
128
133
129
134
* Body
130
-
*Chasis
135
+
*Chassis
131
136
* Front axle
132
137
* Rear axle
133
138
* Front Right/Left tire
134
139
* Rear Right/Left tire
135
140
136
141
### 2.4.1 Drawing method
137
-
Implementing a member method of State class, "draw" for visualization. In this code, Those lists of x, y history are plot and the current speed is also visualized.
142
+
The `draw`method of the State class is implemented for visualization. In this code, the lists of $x, y$ history are plotted and the current speed is also visualized.
138
143
139
144
```python
140
145
defdraw(self, axes, elems):
@@ -149,7 +154,7 @@ Implementing a member method of State class, "draw" for visualization. In this c
149
154
```
150
155
151
156
### 2.4.2 X-Y Array class
152
-
The vehicle's drawing is represented as x-y 2D array. So, I implement X-Y Array class as follow.
157
+
The vehicle's drawing is represented as x-y 2D array. So, the X-Y Array class is implemented as follows.
153
158
[xy_array.py](/src/components/array/xy_array.py)
154
159
155
160
```python
@@ -198,10 +203,10 @@ class XYArray:
198
203
return XYArray(translated_data)
199
204
```
200
205
201
-
In this code, a given data to Constructor is x-y 2D array. Then, the data can be transformed based on the vehicle's position (x, y) and yaw angle. After the data was transformed, a new XYArray object with the transformed data is returned.
206
+
In this code, the data passed to the constructor is a 2D x-y array. Then, the data can be transformed based on the vehicle's position (x, y) and yaw angle. After transformation, a new XYArray object with the transformed data is returned.
202
207
203
208
### 2.4.3 Specification class
204
-
Implementing Vehicle's specification class as follow. This class is used to manage each parameters for the vehicle's control.
209
+
The `VehicleSpecification`class is implemented as follows. This class is used to manage the parameters for the vehicle's control.
Vehicle front right tire class is implemented as follow. This class is used for drawing the vehicle's front right tire according to the specification.
555
+
Vehicle front right tire class is implemented as follows. This class is used for drawing the vehicle's front right tire according to the specification.
You can see the following animation by executing this program. In this animation, the size of limited area is 10m x 10m. This size is defined as default values of VehicleSpecification class's parameters.
937
+
You can see the following animation by executing this program. In this animation, the size of the limited area is 10m x 10m. This size is defined as default values of VehicleSpecification class's parameters.
0 commit comments