Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions doc/1_world_visualization/1_world_visualization.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 1. World Visualization
In this chapter, I'm gonna explain about a program to define a world coordinate as an environment where a vehicle can move. The program can display a x-y world coordinates and manage each objects which exist on the world.
In this chapter, I'm going to explain a program to define a world coordinate as an environment where a vehicle can move. The program can display x-y world coordinates and manage each object that exists in the world.

## 1.1 Visualization class
All classes for world visualization is located at a directory, "src/components/visualization". Firstly, I'm gonna introduce a global x-y coordinate visualization class as follow.
All classes for world visualization are located in a directory, `src/components/visualization`. Firstly, I'm going to introduce a global x-y coordinate visualization class as follows.
[global_xy_visualizer.py](/src/components/visualization/global_xy_visualizer.py)
```python
"""
Expand Down Expand Up @@ -40,10 +40,10 @@ class GlobalXYVisualizer:
self.show_plot = True
self.show_zoom = show_zoom
```
This class need to import matplotlib.pyplot and animation to display data plots and an animation. In "__init__" method, an empty "objects" list is defined. Each objects which are located in the world are stored into this list.
This class needs to import `matplotlib.pyplot` and `animation` to display data plots and an animation. In `__init__` method, an empty `objects` list is defined. Objects that are located in the world are stored in this list.

### 1.1.1 MinMax class
"x_lim" and "y_lim" are objects of MinMax class. This class defines limitation of x/y axis. These objects are used to set a size of world visualization.
`x_lim` and `y_lim` are objects of `MinMax` class. This class defines the limits of the x/y axes. These objects are used to set the size of the world visualization.
[min_max.py](/src/components/visualization/min_max.py)
```python
"""
Expand Down Expand Up @@ -83,7 +83,7 @@ class MinMax:
```

### 1.1.2 TimeParameters class
"time_params" is an object of TimeParameters class to manage the visualization time.
`time_params` is an object of `TimeParameters` class to manage the visualization time.
[time_parameters.py](/src/components/visualization/time_parameters.py)
```python
"""
Expand Down Expand Up @@ -141,10 +141,10 @@ class TimeParameters:
```

### 1.1.3 Other member variables
"gif_name" is a string object for saving the animation's gif file. A boolean, "show_plot" is used to switch displaying or not displaying the visualization's figure window when unit test is executed. While the test is running, the figure window should not be displayed to continue the test. "show_zoom" is deciding to limit the size of visualization area until around of the vehicle or the maximum size of world.
`gif_name` is a string object for saving the animation's gif file. The boolean `show_plot` is used to toggle whether the visualization's figure window is displayed when a unit test is executed. While the test is running, the figure window should not be displayed to continue the test. `show_zoom` determines whether to limit the visualization area to the vicinity of the vehicle or to show the full world.

### 1.1.4 Member methods
A member method, "add_object()" is defined to add each objects which is located in the world. An object can be added to the objects list by calling this method.
The member method `add_object()` is defined to add objects that are located in the world. An object can be added to the `objects` list by calling this method.
```python
def add_object(self, obj):
"""
Expand All @@ -155,7 +155,7 @@ A member method, "add_object()" is defined to add each objects which is located
self.objects.append(obj)
```

A member method, "not_show_plot()" is defined not to display the figure window of the visualization. This method can be used when the unit test is executed.
A member method, `not_show_plot()` is defined to prevent the figure window from being displayed of the visualization. This method can be used when the unit test is executed.
```python
def not_show_plot(self):
"""
Expand All @@ -166,7 +166,7 @@ A member method, "not_show_plot()" is defined not to display the figure window o
self.show_plot = False
```

This member method, "update" is used to update each objects's data and draw the animation in the list periodically. For this process, each objects in the list must have "update" method and "draw" method.
The member method `update` is used to periodically update each object's data and draw the animation. For this process, each object in the list must have an `update` method and a `draw` method.
```python
def update(self, i, elems, axes):
"""
Expand Down Expand Up @@ -194,7 +194,7 @@ This member method, "update" is used to update each objects's data and draw the
axes.set_ylim(self.y_lim.min_value(), self.y_lim.max_value())
```

Finally, this "draw" method is defined to execute simulation including updating and visualization. If a specific name of gif file is set to "gif_name", the simulation's gif file will be created and saved instead of visualization.
Finally, this `draw` method is defined to execute simulation including updating and visualization. If a specific GIF filename is assigned to `gif_name`, the simulation will be saved as a GIF file instead of being displayed.
```python
def draw(self):
"""
Expand Down Expand Up @@ -231,7 +231,7 @@ Finally, this "draw" method is defined to execute simulation including updating
```

## 1.2 Visualize empty world
I prepared for [a sample progoram to visualize an empty world](/doc/1_world_visualization/visualize_world.py).
I have prepared [a sample program to visualize an empty world](/doc/1_world_visualization/visualize_world.py).
```python
"""
visualize_world.py
Expand Down Expand Up @@ -283,5 +283,5 @@ def main():
if __name__ == "__main__":
main()
```
You will be able to understand how to use the above world visualization class by reading the code. By executing this, you can see that an empty world simulation is visualized as follow.
You will be able to understand how to use the above world visualization class by reading the code. By executing this, you can see that an empty world simulation is visualized as follows.
![](/doc/1_world_visualization/visualize_world.gif)
Loading