ir-sim 2.2.4__tar.gz → 2.2.6__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.
Files changed (88) hide show
  1. {ir_sim-2.2.4 → ir_sim-2.2.6}/PKG-INFO +7 -18
  2. {ir_sim-2.2.4 → ir_sim-2.2.6}/README.md +4 -15
  3. {ir_sim-2.2.4 → ir_sim-2.2.6}/ir_sim.egg-info/PKG-INFO +7 -18
  4. {ir_sim-2.2.4 → ir_sim-2.2.6}/ir_sim.egg-info/SOURCES.txt +10 -6
  5. {ir_sim-2.2.4 → ir_sim-2.2.6}/ir_sim.egg-info/requires.txt +1 -1
  6. {ir_sim-2.2.4 → ir_sim-2.2.6}/ir_sim.egg-info/top_level.txt +1 -0
  7. ir_sim-2.2.6/irsim/__init__.py +11 -0
  8. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/env/env_base.py +46 -7
  9. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/env/env_config.py +4 -3
  10. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/env/env_plot.py +61 -10
  11. ir_sim-2.2.6/irsim/lib/behavior.py +81 -0
  12. ir_sim-2.2.4/irsim/lib/behaviorlib.py → ir_sim-2.2.6/irsim/lib/behavior_methods.py +144 -75
  13. ir_sim-2.2.6/irsim/lib/behavior_registry.py +20 -0
  14. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/02robot_world/car_world.yaml +3 -0
  15. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/02robot_world/robot_world.py +2 -2
  16. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/02robot_world/robot_world.yaml +2 -0
  17. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/03obstacle_world/obstacle_world.py +0 -1
  18. ir_sim-2.2.4/irsim/usage/07render_world/render.py → ir_sim-2.2.6/irsim/usage/05lidar_world/lidar_world.py +2 -1
  19. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/05lidar_world/lidar_world.yaml +1 -1
  20. ir_sim-2.2.6/irsim/usage/05lidar_world/lidar_world_noise.yaml +41 -0
  21. ir_sim-2.2.4/irsim/usage/05lidar_world/lidar_world.py → ir_sim-2.2.6/irsim/usage/07render_world/render.py +2 -2
  22. ir_sim-2.2.6/irsim/usage/07render_world/render_save_figure.py +14 -0
  23. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/11collision_avoidance/collision_avoidance.py +1 -1
  24. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/11collision_avoidance/collision_avoidance.yaml +4 -3
  25. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/12dynamic_obstacle/dynamic_obstacle.py +1 -2
  26. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/12dynamic_obstacle/dynamic_obstacle.yaml +4 -1
  27. ir_sim-2.2.6/irsim/usage/13custom_behavior/custom_behavior.py +20 -0
  28. ir_sim-2.2.6/irsim/usage/13custom_behavior/custom_behavior.yaml +67 -0
  29. ir_sim-2.2.6/irsim/usage/13custom_behavior/custom_behavior_methods.py +49 -0
  30. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/util/util.py +14 -1
  31. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/object_base.py +57 -66
  32. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/sensors/lidar2d.py +21 -3
  33. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/world.py +10 -1
  34. {ir_sim-2.2.4 → ir_sim-2.2.6}/pyproject.toml +3 -3
  35. ir_sim-2.2.6/tests/test_all_objects.py +12 -0
  36. ir_sim-2.2.4/irsim/usage/test_all_objects/all_objects.yaml → ir_sim-2.2.6/tests/test_all_objects.yaml +2 -2
  37. ir_sim-2.2.4/doc/animations/image/IR_SIM_logos/logo1.png +0 -0
  38. ir_sim-2.2.4/doc/animations/image/IR_SIM_logos/logo1_nobg.png +0 -0
  39. ir_sim-2.2.4/irsim/__init__.py +0 -6
  40. ir_sim-2.2.4/irsim/lib/behavior.py +0 -98
  41. ir_sim-2.2.4/irsim/usage/test_all_objects/all_objects.py +0 -10
  42. {ir_sim-2.2.4 → ir_sim-2.2.6}/LICENSE +0 -0
  43. {ir_sim-2.2.4 → ir_sim-2.2.6}/doc/source/conf.py +0 -0
  44. {ir_sim-2.2.4 → ir_sim-2.2.6}/ir_sim.egg-info/dependency_links.txt +0 -0
  45. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/env/__init__.py +0 -0
  46. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/env/env_logger.py +0 -0
  47. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/global_param/env_param.py +0 -0
  48. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/global_param/path_param.py +0 -0
  49. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/global_param/world_param.py +0 -0
  50. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/lib/__init__.py +0 -0
  51. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/lib/algorithm/rvo.py +0 -0
  52. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/lib/generation.py +0 -0
  53. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/lib/kinematics.py +0 -0
  54. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/01empty_world/empty_world.py +0 -0
  55. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/01empty_world/empty_world.yaml +0 -0
  56. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/02robot_world/robot_omni_world.yaml +0 -0
  57. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/03obstacle_world/obstacle_world.yaml +0 -0
  58. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/04collision_world/collision_world.py +0 -0
  59. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/04collision_world/collision_world.yaml +0 -0
  60. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/06multi_objects_world/multi_objects_world.py +0 -0
  61. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/06multi_objects_world/multi_objects_world.yaml +0 -0
  62. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/07render_world/render.yaml +0 -0
  63. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/08random_obstacle/random_obstacle.py +0 -0
  64. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/08random_obstacle/random_obstacle.yaml +0 -0
  65. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/09keyboard_control/keyboard_control.py +0 -0
  66. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/09keyboard_control/keyboard_control.yaml +0 -0
  67. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/10grid_map/cave.png +0 -0
  68. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/10grid_map/grid_map.py +0 -0
  69. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/usage/10grid_map/grid_map.yaml +0 -0
  70. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/version.py +0 -0
  71. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/__init__.py +0 -0
  72. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/description/car_blue.png +0 -0
  73. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/description/car_green.png +0 -0
  74. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/description/car_red.png +0 -0
  75. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/description/diff_robot0.png +0 -0
  76. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/description/diff_robot1.png +0 -0
  77. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/map/cave.png +0 -0
  78. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/map/obstacle_map.py +0 -0
  79. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/multi_object_base.py +0 -0
  80. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/object_factory.py +0 -0
  81. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/obstacles/obstacle_diff.py +0 -0
  82. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/obstacles/obstacle_omni.py +0 -0
  83. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/obstacles/obstacle_static.py +0 -0
  84. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/robots/robot_acker.py +0 -0
  85. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/robots/robot_diff.py +0 -0
  86. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/robots/robot_omni.py +0 -0
  87. {ir_sim-2.2.4 → ir_sim-2.2.6}/irsim/world/sensors/sensor_factory.py +0 -0
  88. {ir_sim-2.2.4 → ir_sim-2.2.6}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ir-sim
3
- Version: 2.2.4
4
- Summary: A simple python based Intelligent Robot Simulator fpr robot navigation and Learning
3
+ Version: 2.2.6
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
7
7
  Classifier: Programming Language :: Python :: 3
@@ -17,7 +17,7 @@ Requires-Dist: pyyaml
17
17
  Requires-Dist: pynput
18
18
  Requires-Dist: imageio
19
19
  Requires-Dist: pathlib
20
- Requires-Dist: shapely
20
+ Requires-Dist: shapely==2.0.6
21
21
  Requires-Dist: scikit-image
22
22
  Requires-Dist: loguru
23
23
 
@@ -33,8 +33,7 @@ Requires-Dist: loguru
33
33
  <a href="https://img.shields.io/badge/release-v2.1.0-brightgreen?link=https%3A%2F%2Fgithub.com%2Fhanruihua%2Fir-sim%2Freleases%2F
34
34
  )](https://github.com/hanruihua/ir-sim/releases/"><img src='https://img.shields.io/github/v/release/hanruihua/ir-sim?color=brightgreen' alt='Github Release'></a>
35
35
  <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>
36
- <a href="https://pypistats.org/packages/ir-sim"><img src='https://img.shields.io/pypi/dm/ir-sim' alt='Download'></a>
37
-
36
+ <a href="https://pepy.tech/project/ir-sim"><img src="https://img.shields.io/pepy/dt/ir-sim" alt="PyPI Downloads"></a>
38
37
  </div>
39
38
 
40
39
  IR-SIM is an open-source, lightweight robot 2D 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.
@@ -48,8 +47,7 @@ It provides the following features:
48
47
 
49
48
  Robot | Car
50
49
  :-------------------------:|:-------------------------:
51
- ![robot](doc/animations/rvo.gif) | ![car](doc/animations/car.gif)
52
-
50
+ ![robot](https://github.com/user-attachments/assets/5930b088-d400-4943-8ded-853c22eae75b) | ![car](https://github.com/user-attachments/assets/3257abc1-8bed-40d8-9b51-e5d90b06ee06)
53
51
 
54
52
  ## Prerequisite
55
53
 
@@ -167,19 +165,10 @@ obstacle:
167
165
  - [RDA_planner](https://github.com/hanruihua/RDA_planner)(RAL & IROS2023)
168
166
 
169
167
 
170
- <!-- ## Contact:
171
- hanrh@connect.hku.hk -->
168
+ ## Acknowledgement
172
169
 
173
- <!-- ## Citation
170
+ - [PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics)
174
171
 
175
- ```
176
- @misc{ir-sim,
177
- author = "Ruihua Han",
178
- title = "ir-sim: Python based light-weight simulator for robotics navigation and learning.",
179
- year = 2024,
180
- url = "https://github.com/hanruihua/ir-sim"
181
- }
182
- ``` -->
183
172
 
184
173
 
185
174
 
@@ -10,8 +10,7 @@
10
10
  <a href="https://img.shields.io/badge/release-v2.1.0-brightgreen?link=https%3A%2F%2Fgithub.com%2Fhanruihua%2Fir-sim%2Freleases%2F
11
11
  )](https://github.com/hanruihua/ir-sim/releases/"><img src='https://img.shields.io/github/v/release/hanruihua/ir-sim?color=brightgreen' alt='Github Release'></a>
12
12
  <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>
13
- <a href="https://pypistats.org/packages/ir-sim"><img src='https://img.shields.io/pypi/dm/ir-sim' alt='Download'></a>
14
-
13
+ <a href="https://pepy.tech/project/ir-sim"><img src="https://img.shields.io/pepy/dt/ir-sim" alt="PyPI Downloads"></a>
15
14
  </div>
16
15
 
17
16
  IR-SIM is an open-source, lightweight robot 2D 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.
@@ -25,8 +24,7 @@ It provides the following features:
25
24
 
26
25
  Robot | Car
27
26
  :-------------------------:|:-------------------------:
28
- ![robot](doc/animations/rvo.gif) | ![car](doc/animations/car.gif)
29
-
27
+ ![robot](https://github.com/user-attachments/assets/5930b088-d400-4943-8ded-853c22eae75b) | ![car](https://github.com/user-attachments/assets/3257abc1-8bed-40d8-9b51-e5d90b06ee06)
30
28
 
31
29
  ## Prerequisite
32
30
 
@@ -144,19 +142,10 @@ obstacle:
144
142
  - [RDA_planner](https://github.com/hanruihua/RDA_planner)(RAL & IROS2023)
145
143
 
146
144
 
147
- <!-- ## Contact:
148
- hanrh@connect.hku.hk -->
145
+ ## Acknowledgement
149
146
 
150
- <!-- ## Citation
147
+ - [PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics)
151
148
 
152
- ```
153
- @misc{ir-sim,
154
- author = "Ruihua Han",
155
- title = "ir-sim: Python based light-weight simulator for robotics navigation and learning.",
156
- year = 2024,
157
- url = "https://github.com/hanruihua/ir-sim"
158
- }
159
- ``` -->
160
149
 
161
150
 
162
151
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ir-sim
3
- Version: 2.2.4
4
- Summary: A simple python based Intelligent Robot Simulator fpr robot navigation and Learning
3
+ Version: 2.2.6
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
7
7
  Classifier: Programming Language :: Python :: 3
@@ -17,7 +17,7 @@ Requires-Dist: pyyaml
17
17
  Requires-Dist: pynput
18
18
  Requires-Dist: imageio
19
19
  Requires-Dist: pathlib
20
- Requires-Dist: shapely
20
+ Requires-Dist: shapely==2.0.6
21
21
  Requires-Dist: scikit-image
22
22
  Requires-Dist: loguru
23
23
 
@@ -33,8 +33,7 @@ Requires-Dist: loguru
33
33
  <a href="https://img.shields.io/badge/release-v2.1.0-brightgreen?link=https%3A%2F%2Fgithub.com%2Fhanruihua%2Fir-sim%2Freleases%2F
34
34
  )](https://github.com/hanruihua/ir-sim/releases/"><img src='https://img.shields.io/github/v/release/hanruihua/ir-sim?color=brightgreen' alt='Github Release'></a>
35
35
  <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>
36
- <a href="https://pypistats.org/packages/ir-sim"><img src='https://img.shields.io/pypi/dm/ir-sim' alt='Download'></a>
37
-
36
+ <a href="https://pepy.tech/project/ir-sim"><img src="https://img.shields.io/pepy/dt/ir-sim" alt="PyPI Downloads"></a>
38
37
  </div>
39
38
 
40
39
  IR-SIM is an open-source, lightweight robot 2D 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.
@@ -48,8 +47,7 @@ It provides the following features:
48
47
 
49
48
  Robot | Car
50
49
  :-------------------------:|:-------------------------:
51
- ![robot](doc/animations/rvo.gif) | ![car](doc/animations/car.gif)
52
-
50
+ ![robot](https://github.com/user-attachments/assets/5930b088-d400-4943-8ded-853c22eae75b) | ![car](https://github.com/user-attachments/assets/3257abc1-8bed-40d8-9b51-e5d90b06ee06)
53
51
 
54
52
  ## Prerequisite
55
53
 
@@ -167,19 +165,10 @@ obstacle:
167
165
  - [RDA_planner](https://github.com/hanruihua/RDA_planner)(RAL & IROS2023)
168
166
 
169
167
 
170
- <!-- ## Contact:
171
- hanrh@connect.hku.hk -->
168
+ ## Acknowledgement
172
169
 
173
- <!-- ## Citation
170
+ - [PythonRobotics](https://github.com/AtsushiSakai/PythonRobotics)
174
171
 
175
- ```
176
- @misc{ir-sim,
177
- author = "Ruihua Han",
178
- title = "ir-sim: Python based light-weight simulator for robotics navigation and learning.",
179
- year = 2024,
180
- url = "https://github.com/hanruihua/ir-sim"
181
- }
182
- ``` -->
183
172
 
184
173
 
185
174
 
@@ -1,8 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- doc/animations/image/IR_SIM_logos/logo1.png
5
- doc/animations/image/IR_SIM_logos/logo1_nobg.png
6
4
  doc/source/conf.py
7
5
  ir_sim.egg-info/PKG-INFO
8
6
  ir_sim.egg-info/SOURCES.txt
@@ -21,7 +19,8 @@ irsim/global_param/path_param.py
21
19
  irsim/global_param/world_param.py
22
20
  irsim/lib/__init__.py
23
21
  irsim/lib/behavior.py
24
- irsim/lib/behaviorlib.py
22
+ irsim/lib/behavior_methods.py
23
+ irsim/lib/behavior_registry.py
25
24
  irsim/lib/generation.py
26
25
  irsim/lib/kinematics.py
27
26
  irsim/lib/algorithm/rvo.py
@@ -37,10 +36,12 @@ irsim/usage/04collision_world/collision_world.py
37
36
  irsim/usage/04collision_world/collision_world.yaml
38
37
  irsim/usage/05lidar_world/lidar_world.py
39
38
  irsim/usage/05lidar_world/lidar_world.yaml
39
+ irsim/usage/05lidar_world/lidar_world_noise.yaml
40
40
  irsim/usage/06multi_objects_world/multi_objects_world.py
41
41
  irsim/usage/06multi_objects_world/multi_objects_world.yaml
42
42
  irsim/usage/07render_world/render.py
43
43
  irsim/usage/07render_world/render.yaml
44
+ irsim/usage/07render_world/render_save_figure.py
44
45
  irsim/usage/08random_obstacle/random_obstacle.py
45
46
  irsim/usage/08random_obstacle/random_obstacle.yaml
46
47
  irsim/usage/09keyboard_control/keyboard_control.py
@@ -52,8 +53,9 @@ irsim/usage/11collision_avoidance/collision_avoidance.py
52
53
  irsim/usage/11collision_avoidance/collision_avoidance.yaml
53
54
  irsim/usage/12dynamic_obstacle/dynamic_obstacle.py
54
55
  irsim/usage/12dynamic_obstacle/dynamic_obstacle.yaml
55
- irsim/usage/test_all_objects/all_objects.py
56
- irsim/usage/test_all_objects/all_objects.yaml
56
+ irsim/usage/13custom_behavior/custom_behavior.py
57
+ irsim/usage/13custom_behavior/custom_behavior.yaml
58
+ irsim/usage/13custom_behavior/custom_behavior_methods.py
57
59
  irsim/util/util.py
58
60
  irsim/world/__init__.py
59
61
  irsim/world/multi_object_base.py
@@ -74,4 +76,6 @@ irsim/world/robots/robot_acker.py
74
76
  irsim/world/robots/robot_diff.py
75
77
  irsim/world/robots/robot_omni.py
76
78
  irsim/world/sensors/lidar2d.py
77
- irsim/world/sensors/sensor_factory.py
79
+ irsim/world/sensors/sensor_factory.py
80
+ tests/test_all_objects.py
81
+ tests/test_all_objects.yaml
@@ -5,6 +5,6 @@ pyyaml
5
5
  pynput
6
6
  imageio
7
7
  pathlib
8
- shapely
8
+ shapely==2.0.6
9
9
  scikit-image
10
10
  loguru
@@ -1,3 +1,4 @@
1
1
  dist
2
2
  doc
3
3
  irsim
4
+ tests
@@ -0,0 +1,11 @@
1
+ from .version import __version__
2
+ from irsim.env import EnvBase
3
+ import os
4
+ import sys
5
+
6
+
7
+ def make(world_name=None, **kwargs) -> EnvBase:
8
+
9
+ world_name = world_name or os.path.basename(sys.argv[0]).split(".")[0] + ".yaml"
10
+
11
+ return EnvBase(world_name, **kwargs)
@@ -13,6 +13,7 @@ from .env_logger import EnvLogger
13
13
  from irsim.lib.generation import random_generate_polygon
14
14
  from shapely import Polygon
15
15
  from typing import Optional
16
+ import importlib
16
17
 
17
18
 
18
19
  class EnvBase:
@@ -40,9 +41,6 @@ class EnvBase:
40
41
  log_level: str = "INFO",
41
42
  ) -> None:
42
43
 
43
- env_config = EnvConfig(world_name)
44
- object_factory = ObjectFactory()
45
-
46
44
  # init env setting
47
45
  self.display = display
48
46
  self.disable_all_plot = disable_all_plot
@@ -50,6 +48,9 @@ class EnvBase:
50
48
  self.logger = EnvLogger(log_file, log_level)
51
49
  env_param.logger = self.logger
52
50
 
51
+ env_config = EnvConfig(world_name)
52
+ object_factory = ObjectFactory()
53
+
53
54
  # init objects (world, obstacle, robot)
54
55
  self._world = world(world_name, **env_config.parse["world"])
55
56
 
@@ -90,7 +91,7 @@ class EnvBase:
90
91
 
91
92
  def __del__(self):
92
93
  print(
93
- "Simulated Environment End with sim time elapsed: {} seconds".format(
94
+ "INFO: Simulated Environment End with sim time elapsed: {} seconds".format(
94
95
  round(self._world.time, 2)
95
96
  )
96
97
  )
@@ -148,7 +149,7 @@ class EnvBase:
148
149
  plt.pause(interval)
149
150
 
150
151
  if self.save_ani:
151
- self._env_plot.save_gif_figure(**figure_kwargs)
152
+ self.save_figure(save_gif=True, **figure_kwargs)
152
153
 
153
154
  self._env_plot.clear_components("dynamic", self.objects)
154
155
  self._env_plot.draw_components("dynamic", self.objects, **kwargs)
@@ -272,12 +273,18 @@ class EnvBase:
272
273
  **kwargs: Additional keyword arguments for saving the animation, see env_plot.save_animate() function for detail.
273
274
  """
274
275
 
276
+ if self.disable_all_plot:
277
+ return
278
+
275
279
  if self.save_ani:
276
280
  self._env_plot.save_animate(**kwargs)
277
281
 
278
- self.logger.info(f"Figure will be closed within {ending_time:.2f} seconds.")
279
- plt.pause(ending_time)
282
+ if self.display:
283
+ plt.pause(ending_time)
284
+ self.logger.info(f"Figure will be closed within {ending_time:.2f} seconds.")
285
+
280
286
  plt.close()
287
+
281
288
 
282
289
  def done(self, mode="all"):
283
290
  """
@@ -306,8 +313,11 @@ class EnvBase:
306
313
  """
307
314
 
308
315
  self._reset_all()
316
+ self.reset_plot()
317
+ self._world.reset()
309
318
  self.step(action=np.zeros((2, 1)))
310
319
 
320
+
311
321
  def _reset_all(self):
312
322
  [obj.reset() for obj in self.objects]
313
323
 
@@ -469,8 +479,37 @@ class EnvBase:
469
479
 
470
480
  # endregion: get information
471
481
 
482
+ def save_figure(self, save_name=None, include_index=False, save_gif=False, **kwargs):
483
+ """
484
+ Save the current figure.
485
+ Args:
486
+ save_name: Name of the file with format to save the figure.
487
+ **kwargs: Additional keyword arguments for saving the figure, see matplotlib.pyplot.savefig() function for detail.
488
+ """
489
+ if save_name is None:
490
+ save_name = self._world.name + '.png'
491
+
492
+ file_name, file_format = save_name.split('.')
493
+
494
+ self._env_plot.save_figure(file_name, file_format, include_index, save_gif, **kwargs)
495
+
472
496
  # region: property
473
497
 
498
+ def load_behavior(self, behaviors: str='behavior_methods'):
499
+ """
500
+ Load behavior parameters from the script. Please refer to the behavior_methods.py file for more details.
501
+ Please make sure the python file is placed in the same folder with the implemented script.
502
+
503
+ Args:
504
+ behaviors (str): name of the bevavior script.
505
+ """
506
+
507
+ try:
508
+ importlib.import_module(behaviors)
509
+ except ImportError as e:
510
+ print(f"Failed to load module '{behaviors}': {e}")
511
+
512
+
474
513
  @property
475
514
  def arrive(self, id=None, mode=None):
476
515
  """
@@ -1,6 +1,6 @@
1
1
  import yaml
2
2
  from irsim.util.util import file_check
3
-
3
+ from irsim.global_param import env_param
4
4
 
5
5
  class EnvConfig:
6
6
  """
@@ -30,10 +30,11 @@ class EnvConfig:
30
30
  if key in self._kwargs_parse.keys():
31
31
  self._kwargs_parse[key] = com_list[key]
32
32
  else:
33
- print(f"Invalid key: {key} in {world_name} file!")
33
+ env_param.logger.error(f"There are invalid key: '{key}' in {world_name} file!")
34
+ raise KeyError
34
35
 
35
36
  else:
36
- print("File not found!")
37
+ env_param.logger.error(f" {world_name} YAML File not found! ")
37
38
 
38
39
  @property
39
40
  def parse(self):
@@ -8,6 +8,9 @@ import shutil
8
8
  import glob
9
9
  from math import sin, cos
10
10
  import numpy as np
11
+ import matplotlib
12
+
13
+ matplotlib.use("TkAgg")
11
14
 
12
15
 
13
16
  class EnvPlot:
@@ -23,6 +26,8 @@ class EnvPlot:
23
26
  See https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html for details.
24
27
  saved_ani (dict): Keyword arguments for saving the animation.
25
28
  See https://imageio.readthedocs.io/en/v2.8.0/format_gif-pil.html#gif-pil for details.
29
+ dpi: Dots per inch for the figure. Default is 100.
30
+ figure_pixels: Width and height of the figure in pixels. Default is [1920, 1080].
26
31
  kwargs: Additional options such as color_map, no_axis, and tight.
27
32
  """
28
33
 
@@ -34,13 +39,15 @@ class EnvPlot:
34
39
  y_range=[0, 10],
35
40
  saved_figure=dict(),
36
41
  saved_ani=dict(),
42
+ dpi: int = 100,
43
+ figure_pixels: list =[1920, 1080],
37
44
  **kwargs,
38
45
  ) -> None:
39
46
  """
40
47
  Initialize the EnvPlot instance.
41
48
  """
42
- self.fig, self.ax = plt.subplots()
43
49
 
50
+ self.fig, self.ax = plt.subplots(figsize=(figure_pixels[0] / dpi, figure_pixels[1] / dpi), dpi=dpi)
44
51
  self.x_range = x_range
45
52
  self.y_range = y_range
46
53
 
@@ -56,6 +63,8 @@ class EnvPlot:
56
63
 
57
64
  self.saved_figure_kwargs = saved_figure
58
65
  self.saved_ani_kwargs = saved_ani
66
+ self.dpi = dpi
67
+ self.figure_pixels = figure_pixels
59
68
 
60
69
  self.dyna_line_list = []
61
70
  self.dyna_point_list = []
@@ -221,29 +230,38 @@ class EnvPlot:
221
230
  if refresh:
222
231
  self.dyna_line_list.append(box_line)
223
232
 
224
- def save_gif_figure(self, format="png", **kwargs):
233
+ def save_figure(self, file_name='', file_format="png", include_index=False, save_gif=False, **kwargs):
225
234
  """
226
- Save the figure for generating animation.
235
+ Save the current figure.
227
236
 
228
237
  Args:
229
- format (str): Format of the figure. Default is 'png'.
238
+ file_name (str): Name of the figure. Default is ''.
239
+ file_format (str): Format of the figure. Default is 'png'.
230
240
  kwargs: Additional arguments for saving the figure.
231
241
  See https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html for details.
232
242
  """
233
- fp = pm.ani_buffer_path
243
+
244
+ if save_gif:
245
+ fp = pm.ani_buffer_path
246
+ else:
247
+ fp = pm.fig_path
234
248
 
235
249
  if not os.path.exists(fp):
236
250
  os.makedirs(fp)
237
251
 
238
- order = str(world_param.count).zfill(3)
239
-
240
- self.saved_figure_kwargs.update({"dpi": 100, "bbox_inches": "tight"})
252
+ self.saved_figure_kwargs.update({"dpi": self.dpi, "bbox_inches": "tight"})
241
253
  self.saved_figure_kwargs.update(kwargs)
242
254
 
255
+ if include_index or save_gif:
256
+ order = str(world_param.count).zfill(3)
257
+ full_name = fp + "/" + file_name + '_' + order + "." + file_format
258
+ else:
259
+ full_name = fp + "/" + file_name + "." + file_format
260
+
243
261
  self.fig.savefig(
244
- fp + "/" + order + "." + format, format=format, **self.saved_figure_kwargs
262
+ full_name, format=file_format, **self.saved_figure_kwargs
245
263
  )
246
-
264
+
247
265
  def save_animate(
248
266
  self,
249
267
  ani_name="animation",
@@ -301,3 +319,36 @@ class EnvPlot:
301
319
  Display the plot.
302
320
  """
303
321
  plt.show()
322
+
323
+
324
+ def linewidth_from_data_units(linewidth, axis, reference='y'):
325
+ """
326
+ Convert a linewidth in data units to linewidth in points.
327
+
328
+ Parameters
329
+ ----------
330
+ linewidth: float
331
+ Linewidth in data units of the respective reference-axis
332
+ axis: matplotlib axis
333
+ The axis which is used to extract the relevant transformation
334
+ data (data limits and size must not change afterwards)
335
+ reference: string
336
+ The axis that is taken as a reference for the data width.
337
+ Possible values: 'x' and 'y'. Defaults to 'y'.
338
+
339
+ Returns
340
+ -------
341
+ linewidth: float
342
+ Linewidth in points
343
+ """
344
+ fig = axis.get_figure()
345
+ if reference == 'x':
346
+ length = fig.bbox_inches.width * axis.get_position().width
347
+ value_range = np.diff(axis.get_xlim())
348
+ elif reference == 'y':
349
+ length = fig.bbox_inches.height * axis.get_position().height
350
+ value_range = np.diff(axis.get_ylim())
351
+ # Convert length to points
352
+ length *= 72
353
+ # Scale linewidth to value range
354
+ return linewidth * (length / value_range)
@@ -0,0 +1,81 @@
1
+ from math import inf
2
+ import numpy as np
3
+ from irsim.global_param import env_param
4
+ import importlib
5
+ from typing import Tuple, Any
6
+ from .behavior_registry import behaviors_map
7
+
8
+ class Behavior:
9
+ """
10
+ Represents the behavior of an agent in the simulation.
11
+
12
+ Args:
13
+ object_info (object): Object information from the object_base class ObjectInfo.
14
+ behavior_dict (dict): Dictionary containing behavior parameters for different behaviors.
15
+ Options include: 'dash', 'rvo'.
16
+ """
17
+
18
+ def __init__(self, object_info=None, behavior_dict=None) -> None:
19
+ """
20
+ Initializes the Behavior class with object information and behavior parameters.
21
+
22
+ Args:
23
+ object_info (object): Information about the agent.
24
+ behavior_dict (dict): Behavior parameters.
25
+ """
26
+ self.object_info = object_info
27
+ self.behavior_dict = dict() if behavior_dict is None else behavior_dict
28
+ self.load_behavior()
29
+
30
+ def gen_vel(self, objects):
31
+ """
32
+ Generate velocity for the agent based on the behavior dictionary.
33
+
34
+ Args:
35
+ objects: all the objects in the evironment
36
+
37
+ Returns:
38
+ np.array (2, 1): Generated velocity for the agent.
39
+ """
40
+
41
+ if self.behavior_dict is None:
42
+ env_param.logger.error("Behavior not defined for object {}.".format(self.object_info.id))
43
+ return np.zeros((2, 1))
44
+
45
+ behavior_vel = self.invoke_behavior(self.object_info.kinematics, self.behavior_dict["name"], ego_object=objects[self.object_info.id], objects=objects, **self.behavior_dict)
46
+
47
+ return behavior_vel
48
+
49
+
50
+ def load_behavior(self, behaviors: str='.behavior_methods'):
51
+ """
52
+ Load behavior parameters from the script.
53
+
54
+ Args:
55
+ behaviors (str): name of the bevavior script.
56
+ """
57
+
58
+ try:
59
+ importlib.import_module(behaviors, package='irsim.lib')
60
+ except ImportError as e:
61
+ print(f"Failed to load module '{behaviors}': {e}")
62
+
63
+
64
+ def invoke_behavior(self, kinematics: str, action: str, **kwargs: Any) -> Any:
65
+ """
66
+ Invoke a behavior method.
67
+
68
+ Args:
69
+ kinematics (str): Name of the behavior method. only support: 'diff', 'omni', 'acker'.
70
+ action: Name of the action method. example: 'dash', 'rvo'.
71
+ **kwargs: Arbitrary keyword arguments.
72
+
73
+ Returns:
74
+ np.array: Velocity (2x1).
75
+ """
76
+ key: Tuple[str, str] = (kinematics, action)
77
+ func = behaviors_map.get(key)
78
+ if not func:
79
+ raise ValueError(f"No method found for category '{kinematics}' and action '{action}'.")
80
+
81
+ return func(**kwargs)