Skip to content

Commit

Permalink
add section of vehicle visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiye Shizhi committed Jan 16, 2025
1 parent d341fc3 commit e6d6d79
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion doc/2_vehicle_model/2_vehicle_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,4 +861,73 @@ if __name__ == "__main__":
```

You can see the following animation by executing this program.
![](/doc/2_vehicle_model/visualize_vehicle.gif)
![](/doc/2_vehicle_model/visualize_vehicle.gif)

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

```python
"""
visualize_vehicle_zoom.py
Author: Shisato Yano
"""

# import path setting
import numpy as np
import sys
from pathlib import Path

abs_dir_path = str(Path(__file__).absolute().parent)
relative_path = "/../../src/components/"

sys.path.append(abs_dir_path + relative_path + "visualization")
sys.path.append(abs_dir_path + relative_path + "state")
sys.path.append(abs_dir_path + relative_path + "vehicle")


# import component modules
from global_xy_visualizer import GlobalXYVisualizer
from min_max import MinMax
from time_parameters import TimeParameters
from vehicle_specification import VehicleSpecification
from state import State
from four_wheels_vehicle import FourWheelsVehicle


# flag to show plot figure
# when executed as unit test, this flag is set as false
show_plot = True


def main():
"""
Main process function
"""

# set simulation parameters
x_lim, y_lim = MinMax(-30, 30), MinMax(-30, 30)
vis = GlobalXYVisualizer(x_lim, y_lim, TimeParameters(span_sec=20))

# create vehicle
spec = VehicleSpecification() # specification
vehicle = FourWheelsVehicle(State(), spec) # set state and spec

# add objects here
vis.add_object(vehicle)

# plot figure is not shown when executed as unit test
if not show_plot: vis.not_show_plot()

# show plot figure
vis.draw()


# execute main process
if __name__ == "__main__":
main()
```

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

0 comments on commit e6d6d79

Please sign in to comment.