Skip to content

Commit ffcf31e

Browse files
author
Shiye Shizhi
committed
implemented obstacle list class
1 parent 7cec817 commit ffcf31e

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

doc/3_sensor_models/3_1_obstacle.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,62 @@ The method, vertex_xy is used to get the vertexes coordinates (x, y) of the obst
9292
transformed_array = self.array.homogeneous_transformation(x_m, y_m, yaw_rad)
9393

9494
return transformed_array.get_x_data(), transformed_array.get_y_data()
95-
```
95+
```
96+
97+
### 3.1.2 Obstacles list
98+
ObstacleList class is implemented to execute update and draw the data of multiple obstacles sequencially. An object of this list is given to a visualizer object and a sensor model object.
99+
100+
[obstacle_list.py](/src/components/obstacle/obstacle_list.py)
101+
```python
102+
"""
103+
obstacle_list.py
104+
105+
Author: Shisato Yano
106+
"""
107+
108+
class ObstacleList:
109+
"""
110+
Obstacles list class
111+
"""
112+
113+
def __init__(self):
114+
"""
115+
Constructor
116+
"""
117+
118+
self.list = []
119+
120+
def add_obstacle(self, obstacle):
121+
"""
122+
Function to add obstacle object into list
123+
obstacle: Obstacle class's object
124+
"""
125+
126+
self.list.append(obstacle)
127+
128+
def update(self, times_s):
129+
"""
130+
Function to update each obstacle's state in list
131+
time_s: Time interval value[sec]
132+
"""
133+
134+
for obst in self.list: obst.update(times_s)
135+
136+
def draw(self, axes, elems):
137+
"""
138+
Function to draw each obstacles in list
139+
axes: Axes object of figure
140+
elems: List of plot objects
141+
"""
142+
143+
for obst in self.list: obst.draw(axes, elems)
144+
145+
def get_list(self):
146+
"""
147+
Function to get obstacle's list
148+
"""
149+
150+
return self.list
151+
```
152+
153+
This class has a list to store each obstacle objects as a member. Each obstacles can be stored by using a method, add_obstacle. The data of the obstacles can be updated and drawn sequencially by using update and draw methods. Finally, get_list method is implemented to get the list for a sensor model object.

0 commit comments

Comments
 (0)