Skip to content

Commit 611f8ad

Browse files
authored
Merge pull request #76 from mohitk3000/docs-vehicle-model
Documentation: Review contents and English expression for doc/2_vehicle_model
2 parents 87ddd36 + 627b8dd commit 611f8ad

2 files changed

Lines changed: 31 additions & 26 deletions

File tree

doc/2_vehicle_model/2_vehicle_model.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# 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]
36

47
## 2.1 Vehicle's state
5-
A vehicle's state is defined as follow.
8+
A vehicle's state is defined as follows.
69

710
* Position (x, y)[m]
811
* Yaw angle[rad]
912
* Speed[m/s]
1013

11-
State class which manages these data is implemented.
14+
The `State` class which manages these data is implemented.
1215
[state.py](/src/components/state/state.py)
1316

1417
```python
@@ -50,10 +53,12 @@ class State:
5053
self.y_history = [self.y_m]
5154
```
5255

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.
5457

5558
## 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.
5762

5863
```python
5964
@staticmethod
@@ -87,14 +92,14 @@ I define the vehicle's motion and a state equation in this section. The vehicle'
8792
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.
8893

8994
## 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.
9196

9297
```python
9398
def update(self, accel_mps2, yaw_rate_rps, time_s):
9499
"""
95100
Function to update state
96101
accel_mps2: Acceleration[m/s^2]
97-
steer_rad: Steering angle[rad]
102+
yaw_rate_rps: Yaw rate [rad/s]
98103
time_s: Time interval per cycle[sec]
99104
"""
100105

@@ -121,20 +126,20 @@ I implement a member method of State class, "update" to compute the vehicle's st
121126
self.y_history.append(self.y_m)
122127
```
123128

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.
125130

126131
## 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.
128133

129134
* Body
130-
* Chasis
135+
* Chassis
131136
* Front axle
132137
* Rear axle
133138
* Front Right/Left tire
134139
* Rear Right/Left tire
135140

136141
### 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.
138143

139144
```python
140145
def draw(self, axes, elems):
@@ -149,7 +154,7 @@ Implementing a member method of State class, "draw" for visualization. In this c
149154
```
150155

151156
### 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.
153158
[xy_array.py](/src/components/array/xy_array.py)
154159

155160
```python
@@ -198,10 +203,10 @@ class XYArray:
198203
return XYArray(translated_data)
199204
```
200205

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.
202207

203208
### 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.
205210
[vehicle_specification.py](/src/components/vehicle/vehicle_specification.py)
206211

207212
```python
@@ -287,7 +292,7 @@ The vehicle has the following parameters as specification. The vehicle is drawn
287292
* Maximum acceleration[m/s2]
288293

289294
### 2.4.4 Body class
290-
Vehicle body class is implemented as follow. This class is used for drawing the vehicle's body according to the specification.
295+
Vehicle body class is implemented as follows. This class is used for drawing the vehicle's body as per the specification.
291296
[body.py](/src/components/vehicle/body.py)
292297

293298
```python
@@ -337,7 +342,7 @@ class Body:
337342
```
338343

339344
### 2.4.5 Chassis class
340-
Vehicle chassis class is implemented as follow. This class is used for drawing the vehicle's chassis according to the specification.
345+
Vehicle chassis class is implemented as follows. This class is used for drawing the vehicle's chassis according to the specification.
341346
[chassis.py](/src/components/vehicle/chassis.py)
342347

343348
```python
@@ -387,7 +392,7 @@ class Chassis:
387392
```
388393

389394
### 2.4.6 Front axle class
390-
Vehicle front axle class is implemented as follow. This class is used for drawing the vehicle's front axle according to the specification.
395+
Vehicle front axle class is implemented as follows. This class is used for drawing the vehicle's front axle according to the specification.
391396
[front_axle.py](/src/components/vehicle/front_axle.py)
392397

393398
```python
@@ -440,7 +445,7 @@ class FrontAxle:
440445
```
441446

442447
### 2.4.7 Rear axle class
443-
Vehicle rear axle class is implemented as follow. This class is used for drawing the vehicle's rear axle according to the specification.
448+
Vehicle rear axle class is implemented as follows. This class is used for drawing the vehicle's rear axle according to the specification.
444449
[rear_axle.py](/src/components/vehicle/rear_axle.py)
445450

446451
```python
@@ -493,7 +498,7 @@ class RearAxle:
493498
```
494499

495500
### 2.4.8 Front left tire class
496-
Vehicle front left tire class is implemented as follow. This class is used for drawing the vehicle's front left tire according to the specification.
501+
Vehicle front left tire class is implemented as follows. This class is used for drawing the vehicle's front left tire according to the specification.
497502
[front_left_tire.py](/src/components/vehicle/front_left_tire.py)
498503

499504
```python
@@ -547,7 +552,7 @@ class FrontLeftTire:
547552
```
548553

549554
### 2.4.9 Front right tire class
550-
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.
551556
[front_right_tire.py](/src/components/vehicle/front_right_tire.py)
552557

553558
```python
@@ -601,7 +606,7 @@ class FrontRightTire:
601606
```
602607

603608
### 2.4.10 Rear left tire class
604-
Vehicle rear left tire class is implemented as follow. This class is used for drawing the vehicle's rear left tire according to the specification.
609+
Vehicle rear left tire class is implemented as follows. This class is used for drawing the vehicle's rear left tire as per the specification.
605610
[rear_left_tire.py](/src/components/vehicle/rear_left_tire.py)
606611

607612
```python
@@ -654,7 +659,7 @@ class RearLeftTire:
654659
```
655660

656661
### 2.4.11 Rear right tire class
657-
Vehicle rear left tire class is implemented as follow. This class is used for drawing the vehicle's rear left tire according to the specification.
662+
Vehicle rear right tire class is implemented as follows. This class is used for drawing the vehicle's rear right tire as per the specification.
658663
[rear_right_tire.py](/src/components/vehicle/rear_right_tire.py)
659664

660665
```python
@@ -707,7 +712,7 @@ class RearRightTire:
707712
```
708713

709714
### 2.4.12 Four wheels vehicle class
710-
FourWheelsVehicle class is implemented by importing the above each parts class.
715+
`FourWheelsVehicle` class is implemented by composing the part classes above.
711716
[four_wheels_vehicle.py](/src/components/vehicle/four_wheels_vehicle.py)
712717

713718
```python
@@ -864,7 +869,7 @@ You can see the following animation by executing this program.
864869
![](/doc/2_vehicle_model/visualize_vehicle.gif)
865870

866871
### 2.5.2 With zoom
867-
This program can visualize the vehicle within an limited area in global coordinate system. The size of limited area can be set as parameters.
872+
This program can visualize the vehicle within a limited area in global coordinate system. The size of the limited area can be set as parameters.
868873
[visualize_vehicle_zoom.py](/doc/2_vehicle_model/visualize_vehicle_zoom.py)
869874

870875
```python
@@ -929,5 +934,5 @@ if __name__ == "__main__":
929934
main()
930935
```
931936

932-
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.
933938
![](/doc/2_vehicle_model/visualize_vehicle_zoom.gif)

src/components/state/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def update(self, accel_mps2, yaw_rate_rps, time_s):
6666
"""
6767
Function to update state
6868
accel_mps2: Acceleration[m/s^2]
69-
steer_rad: Steering angle[rad]
69+
yaw_rate_rps: Yaw rate[rad/s]
7070
time_s: Time interval per cycle[sec]
7171
"""
7272

0 commit comments

Comments
 (0)