ir-sim 2.3.0__tar.gz → 2.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ir_sim-2.3.0 → ir_sim-2.3.2}/PKG-INFO +29 -58
- ir_sim-2.3.2/README.md +127 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/ir_sim.egg-info/PKG-INFO +29 -58
- {ir_sim-2.3.0 → ir_sim-2.3.2}/ir_sim.egg-info/SOURCES.txt +6 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/env/env_base.py +10 -7
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/env/env_plot.py +23 -8
- ir_sim-2.3.2/irsim/env/env_plot3d.py +125 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/algorithm/generation.py +2 -2
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/algorithm/kinematics.py +49 -11
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/behavior/behavior.py +19 -5
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/behavior/behavior_methods.py +9 -7
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/handler/geometry_handler.py +133 -4
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/07render_world/render.py +1 -1
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/12dynamic_obstacle/dynamic_obstacle.yaml +5 -5
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/13custom_behavior/custom_behavior_methods.py +1 -1
- ir_sim-2.3.2/irsim/usage/15fov_world/fov_world.py +15 -0
- ir_sim-2.3.2/irsim/usage/15fov_world/fov_world.yaml +38 -0
- ir_sim-2.3.2/irsim/usage/16noise_world/noise_world.py +10 -0
- ir_sim-2.3.2/irsim/usage/16noise_world/noise_world.yaml +36 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/util/util.py +17 -11
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/__init__.py +2 -5
- ir_sim-2.3.2/irsim/world/arm_base.py +4 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/object_base.py +236 -48
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/object_base_3d.py +2 -1
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/object_factory.py +4 -1
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/obstacles/obstacle_static.py +5 -1
- ir_sim-2.3.2/irsim/world/robots/robot_arm.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/robots/robot_diff.py +1 -1
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/sensors/lidar2d.py +0 -1
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/world.py +4 -2
- {ir_sim-2.3.0 → ir_sim-2.3.2}/pyproject.toml +1 -1
- {ir_sim-2.3.0 → ir_sim-2.3.2}/tests/test_all_objects.py +11 -0
- ir_sim-2.3.0/README.md +0 -156
- ir_sim-2.3.0/irsim/env/env_plot3d.py +0 -34
- {ir_sim-2.3.0 → ir_sim-2.3.2}/LICENSE +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/ir_sim.egg-info/dependency_links.txt +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/ir_sim.egg-info/requires.txt +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/ir_sim.egg-info/top_level.txt +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/__init__.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/env/__init__.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/env/env_base3d.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/env/env_config.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/env/env_logger.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/global_param/env_param.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/global_param/path_param.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/global_param/world_param.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/__init__.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/algorithm/rvo.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/behavior/behavior_registry.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/lib/handler/kinematics_handler.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/01empty_world/empty_world.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/01empty_world/empty_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/02robot_world/car_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/02robot_world/robot_omni_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/02robot_world/robot_polygon_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/02robot_world/robot_world.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/02robot_world/robot_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/03obstacle_world/obstacle_world.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/03obstacle_world/obstacle_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/04collision_world/collision_world.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/04collision_world/collision_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/05lidar_world/lidar_world.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/05lidar_world/lidar_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/05lidar_world/lidar_world_noise.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/06multi_objects_world/multi_objects_world.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/06multi_objects_world/multi_objects_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/07render_world/render.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/07render_world/render_save_figure.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/08random_obstacle/random_obstacle.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/08random_obstacle/random_obstacle.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/09keyboard_control/keyboard_control.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/09keyboard_control/keyboard_control.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/10grid_map/cave.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/10grid_map/grid_map.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/10grid_map/grid_map.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/11collision_avoidance/collision_avoidance.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/11collision_avoidance/collision_avoidance.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/12dynamic_obstacle/dynamic_obstacle.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/13custom_behavior/custom_behavior.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/13custom_behavior/custom_behavior.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/14world_3d_plot/car_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/14world_3d_plot/robot_omni_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/14world_3d_plot/robot_polygon_world.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/14world_3d_plot/robot_world_3d.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/usage/14world_3d_plot/robot_world_3d.yaml +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/version.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/description/car_blue.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/description/car_green.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/description/car_red.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/description/diff_robot0.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/description/diff_robot1.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/map/cave.png +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/map/obstacle_map.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/obstacles/obstacle_acker.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/obstacles/obstacle_diff.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/obstacles/obstacle_omni.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/robots/robot_acker.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/robots/robot_omni.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/robots/robot_rigid3d.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/sensors/sensor_factory.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/irsim/world/world3d.py +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/setup.cfg +0 -0
- {ir_sim-2.3.0 → ir_sim-2.3.2}/tests/test_all_objects_3d.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: ir-sim
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: Open-source, lightweight robot 2D simulator based on Python, specifically designed for intelligent robotics navigation and learning.
|
|
5
5
|
Author-email: Han Ruihua <hanrh@connect.hku.hk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/hanruihua/ir-sim
|
|
@@ -39,19 +39,26 @@ Requires-Dist: pynput; extra == "all"
|
|
|
39
39
|
|
|
40
40
|
</div>
|
|
41
41
|
|
|
42
|
-
Documentation
|
|
42
|
+
**Documentation:** [https://ir-sim.readthedocs.io/en](https://ir-sim.readthedocs.io/en/latest/)
|
|
43
43
|
|
|
44
44
|
IR-SIM is an open-source, lightweight robot simulator based on Python, specifically designed for intelligent robotics navigation and learning. Primarily intended for research and educational purposes, it is user-friendly and easily customizable.
|
|
45
45
|
|
|
46
46
|
It provides the following features:
|
|
47
|
-
- A versatile and easy-to-use framework for simulating a variety of robot platforms with kinematics and sensors.
|
|
48
|
-
- Customizable configurations and parameters using yaml files.
|
|
49
|
-
- Real-time visualization of simulation outcomes.
|
|
50
|
-
- Ideal for developing and testing algorithms related to robot navigation, motion planning, reinforcement learning.
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
- **Versatile and User-Friendly Framework:** Simulate a wide range of robot platforms with diverse kinematics and sensors.
|
|
49
|
+
- **Easy Configuration with YAML:** Easily set up and modify simulation scenarios using straightforward YAML files, no complex coding required for quick and flexible environment customization.
|
|
50
|
+
- **Real-Time Visualization:** Visualize simulation outcomes in real time for immediate feedback and analysis.
|
|
51
|
+
- **Predefined Benchmark Behaviors:** Utilize a comprehensive library of pre-defined behaviors that serve as benchmarks for evaluating and comparing algorithm performance.
|
|
52
|
+
- **Ideal for Algorithm Development:** Suitable for developing and testing algorithms related to robot navigation, motion planning, optimal control, and reinforcement learning.
|
|
53
|
+
|
|
54
|
+
| Scenarios | Description |
|
|
55
|
+
| :--------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
56
|
+
| <img src="https://github.com/user-attachments/assets/5930b088-d400-4943-8ded-853c22eae75b" alt="drawing" width="280"/> | In scenarios involving multiple circular differential robots, each robot employs Reciprocal Velocity Obstacle (RVO) behavior to avoid collisions. |
|
|
57
|
+
| <img src="https://github.com/user-attachments/assets/3257abc1-8bed-40d8-9b51-e5d90b06ee06" alt="drawing" width="280"/> | A car-like robot controlled via keyboard navigates a binary map using a 2D LiDAR sensor to detect obstacles. |
|
|
58
|
+
| <img src="https://github.com/user-attachments/assets/7aa809c2-3a44-4377-a22d-728b9dbdf8bc" alt="drawing" width="280"/> | Each robot employing RVO behavior is equipped with a field of view (FOV) to detect other robots within this area. |
|
|
59
|
+
| <img src="https://github.com/user-attachments/assets/1cc8a4a6-2f41-4bc9-bc59-a7faff443223" alt="drawing" width="280"/> | A car-like robot navigates through the randomly generated and moving obstacles |
|
|
60
|
+
|
|
61
|
+
|
|
55
62
|
|
|
56
63
|
## Prerequisite
|
|
57
64
|
|
|
@@ -65,6 +72,16 @@ It provides the following features:
|
|
|
65
72
|
pip install ir-sim
|
|
66
73
|
```
|
|
67
74
|
|
|
75
|
+
This does not include dependencies for all features of the simulator. To install additional optional dependencies, use the following pip commands:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
# install dependencies for keyboard control
|
|
79
|
+
pip install ir-sim[keyboard]
|
|
80
|
+
|
|
81
|
+
# install all optional dependencies
|
|
82
|
+
pip install ir-sim[all]
|
|
83
|
+
```
|
|
84
|
+
|
|
68
85
|
- Or for development, you may install from source:
|
|
69
86
|
|
|
70
87
|
```
|
|
@@ -118,54 +135,8 @@ robot:
|
|
|
118
135
|
|
|
119
136
|
The advanced usages are listed in the [irsim/usage](https://github.com/hanruihua/ir-sim/tree/main/irsim/usage)
|
|
120
137
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```yaml
|
|
125
|
-
|
|
126
|
-
world:
|
|
127
|
-
height: 10
|
|
128
|
-
width: 10
|
|
129
|
-
step_time: 0.1
|
|
130
|
-
sample_time: 0.1
|
|
131
|
-
offset: [0, 0]
|
|
132
|
-
collision_mode: 'stop' # 'stop', 'unobstructed', 'reactive'
|
|
133
|
-
control_mode: 'auto' # 'auto', 'keyboard'
|
|
134
|
-
|
|
135
|
-
robot:
|
|
136
|
-
- number: 10
|
|
137
|
-
distribution: {name: 'circle', radius: 4.0, center: [5, 5]} # name: 'circle', 'random',
|
|
138
|
-
kinematics: {name: 'diff'} # name: 'diff', 'omni', acker
|
|
139
|
-
shape:
|
|
140
|
-
- {name: 'circle', radius: 0.2} # name: 'circle', 'rectangle'
|
|
141
|
-
behavior: {name: 'rvo', vxmax: 1.3, vymax: 1.3, accer: 1.0, factor: 0.5} # name:
|
|
142
|
-
vel_min: [-2, -2.0]
|
|
143
|
-
vel_max: [2, 2.0]
|
|
144
|
-
color: ['royalblue', 'red', 'green', 'orange', 'purple', 'yellow', 'cyan', 'magenta', 'lime', 'pink', 'brown']
|
|
145
|
-
arrive_mode: position # position, state
|
|
146
|
-
goal_threshold: 0.15
|
|
147
|
-
plot:
|
|
148
|
-
show_trail: true
|
|
149
|
-
show_goal: true
|
|
150
|
-
trail_fill: True
|
|
151
|
-
trail_alpha: 0.2
|
|
152
|
-
|
|
153
|
-
obstacle:
|
|
154
|
-
- shape: {name: 'circle', radius: 1.0}
|
|
155
|
-
state: [5, 5, 0]
|
|
156
|
-
|
|
157
|
-
- number: 10
|
|
158
|
-
distribution: {name: 'manual'}
|
|
159
|
-
shape:
|
|
160
|
-
- {name: 'polygon', random_shape: true, center_range: [5, 10, 40, 30], avg_radius_range: [0.5, 2], irregularity_range: [0, 1], spikeyness_range: [0, 1], num_vertices_range: [4, 5]}
|
|
161
|
-
|
|
162
|
-
- shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] }
|
|
163
|
-
state: [0, 0, 0]
|
|
164
|
-
|
|
165
|
-
``` -->
|
|
166
|
-
|
|
167
|
-
## Cases
|
|
168
|
-
- [rl-rvo-nav](https://github.com/hanruihua/rl_rvo_nav)(RAL & ICRA2023)
|
|
138
|
+
## Academic Cases
|
|
139
|
+
- [rl-rvo-nav](https://github.com/hanruihua/rl_rvo_nav) (RAL & ICRA2023)
|
|
169
140
|
- [RDA_planner](https://github.com/hanruihua/RDA_planner)(RAL & IROS2023)
|
|
170
141
|
|
|
171
142
|
|
ir_sim-2.3.2/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<!-- <div align="center">
|
|
2
|
+
<img src="doc/image/ir-sim_logos/logo1_nobg.png" width = "200" >
|
|
3
|
+
</div> -->
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<div align="center">
|
|
7
|
+
|
|
8
|
+
# Intelligent Robot Simulator (IR-SIM)
|
|
9
|
+
|
|
10
|
+
<a href="https://pypi.org/project/ir-sim/"><img src='https://img.shields.io/pypi/v/ir-sim?color=orange' alt='Github Release'></a>
|
|
11
|
+
<a href="https://github.com/hanruihua/ir-sim?tab=MIT-1-ov-file"><img src='https://img.shields.io/badge/License-MIT-blue' alt='License'></a>
|
|
12
|
+
<a href="https://pepy.tech/project/ir-sim"><img src="https://img.shields.io/pepy/dt/ir-sim" alt="PyPI Downloads"></a>
|
|
13
|
+
<a href="https://codecov.io/gh/hanruihua/ir-sim" > <img src="https://codecov.io/gh/hanruihua/ir-sim/branch/dev/graph/badge.svg?token=OSC8I5QCQ0"/> </a>
|
|
14
|
+
<a href="https://ir-sim.readthedocs.io/en/latest/"> <img alt="Read the Docs" src="https://img.shields.io/readthedocs/ir-sim"/> </a>
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
**Documentation:** [https://ir-sim.readthedocs.io/en](https://ir-sim.readthedocs.io/en/latest/)
|
|
19
|
+
|
|
20
|
+
IR-SIM is an open-source, lightweight robot simulator based on Python, specifically designed for intelligent robotics navigation and learning. Primarily intended for research and educational purposes, it is user-friendly and easily customizable.
|
|
21
|
+
|
|
22
|
+
It provides the following features:
|
|
23
|
+
|
|
24
|
+
- **Versatile and User-Friendly Framework:** Simulate a wide range of robot platforms with diverse kinematics and sensors.
|
|
25
|
+
- **Easy Configuration with YAML:** Easily set up and modify simulation scenarios using straightforward YAML files, no complex coding required for quick and flexible environment customization.
|
|
26
|
+
- **Real-Time Visualization:** Visualize simulation outcomes in real time for immediate feedback and analysis.
|
|
27
|
+
- **Predefined Benchmark Behaviors:** Utilize a comprehensive library of pre-defined behaviors that serve as benchmarks for evaluating and comparing algorithm performance.
|
|
28
|
+
- **Ideal for Algorithm Development:** Suitable for developing and testing algorithms related to robot navigation, motion planning, optimal control, and reinforcement learning.
|
|
29
|
+
|
|
30
|
+
| Scenarios | Description |
|
|
31
|
+
| :--------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
32
|
+
| <img src="https://github.com/user-attachments/assets/5930b088-d400-4943-8ded-853c22eae75b" alt="drawing" width="280"/> | In scenarios involving multiple circular differential robots, each robot employs Reciprocal Velocity Obstacle (RVO) behavior to avoid collisions. |
|
|
33
|
+
| <img src="https://github.com/user-attachments/assets/3257abc1-8bed-40d8-9b51-e5d90b06ee06" alt="drawing" width="280"/> | A car-like robot controlled via keyboard navigates a binary map using a 2D LiDAR sensor to detect obstacles. |
|
|
34
|
+
| <img src="https://github.com/user-attachments/assets/7aa809c2-3a44-4377-a22d-728b9dbdf8bc" alt="drawing" width="280"/> | Each robot employing RVO behavior is equipped with a field of view (FOV) to detect other robots within this area. |
|
|
35
|
+
| <img src="https://github.com/user-attachments/assets/1cc8a4a6-2f41-4bc9-bc59-a7faff443223" alt="drawing" width="280"/> | A car-like robot navigates through the randomly generated and moving obstacles |
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Prerequisite
|
|
40
|
+
|
|
41
|
+
- Python: >= 3.7
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
- Install this package from PyPi:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
pip install ir-sim
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This does not include dependencies for all features of the simulator. To install additional optional dependencies, use the following pip commands:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
# install dependencies for keyboard control
|
|
55
|
+
pip install ir-sim[keyboard]
|
|
56
|
+
|
|
57
|
+
# install all optional dependencies
|
|
58
|
+
pip install ir-sim[all]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- Or for development, you may install from source:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
git clone https://github.com/hanruihua/ir-sim.git
|
|
65
|
+
cd ir-sim
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
### Quick Start
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
|
|
75
|
+
import irsim
|
|
76
|
+
|
|
77
|
+
env = irsim.make('robot_world.yaml') # initialize the environment with the configuration file
|
|
78
|
+
|
|
79
|
+
for i in range(300): # run the simulation for 300 steps
|
|
80
|
+
|
|
81
|
+
env.step() # update the environment
|
|
82
|
+
env.render() # render the environment
|
|
83
|
+
|
|
84
|
+
if env.done(): break # check if the simulation is done
|
|
85
|
+
|
|
86
|
+
env.end() # close the environment
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
YAML Configuration: robot_world.yaml
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
|
|
93
|
+
world:
|
|
94
|
+
height: 10 # the height of the world
|
|
95
|
+
width: 10 # the height of the world
|
|
96
|
+
step_time: 0.1 # 10Hz calculate each step
|
|
97
|
+
sample_time: 0.1 # 10 Hz for render and data extraction
|
|
98
|
+
offset: [0, 0] # the offset of the world on x and y
|
|
99
|
+
|
|
100
|
+
robot:
|
|
101
|
+
kinematics: {name: 'diff'} # omni, diff, acker
|
|
102
|
+
shape: {name: 'circle', radius: 0.2} # radius
|
|
103
|
+
state: [1, 1, 0] # x, y, theta
|
|
104
|
+
goal: [9, 9, 0] # x, y, theta
|
|
105
|
+
behavior: {name: 'dash'} # move toward to the goal directly
|
|
106
|
+
color: 'g' # green
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### Advanced Usage
|
|
111
|
+
|
|
112
|
+
The advanced usages are listed in the [irsim/usage](https://github.com/hanruihua/ir-sim/tree/main/irsim/usage)
|
|
113
|
+
|
|
114
|
+
## Academic Cases
|
|
115
|
+
- [rl-rvo-nav](https://github.com/hanruihua/rl_rvo_nav) (RAL & ICRA2023)
|
|
116
|
+
- [RDA_planner](https://github.com/hanruihua/RDA_planner)(RAL & IROS2023)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## Acknowledgement
|
|
120
|
+
|
|
121
|
+
- [PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: ir-sim
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: Open-source, lightweight robot 2D simulator based on Python, specifically designed for intelligent robotics navigation and learning.
|
|
5
5
|
Author-email: Han Ruihua <hanrh@connect.hku.hk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/hanruihua/ir-sim
|
|
@@ -39,19 +39,26 @@ Requires-Dist: pynput; extra == "all"
|
|
|
39
39
|
|
|
40
40
|
</div>
|
|
41
41
|
|
|
42
|
-
Documentation
|
|
42
|
+
**Documentation:** [https://ir-sim.readthedocs.io/en](https://ir-sim.readthedocs.io/en/latest/)
|
|
43
43
|
|
|
44
44
|
IR-SIM is an open-source, lightweight robot simulator based on Python, specifically designed for intelligent robotics navigation and learning. Primarily intended for research and educational purposes, it is user-friendly and easily customizable.
|
|
45
45
|
|
|
46
46
|
It provides the following features:
|
|
47
|
-
- A versatile and easy-to-use framework for simulating a variety of robot platforms with kinematics and sensors.
|
|
48
|
-
- Customizable configurations and parameters using yaml files.
|
|
49
|
-
- Real-time visualization of simulation outcomes.
|
|
50
|
-
- Ideal for developing and testing algorithms related to robot navigation, motion planning, reinforcement learning.
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
- **Versatile and User-Friendly Framework:** Simulate a wide range of robot platforms with diverse kinematics and sensors.
|
|
49
|
+
- **Easy Configuration with YAML:** Easily set up and modify simulation scenarios using straightforward YAML files, no complex coding required for quick and flexible environment customization.
|
|
50
|
+
- **Real-Time Visualization:** Visualize simulation outcomes in real time for immediate feedback and analysis.
|
|
51
|
+
- **Predefined Benchmark Behaviors:** Utilize a comprehensive library of pre-defined behaviors that serve as benchmarks for evaluating and comparing algorithm performance.
|
|
52
|
+
- **Ideal for Algorithm Development:** Suitable for developing and testing algorithms related to robot navigation, motion planning, optimal control, and reinforcement learning.
|
|
53
|
+
|
|
54
|
+
| Scenarios | Description |
|
|
55
|
+
| :--------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
56
|
+
| <img src="https://github.com/user-attachments/assets/5930b088-d400-4943-8ded-853c22eae75b" alt="drawing" width="280"/> | In scenarios involving multiple circular differential robots, each robot employs Reciprocal Velocity Obstacle (RVO) behavior to avoid collisions. |
|
|
57
|
+
| <img src="https://github.com/user-attachments/assets/3257abc1-8bed-40d8-9b51-e5d90b06ee06" alt="drawing" width="280"/> | A car-like robot controlled via keyboard navigates a binary map using a 2D LiDAR sensor to detect obstacles. |
|
|
58
|
+
| <img src="https://github.com/user-attachments/assets/7aa809c2-3a44-4377-a22d-728b9dbdf8bc" alt="drawing" width="280"/> | Each robot employing RVO behavior is equipped with a field of view (FOV) to detect other robots within this area. |
|
|
59
|
+
| <img src="https://github.com/user-attachments/assets/1cc8a4a6-2f41-4bc9-bc59-a7faff443223" alt="drawing" width="280"/> | A car-like robot navigates through the randomly generated and moving obstacles |
|
|
60
|
+
|
|
61
|
+
|
|
55
62
|
|
|
56
63
|
## Prerequisite
|
|
57
64
|
|
|
@@ -65,6 +72,16 @@ It provides the following features:
|
|
|
65
72
|
pip install ir-sim
|
|
66
73
|
```
|
|
67
74
|
|
|
75
|
+
This does not include dependencies for all features of the simulator. To install additional optional dependencies, use the following pip commands:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
# install dependencies for keyboard control
|
|
79
|
+
pip install ir-sim[keyboard]
|
|
80
|
+
|
|
81
|
+
# install all optional dependencies
|
|
82
|
+
pip install ir-sim[all]
|
|
83
|
+
```
|
|
84
|
+
|
|
68
85
|
- Or for development, you may install from source:
|
|
69
86
|
|
|
70
87
|
```
|
|
@@ -118,54 +135,8 @@ robot:
|
|
|
118
135
|
|
|
119
136
|
The advanced usages are listed in the [irsim/usage](https://github.com/hanruihua/ir-sim/tree/main/irsim/usage)
|
|
120
137
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```yaml
|
|
125
|
-
|
|
126
|
-
world:
|
|
127
|
-
height: 10
|
|
128
|
-
width: 10
|
|
129
|
-
step_time: 0.1
|
|
130
|
-
sample_time: 0.1
|
|
131
|
-
offset: [0, 0]
|
|
132
|
-
collision_mode: 'stop' # 'stop', 'unobstructed', 'reactive'
|
|
133
|
-
control_mode: 'auto' # 'auto', 'keyboard'
|
|
134
|
-
|
|
135
|
-
robot:
|
|
136
|
-
- number: 10
|
|
137
|
-
distribution: {name: 'circle', radius: 4.0, center: [5, 5]} # name: 'circle', 'random',
|
|
138
|
-
kinematics: {name: 'diff'} # name: 'diff', 'omni', acker
|
|
139
|
-
shape:
|
|
140
|
-
- {name: 'circle', radius: 0.2} # name: 'circle', 'rectangle'
|
|
141
|
-
behavior: {name: 'rvo', vxmax: 1.3, vymax: 1.3, accer: 1.0, factor: 0.5} # name:
|
|
142
|
-
vel_min: [-2, -2.0]
|
|
143
|
-
vel_max: [2, 2.0]
|
|
144
|
-
color: ['royalblue', 'red', 'green', 'orange', 'purple', 'yellow', 'cyan', 'magenta', 'lime', 'pink', 'brown']
|
|
145
|
-
arrive_mode: position # position, state
|
|
146
|
-
goal_threshold: 0.15
|
|
147
|
-
plot:
|
|
148
|
-
show_trail: true
|
|
149
|
-
show_goal: true
|
|
150
|
-
trail_fill: True
|
|
151
|
-
trail_alpha: 0.2
|
|
152
|
-
|
|
153
|
-
obstacle:
|
|
154
|
-
- shape: {name: 'circle', radius: 1.0}
|
|
155
|
-
state: [5, 5, 0]
|
|
156
|
-
|
|
157
|
-
- number: 10
|
|
158
|
-
distribution: {name: 'manual'}
|
|
159
|
-
shape:
|
|
160
|
-
- {name: 'polygon', random_shape: true, center_range: [5, 10, 40, 30], avg_radius_range: [0.5, 2], irregularity_range: [0, 1], spikeyness_range: [0, 1], num_vertices_range: [4, 5]}
|
|
161
|
-
|
|
162
|
-
- shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] }
|
|
163
|
-
state: [0, 0, 0]
|
|
164
|
-
|
|
165
|
-
``` -->
|
|
166
|
-
|
|
167
|
-
## Cases
|
|
168
|
-
- [rl-rvo-nav](https://github.com/hanruihua/rl_rvo_nav)(RAL & ICRA2023)
|
|
138
|
+
## Academic Cases
|
|
139
|
+
- [rl-rvo-nav](https://github.com/hanruihua/rl_rvo_nav) (RAL & ICRA2023)
|
|
169
140
|
- [RDA_planner](https://github.com/hanruihua/RDA_planner)(RAL & IROS2023)
|
|
170
141
|
|
|
171
142
|
|
|
@@ -65,8 +65,13 @@ irsim/usage/14world_3d_plot/robot_omni_world.yaml
|
|
|
65
65
|
irsim/usage/14world_3d_plot/robot_polygon_world.yaml
|
|
66
66
|
irsim/usage/14world_3d_plot/robot_world_3d.py
|
|
67
67
|
irsim/usage/14world_3d_plot/robot_world_3d.yaml
|
|
68
|
+
irsim/usage/15fov_world/fov_world.py
|
|
69
|
+
irsim/usage/15fov_world/fov_world.yaml
|
|
70
|
+
irsim/usage/16noise_world/noise_world.py
|
|
71
|
+
irsim/usage/16noise_world/noise_world.yaml
|
|
68
72
|
irsim/util/util.py
|
|
69
73
|
irsim/world/__init__.py
|
|
74
|
+
irsim/world/arm_base.py
|
|
70
75
|
irsim/world/object_base.py
|
|
71
76
|
irsim/world/object_base_3d.py
|
|
72
77
|
irsim/world/object_factory.py
|
|
@@ -84,6 +89,7 @@ irsim/world/obstacles/obstacle_diff.py
|
|
|
84
89
|
irsim/world/obstacles/obstacle_omni.py
|
|
85
90
|
irsim/world/obstacles/obstacle_static.py
|
|
86
91
|
irsim/world/robots/robot_acker.py
|
|
92
|
+
irsim/world/robots/robot_arm.py
|
|
87
93
|
irsim/world/robots/robot_diff.py
|
|
88
94
|
irsim/world/robots/robot_omni.py
|
|
89
95
|
irsim/world/robots/robot_rigid3d.py
|
|
@@ -25,10 +25,12 @@ from tabulate import tabulate
|
|
|
25
25
|
|
|
26
26
|
try:
|
|
27
27
|
from pynput import keyboard
|
|
28
|
+
|
|
28
29
|
keyboard_module = True
|
|
29
30
|
except ImportError:
|
|
30
31
|
keyboard_module = False
|
|
31
32
|
|
|
33
|
+
|
|
32
34
|
class EnvBase:
|
|
33
35
|
"""
|
|
34
36
|
The base class of environment. This class will read the yaml file and create the world, robot, obstacle, and map objects.
|
|
@@ -118,7 +120,7 @@ class EnvBase:
|
|
|
118
120
|
def __str__(self):
|
|
119
121
|
return f"Environment: {self._world.name}"
|
|
120
122
|
|
|
121
|
-
def step(self, action=None, action_id=0):
|
|
123
|
+
def step(self, action: Optional[np.ndarray] = None, action_id=0):
|
|
122
124
|
"""
|
|
123
125
|
Perform a simulation step in the environment.
|
|
124
126
|
|
|
@@ -142,16 +144,16 @@ class EnvBase:
|
|
|
142
144
|
|
|
143
145
|
self._world.step()
|
|
144
146
|
|
|
145
|
-
def _objects_step(self, action=None):
|
|
147
|
+
def _objects_step(self, action: Optional[list] =None):
|
|
146
148
|
action = action + [None] * (len(self.objects) - len(action))
|
|
147
149
|
[obj.step(action) for obj, action in zip(self.objects, action)]
|
|
148
150
|
|
|
149
|
-
def _object_step(self, action, obj_id=0):
|
|
151
|
+
def _object_step(self, action: np.ndarray, obj_id: int = 0):
|
|
150
152
|
self.objects[obj_id].step(action)
|
|
151
153
|
[obj.step() for obj in self.objects if obj._id != obj_id]
|
|
152
154
|
|
|
153
155
|
# render
|
|
154
|
-
def render(self, interval=0.05, figure_kwargs=dict(), **kwargs):
|
|
156
|
+
def render(self, interval: float =0.05, figure_kwargs=dict(), **kwargs):
|
|
155
157
|
"""
|
|
156
158
|
Render the environment.
|
|
157
159
|
|
|
@@ -199,12 +201,13 @@ class EnvBase:
|
|
|
199
201
|
|
|
200
202
|
Args:
|
|
201
203
|
points (list): List of points (2*1) to be drawn.
|
|
204
|
+
or (np.array): (2, Num) to be drawn.
|
|
202
205
|
s (int): Size of the points.
|
|
203
206
|
c (str): Color of the points.
|
|
204
207
|
refresh (bool): Flag to refresh the points in the figure.
|
|
205
208
|
**kwargs: Additional keyword arguments for drawing the points, see `ax.scatter <https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.scatter.html>`_ function for detail.
|
|
206
209
|
"""
|
|
207
|
-
|
|
210
|
+
|
|
208
211
|
self._env_plot.draw_points(points, s, c, refresh, **kwargs)
|
|
209
212
|
|
|
210
213
|
def draw_box(self, vertex, refresh=True, color="-b"):
|
|
@@ -282,7 +285,7 @@ class EnvBase:
|
|
|
282
285
|
["r", "reset the environment"],
|
|
283
286
|
]
|
|
284
287
|
# headers = ["key", "function"]
|
|
285
|
-
|
|
288
|
+
|
|
286
289
|
headers = ["Key", "Function"]
|
|
287
290
|
# Generate the table using tabulate
|
|
288
291
|
table = tabulate(commands, headers=headers, tablefmt="grid")
|
|
@@ -484,7 +487,7 @@ class EnvBase:
|
|
|
484
487
|
|
|
485
488
|
return self.robot_list[id].get_lidar_offset()
|
|
486
489
|
|
|
487
|
-
def
|
|
490
|
+
def get_obstacle_info_list(self):
|
|
488
491
|
"""
|
|
489
492
|
Get the information of the obstacles in the environment.
|
|
490
493
|
|
|
@@ -39,6 +39,7 @@ class EnvPlot:
|
|
|
39
39
|
saved_ani=dict(),
|
|
40
40
|
dpi: int = 100,
|
|
41
41
|
figure_pixels: list =[1920, 1080],
|
|
42
|
+
|
|
42
43
|
**kwargs,
|
|
43
44
|
) -> None:
|
|
44
45
|
"""
|
|
@@ -205,25 +206,39 @@ class EnvPlot:
|
|
|
205
206
|
if refresh:
|
|
206
207
|
self.dyna_line_list.append(line)
|
|
207
208
|
|
|
208
|
-
def draw_points(self,
|
|
209
|
+
def draw_points(self, points, s=10, c="m", refresh=True, **kwargs):
|
|
209
210
|
"""
|
|
210
211
|
Draw points on the plot.
|
|
211
212
|
|
|
212
213
|
Args:
|
|
213
|
-
|
|
214
|
+
points (list): List of points, each point as [x, y] or (2, 1) array
|
|
215
|
+
or (np.array): points array: (2, N), NL number of points
|
|
214
216
|
s (int): Size of the points.
|
|
215
217
|
c (str): Color of the points.
|
|
216
218
|
refresh (bool): Whether to refresh the plot.
|
|
217
219
|
kwargs: Additional plotting options.
|
|
218
220
|
"""
|
|
219
|
-
if point_list is not None:
|
|
220
|
-
x_coordinates = [point[0] for point in point_list]
|
|
221
|
-
y_coordinates = [point[1] for point in point_list]
|
|
222
221
|
|
|
223
|
-
|
|
222
|
+
if points is None:
|
|
223
|
+
return
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
if isinstance(points, list):
|
|
226
|
+
x_coordinates = [point[0] for point in points]
|
|
227
|
+
y_coordinates = [point[1] for point in points]
|
|
228
|
+
|
|
229
|
+
elif isinstance(points, np.ndarray):
|
|
230
|
+
|
|
231
|
+
if points.shape[1] > 1:
|
|
232
|
+
x_coordinates = [point[0] for point in points.T]
|
|
233
|
+
y_coordinates = [point[1] for point in points.T]
|
|
234
|
+
else:
|
|
235
|
+
x_coordinates = points[0]
|
|
236
|
+
y_coordinates = points[1]
|
|
237
|
+
|
|
238
|
+
points_plot = self.ax.scatter(x_coordinates, y_coordinates, s, c, **kwargs)
|
|
239
|
+
|
|
240
|
+
if refresh:
|
|
241
|
+
self.dyna_point_list.append(points_plot)
|
|
227
242
|
|
|
228
243
|
def draw_box(self, vertices, refresh=False, color="b-"):
|
|
229
244
|
"""
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
from .env_plot import EnvPlot
|
|
2
|
+
import mpl_toolkits.mplot3d.art3d as art3d
|
|
3
|
+
from mpl_toolkits.mplot3d import Axes3D
|
|
4
|
+
import numpy as np
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
from math import cos, sin
|
|
7
|
+
|
|
8
|
+
class EnvPlot3D(EnvPlot):
|
|
9
|
+
|
|
10
|
+
def __init__(
|
|
11
|
+
self,grid_map=None,
|
|
12
|
+
objects=[],
|
|
13
|
+
x_range=[0, 10],
|
|
14
|
+
y_range=[0, 10],
|
|
15
|
+
z_range=[0, 10],
|
|
16
|
+
saved_figure=dict(),
|
|
17
|
+
saved_ani=dict(),
|
|
18
|
+
dpi: int = 100,
|
|
19
|
+
figure_pixels: list =[1920, 1080],
|
|
20
|
+
**kwargs,
|
|
21
|
+
):
|
|
22
|
+
super().__init__(grid_map, objects, x_range, y_range, saved_figure, saved_ani, dpi, figure_pixels, **kwargs)
|
|
23
|
+
|
|
24
|
+
self.clear_components()
|
|
25
|
+
self.ax.remove()
|
|
26
|
+
|
|
27
|
+
self.ax = self.fig.add_subplot(projection='3d')
|
|
28
|
+
self.z_range = z_range
|
|
29
|
+
|
|
30
|
+
self.init_plot(grid_map, objects, **kwargs)
|
|
31
|
+
self.ax.set_zlim(z_range)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def draw_points(self, points, s=10, c="m", refresh=True, **kwargs):
|
|
35
|
+
"""
|
|
36
|
+
Draw points on the plot.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
points (list): List of points, each point as [x, y, z].
|
|
40
|
+
s (int): Size of the points.
|
|
41
|
+
c (str): Color of the points.
|
|
42
|
+
refresh (bool): Whether to refresh the plot.
|
|
43
|
+
kwargs: Additional plotting options.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
if points is None:
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
if isinstance(points, list):
|
|
50
|
+
x_coordinates = [point[0] for point in points]
|
|
51
|
+
y_coordinates = [point[1] for point in points]
|
|
52
|
+
z_coordinates = [point[2] for point in points]
|
|
53
|
+
|
|
54
|
+
elif isinstance(points, np.ndarray):
|
|
55
|
+
|
|
56
|
+
if points.shape[1] > 1:
|
|
57
|
+
x_coordinates = [point[0] for point in points.T]
|
|
58
|
+
y_coordinates = [point[1] for point in points.T]
|
|
59
|
+
z_coordinates = [point[2] for point in points.T]
|
|
60
|
+
else:
|
|
61
|
+
x_coordinates = points[0]
|
|
62
|
+
y_coordinates = points[1]
|
|
63
|
+
z_coordinates = points[2]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
points = self.ax.scatter(x_coordinates, y_coordinates, z_coordinates, 'z', s, c, **kwargs)
|
|
67
|
+
|
|
68
|
+
if refresh:
|
|
69
|
+
self.dyna_point_list.append(points)
|
|
70
|
+
|
|
71
|
+
def draw_trajectory(
|
|
72
|
+
self,
|
|
73
|
+
traj,
|
|
74
|
+
traj_type="g-",
|
|
75
|
+
label="trajectory",
|
|
76
|
+
show_direction=False,
|
|
77
|
+
refresh=False,
|
|
78
|
+
**kwargs,
|
|
79
|
+
):
|
|
80
|
+
"""
|
|
81
|
+
Draw a trajectory on the plot.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
traj (list or np.ndarray): List of points or array of points [x, y, z].
|
|
85
|
+
traj_type (str): Type of trajectory line (e.g., 'g-').
|
|
86
|
+
See https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html for details.
|
|
87
|
+
label (str): Label for the trajectory.
|
|
88
|
+
show_direction (bool): Whether to show the direction of the trajectory.
|
|
89
|
+
refresh (bool): Whether to refresh the plot.
|
|
90
|
+
kwargs: Additional plotting options for ax.plot()
|
|
91
|
+
"""
|
|
92
|
+
if isinstance(traj, list):
|
|
93
|
+
path_x_list = [p[0, 0] for p in traj]
|
|
94
|
+
path_y_list = [p[1, 0] for p in traj]
|
|
95
|
+
path_z_list = [p[2, 0] for p in traj]
|
|
96
|
+
elif isinstance(traj, np.ndarray):
|
|
97
|
+
path_x_list = [p[0] for p in traj.T]
|
|
98
|
+
path_y_list = [p[1] for p in traj.T]
|
|
99
|
+
path_z_list = [p[2] for p in traj.T]
|
|
100
|
+
|
|
101
|
+
line = self.ax.plot(path_x_list, path_y_list, path_z_list, traj_type, label=label, **kwargs)
|
|
102
|
+
|
|
103
|
+
if show_direction:
|
|
104
|
+
print('Not support currently')
|
|
105
|
+
# if isinstance(traj, list):
|
|
106
|
+
# u_list = [cos(p[2, 0]) for p in traj]
|
|
107
|
+
# v_list = [sin(p[2, 0]) for p in traj]
|
|
108
|
+
# elif isinstance(traj, np.ndarray):
|
|
109
|
+
# u_list = [cos(p[2]) for p in traj.T]
|
|
110
|
+
# v_list = [sin(p[2]) for p in traj.T]
|
|
111
|
+
|
|
112
|
+
# if isinstance(self.ax, Axes3D):
|
|
113
|
+
# path_z_list = [0] * len(path_x_list)
|
|
114
|
+
# w_list = [0] * len(u_list)
|
|
115
|
+
|
|
116
|
+
# self.ax.quiver(path_x_list, path_y_list, path_z_list, u_list, v_list, w_list)
|
|
117
|
+
|
|
118
|
+
# else:
|
|
119
|
+
# self.ax.quiver(path_x_list, path_y_list, u_list, v_list)
|
|
120
|
+
|
|
121
|
+
if refresh:
|
|
122
|
+
self.dyna_line_list.append(line)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
@@ -82,7 +82,7 @@ def generate_polygon(center, avg_radius, irregularity, spikeyness, num_vertices)
|
|
|
82
82
|
angle_steps = random_angle_steps(num_vertices, irregularity)
|
|
83
83
|
|
|
84
84
|
points = []
|
|
85
|
-
angle = random.uniform(0, 2 * math.pi)
|
|
85
|
+
angle = np.random.uniform(0, 2 * math.pi)
|
|
86
86
|
for i in range(num_vertices):
|
|
87
87
|
radius = clip(random.gauss(avg_radius, spikeyness), 0, 2 * avg_radius)
|
|
88
88
|
point = (
|
|
@@ -113,7 +113,7 @@ def random_angle_steps(steps: int, irregularity: float) -> List[float]:
|
|
|
113
113
|
upper = (2 * math.pi / steps) + irregularity
|
|
114
114
|
cumsum = 0
|
|
115
115
|
for i in range(steps):
|
|
116
|
-
angle = random.uniform(lower, upper)
|
|
116
|
+
angle = np.random.uniform(lower, upper)
|
|
117
117
|
angles.append(angle)
|
|
118
118
|
cumsum += angle
|
|
119
119
|
|