ir-sim 2.2.0__tar.gz → 2.2.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.2.0/ir_sim.egg-info → ir_sim-2.2.2}/PKG-INFO +1 -1
- ir_sim-2.2.2/doc/source/conf.py +91 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2/ir_sim.egg-info}/PKG-INFO +1 -1
- {ir_sim-2.2.0 → ir_sim-2.2.2}/ir_sim.egg-info/SOURCES.txt +3 -2
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/env/env_base.py +29 -23
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/env/env_logger.py +0 -4
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/env/env_plot.py +36 -36
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/03obstacle_world/obstacle_world.yaml +2 -1
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/04collision_world/collision_world.yaml +1 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/object_base.py +21 -7
- {ir_sim-2.2.0 → ir_sim-2.2.2}/pyproject.toml +1 -1
- {ir_sim-2.2.0 → ir_sim-2.2.2}/LICENSE +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/README.md +0 -0
- {ir_sim-2.2.0/doc → ir_sim-2.2.2/doc/animations}/image/IR_SIM_logos/logo1.png +0 -0
- {ir_sim-2.2.0/doc → ir_sim-2.2.2/doc/animations}/image/IR_SIM_logos/logo1_nobg.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/ir_sim.egg-info/dependency_links.txt +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/ir_sim.egg-info/requires.txt +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/ir_sim.egg-info/top_level.txt +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/__init__.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/env/__init__.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/env/env_config.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/global_param/env_param.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/global_param/path_param.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/global_param/world_param.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/__init__.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/algorithm/rvo.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/behavior.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/behaviorlib.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/factory.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/generation.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/lib/kinematics.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/01empty_world/empty_world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/01empty_world/empty_world.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/02robot_world/car_world.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/02robot_world/robot_omni_world.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/02robot_world/robot_world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/02robot_world/robot_world.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/03obstacle_world/obstacle_world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/04collision_world/collision_world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/05lidar_world/lidar_world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/05lidar_world/lidar_world.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/06multi_objects_world/multi_objects_world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/06multi_objects_world/multi_objects_world.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/07render_world/render.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/07render_world/render.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/08random_obstacle/random_obstacle.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/08random_obstacle/random_obstacle.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/09keyboard_control/keyboard_control.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/09keyboard_control/keyboard_control.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/10grid_map/cave.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/10grid_map/grid_map.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/10grid_map/grid_map.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/11collision_avoidance/collision_avoidance.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/usage/11collision_avoidance/collision_avoidance.yaml +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/util/util.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/version.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/__init__.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/description/car_blue.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/description/car_green.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/description/car_red.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/description/diff_robot0.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/description/diff_robot1.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/map/cave.png +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/map/obstacle_map.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/multi_object_base.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/object_factory.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/obstacles/obstacle_diff.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/obstacles/obstacle_omni.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/obstacles/obstacle_static.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/robots/robot_acker.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/robots/robot_diff.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/robots/robot_omni.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/sensors/lidar2d.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/sensors/sensor_factory.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/irsim/world/world.py +0 -0
- {ir_sim-2.2.0 → ir_sim-2.2.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ir-sim
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: A simple python based Intelligent Robot Simulator fpr robot navigation and Learning
|
|
5
5
|
Author-email: Han Ruihua <hanrh@connect.hku.hk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/hanruihua/ir-sim
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# This file only contains a selection of the most common options. For a full
|
|
4
|
+
# list see the documentation:
|
|
5
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
6
|
+
|
|
7
|
+
# -- Path setup --------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
# If extensions (or modules to document with autodoc) are in another directory,
|
|
10
|
+
# add these directories to sys.path here. If the directory is relative to the
|
|
11
|
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
12
|
+
#
|
|
13
|
+
# import os
|
|
14
|
+
# import sys
|
|
15
|
+
# sys.path.insert(0, os.path.abspath('.'))
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
from unittest.mock import MagicMock
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Mock(MagicMock):
|
|
24
|
+
@classmethod
|
|
25
|
+
def __getattr__(cls, name):
|
|
26
|
+
return MagicMock()
|
|
27
|
+
|
|
28
|
+
MOCK_MODULES = ['pynput', 'loguru']
|
|
29
|
+
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
|
|
30
|
+
|
|
31
|
+
# Rest of your conf.py content
|
|
32
|
+
|
|
33
|
+
# -- Project information -----------------------------------------------------
|
|
34
|
+
|
|
35
|
+
project = 'IR-SIM'
|
|
36
|
+
copyright = '2024, Ruihua Han'
|
|
37
|
+
author = 'Ruihua Han'
|
|
38
|
+
|
|
39
|
+
# The full version, including alpha/beta/rc tags
|
|
40
|
+
release = '2.2.0'
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# print(os.path.abspath('../../'))
|
|
44
|
+
# sys.path.insert(0, os.path.abspath('../../'))
|
|
45
|
+
# sys.path.insert(0, os.path.abspath("../.."))
|
|
46
|
+
# sys.path.insert(0, os.path.abspath("./"))
|
|
47
|
+
# sys.path.insert(0, os.path.join(os.path.dirname((os.path.abspath('.')), 'irsim')))
|
|
48
|
+
|
|
49
|
+
# root_path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
|
50
|
+
# sys.path.insert(0, os.path.dirname(__file__))
|
|
51
|
+
|
|
52
|
+
# sys.path.insert(0, os.path.abspath("../.."))
|
|
53
|
+
# print(os.path.abspath('./'))
|
|
54
|
+
# sys.path.insert(0, os.path.abspath('./'))
|
|
55
|
+
# sys.path.insert(0, os.path.abspath('../src'))
|
|
56
|
+
# sys.path.append(os.path.abspath('../../'))
|
|
57
|
+
# sys.path.insert(0, os.path.abspath(".."))
|
|
58
|
+
|
|
59
|
+
# -- General configuration ---------------------------------------------------
|
|
60
|
+
|
|
61
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
62
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
|
63
|
+
# ones.
|
|
64
|
+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'sphinx.ext.napoleon', 'myst_parser', 'sphinx_multiversion'
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
# Add any paths that contain templates here, relative to this directory.
|
|
68
|
+
templates_path = ['_templates']
|
|
69
|
+
|
|
70
|
+
# List of patterns, relative to source directory, that match files and
|
|
71
|
+
# directories to ignore when looking for source files.
|
|
72
|
+
# This pattern also affects html_static_path and html_extra_path.
|
|
73
|
+
exclude_patterns = []
|
|
74
|
+
|
|
75
|
+
# root_doc = 'irsim'
|
|
76
|
+
# -- Options for HTML output -------------------------------------------------
|
|
77
|
+
|
|
78
|
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
79
|
+
# a list of builtin themes.
|
|
80
|
+
#
|
|
81
|
+
# html_theme = 'alabaster'
|
|
82
|
+
|
|
83
|
+
# Add any paths that contain custom static files (such as style sheets) here,
|
|
84
|
+
# relative to this directory. They are copied after the builtin static files,
|
|
85
|
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
86
|
+
# html_static_path = ['_static']
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
html_theme = "sphinx_rtd_theme"
|
|
90
|
+
|
|
91
|
+
autodoc_member_order = 'bysource'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ir-sim
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: A simple python based Intelligent Robot Simulator fpr robot navigation and Learning
|
|
5
5
|
Author-email: Han Ruihua <hanrh@connect.hku.hk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/hanruihua/ir-sim
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
|
-
doc/image/IR_SIM_logos/logo1.png
|
|
5
|
-
doc/image/IR_SIM_logos/logo1_nobg.png
|
|
4
|
+
doc/animations/image/IR_SIM_logos/logo1.png
|
|
5
|
+
doc/animations/image/IR_SIM_logos/logo1_nobg.png
|
|
6
|
+
doc/source/conf.py
|
|
6
7
|
ir_sim.egg-info/PKG-INFO
|
|
7
8
|
ir_sim.egg-info/SOURCES.txt
|
|
8
9
|
ir_sim.egg-info/dependency_links.txt
|
|
@@ -78,14 +78,13 @@ class EnvBase:
|
|
|
78
78
|
Perform a simulation step in the environment.
|
|
79
79
|
|
|
80
80
|
Args:
|
|
81
|
-
|
|
82
|
-
List of actions to be performed for each robot in the environment.
|
|
83
|
-
if action is numpy array (2 * 1 vector):
|
|
84
|
-
differential robot action: linear velocity, angular velocity
|
|
85
|
-
omnidirectional robot action: velocity in x, velocity in y
|
|
86
|
-
Ackermann robot action: linear velocity, Steering angle
|
|
81
|
+
action (list or numpy array 2*1): Action to be performed in the environment.
|
|
87
82
|
|
|
88
|
-
|
|
83
|
+
- differential robot action: linear velocity, angular velocity
|
|
84
|
+
- omnidirectional robot action: v_x -- velocity in x; v_y -- velocity in y
|
|
85
|
+
- Ackermann robot action: linear velocity, Steering angle
|
|
86
|
+
|
|
87
|
+
action_id (int): Apply the action to the robot with the given id.
|
|
89
88
|
'''
|
|
90
89
|
|
|
91
90
|
if isinstance(action, list):
|
|
@@ -113,9 +112,9 @@ class EnvBase:
|
|
|
113
112
|
Render the environment.
|
|
114
113
|
|
|
115
114
|
Args:
|
|
116
|
-
interval
|
|
117
|
-
figure_kwargs
|
|
118
|
-
kwargs: Additional keyword arguments for drawing components. see object_base.plot() function for detail.
|
|
115
|
+
interval(float) : Time interval between frames in seconds.
|
|
116
|
+
figure_kwargs(dict) : Additional keyword arguments for saving figures, see https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html for detail.
|
|
117
|
+
kwargs: Additional keyword arguments for drawing components. see object_base.plot() function for detail.
|
|
119
118
|
'''
|
|
120
119
|
|
|
121
120
|
if not self.disable_all_plot:
|
|
@@ -184,25 +183,31 @@ class EnvBase:
|
|
|
184
183
|
Initialize keyboard control for the environment.
|
|
185
184
|
|
|
186
185
|
Args:
|
|
187
|
-
keyboard_kwargs (dict): Dictionary of keyword arguments for keyboard control settings
|
|
186
|
+
keyboard_kwargs (dict): Dictionary of keyword arguments for keyboard control settings
|
|
187
|
+
|
|
188
188
|
- vel_max (list): Maximum velocities [linear, angular]. Default is [3.0, 1.0].
|
|
189
|
-
|
|
190
|
-
-
|
|
189
|
+
|
|
190
|
+
- key_lv_max (float): Maximum linear velocity. Default is vel_max [0].
|
|
191
|
+
|
|
192
|
+
- key_ang_max (float): Maximum angular velocity. Default is vel_max [1].
|
|
193
|
+
|
|
191
194
|
- key_lv (float): Initial linear velocity. Default is 0.0.
|
|
195
|
+
|
|
192
196
|
- key_ang (float): Initial angular velocity. Default is 0.0.
|
|
197
|
+
|
|
193
198
|
- key_id (int): Initial robot control ID. Default is 0.
|
|
194
199
|
|
|
195
200
|
Keys:
|
|
196
|
-
w: Move forward.
|
|
197
|
-
s: Move backward.
|
|
198
|
-
a: Turn left.
|
|
199
|
-
d: Turn right.
|
|
200
|
-
q: Decrease linear velocity.
|
|
201
|
-
e: Increase linear velocity.
|
|
202
|
-
z: Decrease angular velocity.
|
|
203
|
-
c: Increase angular velocity.
|
|
204
|
-
alt + num: Change the current control robot id.
|
|
205
|
-
r: Reset the environment.
|
|
201
|
+
- w: Move forward.
|
|
202
|
+
- s: Move backward.
|
|
203
|
+
- a: Turn left.
|
|
204
|
+
- d: Turn right.
|
|
205
|
+
- q: Decrease linear velocity.
|
|
206
|
+
- e: Increase linear velocity.
|
|
207
|
+
- z: Decrease angular velocity.
|
|
208
|
+
- c: Increase angular velocity.
|
|
209
|
+
- alt + num: Change the current control robot id.
|
|
210
|
+
- r: Reset the environment.
|
|
206
211
|
'''
|
|
207
212
|
|
|
208
213
|
vel_max = keyboard_kwargs.get('vel_max', [3.0, 1.0])
|
|
@@ -254,6 +259,7 @@ class EnvBase:
|
|
|
254
259
|
|
|
255
260
|
Args:
|
|
256
261
|
mode (str): Mode to check if all or any of the objects are done.
|
|
262
|
+
|
|
257
263
|
- all (str): Check if all objects are done.
|
|
258
264
|
- any (str): Check if any of the objects are done.
|
|
259
265
|
'''
|
|
@@ -22,7 +22,6 @@ class EnvLogger:
|
|
|
22
22
|
Log an info message.
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
|
-
----
|
|
26
25
|
msg (str): The message to log.
|
|
27
26
|
'''
|
|
28
27
|
logger.info(msg)
|
|
@@ -32,7 +31,6 @@ class EnvLogger:
|
|
|
32
31
|
Log an error message.
|
|
33
32
|
|
|
34
33
|
Args:
|
|
35
|
-
----
|
|
36
34
|
msg (str): The message to log.
|
|
37
35
|
'''
|
|
38
36
|
logger.error(msg)
|
|
@@ -42,7 +40,6 @@ class EnvLogger:
|
|
|
42
40
|
Log a debug message.
|
|
43
41
|
|
|
44
42
|
Args:
|
|
45
|
-
----
|
|
46
43
|
msg (str): The message to log.
|
|
47
44
|
'''
|
|
48
45
|
logger.debug(msg)
|
|
@@ -52,7 +49,6 @@ class EnvLogger:
|
|
|
52
49
|
Log a warning message.
|
|
53
50
|
|
|
54
51
|
Args:
|
|
55
|
-
----
|
|
56
52
|
msg (str): The message to log.
|
|
57
53
|
'''
|
|
58
54
|
logger.warning(msg)
|
|
@@ -15,31 +15,31 @@ class EnvPlot:
|
|
|
15
15
|
'''
|
|
16
16
|
EnvPlot class for visualizing the environment.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
-----------
|
|
20
|
-
grid_map (optional): The grid map of the environment. Png file
|
|
18
|
+
Args:
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
grid_map (optional): The grid map of the environment. Png file
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
Objects: list of object in the environment.
|
|
23
|
+
|
|
24
|
+
x_range : list
|
|
25
|
+
The range of x-axis values. Default is [0, 10].
|
|
26
|
+
y_range : list
|
|
27
|
+
The range of y-axis values. Default is [0, 10].
|
|
28
|
+
|
|
29
|
+
saved_figure : dict
|
|
30
|
+
Keyword arguments for saving the figure.
|
|
31
|
+
See https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html for details.
|
|
32
|
+
saved_ani : dict
|
|
33
|
+
Keyword arguments for saving the animation.
|
|
34
|
+
See https://imageio.readthedocs.io/en/v2.8.0/format_gif-pil.html#gif-pil for details.
|
|
35
|
+
|
|
36
|
+
kwargs:
|
|
37
|
+
color_map : dict
|
|
38
|
+
Color map for different objects.
|
|
39
|
+
no_axis : bool, optional
|
|
40
|
+
Whether to show the axis. Default is False.
|
|
41
|
+
tight : bool, optional
|
|
42
|
+
Whether to show the axis tightly. Default is True.
|
|
43
43
|
|
|
44
44
|
'''
|
|
45
45
|
|
|
@@ -71,7 +71,7 @@ class EnvPlot:
|
|
|
71
71
|
Initialize the plot with the given grid map and objects.
|
|
72
72
|
|
|
73
73
|
Args:
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
grid_map (optional): The grid map of the environment.
|
|
76
76
|
objects (list): List of objects to plot.
|
|
77
77
|
no_axis (bool, optional): Whether to show the axis. Default is False.
|
|
@@ -98,7 +98,7 @@ class EnvPlot:
|
|
|
98
98
|
Draw the components in the environment.
|
|
99
99
|
|
|
100
100
|
Args:
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
mode:
|
|
103
103
|
- static: draw static objects
|
|
104
104
|
- dynamic: draw dynamic objects
|
|
@@ -126,7 +126,7 @@ class EnvPlot:
|
|
|
126
126
|
Clear the components in the environment.
|
|
127
127
|
|
|
128
128
|
Args:
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
mode:
|
|
131
131
|
- static: clear static objects
|
|
132
132
|
- dynamic: clear dynamic objects
|
|
@@ -164,14 +164,14 @@ class EnvPlot:
|
|
|
164
164
|
self.ax.imshow(grid_map.T, cmap='Greys', origin='lower', extent = self.x_range + self.y_range)
|
|
165
165
|
|
|
166
166
|
|
|
167
|
-
def draw_geometry(self, geometry, **kwargs):
|
|
167
|
+
# def draw_geometry(self, geometry, **kwargs):
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
# if geometry.geom_type == 'Point':
|
|
170
|
+
# pass
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
# elif geometry.geom_type == 'MultiLineString':
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
# lines = geometry.coords.xy
|
|
175
175
|
|
|
176
176
|
def draw_trajectory(self, traj, traj_type='g-', label='trajectory', show_direction=False, refresh=False, **kwargs):
|
|
177
177
|
|
|
@@ -179,7 +179,7 @@ class EnvPlot:
|
|
|
179
179
|
Draw a trajectory on the plot
|
|
180
180
|
|
|
181
181
|
Args:
|
|
182
|
-
|
|
182
|
+
|
|
183
183
|
traj: list of points, point: 3*1 np.array, [x, y, theta]
|
|
184
184
|
traj_type: trajectory type, default is 'g-', see https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html for detail
|
|
185
185
|
label: label of the trajectory
|
|
@@ -220,7 +220,7 @@ class EnvPlot:
|
|
|
220
220
|
Draw points on the plot
|
|
221
221
|
|
|
222
222
|
Args:
|
|
223
|
-
|
|
223
|
+
|
|
224
224
|
point_list: list of points, point: 2*1 np.array or [x, y]
|
|
225
225
|
s: size of the points
|
|
226
226
|
c: color of the points
|
|
@@ -245,7 +245,7 @@ class EnvPlot:
|
|
|
245
245
|
Draw a box by the vertices
|
|
246
246
|
|
|
247
247
|
Args:
|
|
248
|
-
|
|
248
|
+
|
|
249
249
|
vertices: 2*edge_number np.array, vertices of the box
|
|
250
250
|
refresh: whether to refresh the plot (clear the previous box)
|
|
251
251
|
color: color and line type of the box
|
|
@@ -264,7 +264,7 @@ class EnvPlot:
|
|
|
264
264
|
save the figure for generating animation
|
|
265
265
|
|
|
266
266
|
Args:
|
|
267
|
-
|
|
267
|
+
|
|
268
268
|
format: format of the figure, default is 'png'
|
|
269
269
|
kwargs: other arguments for the ax savefig, see https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html for detail, default is {'dpi': 100, 'bbox_inches': 'tight'}
|
|
270
270
|
'''
|
|
@@ -287,7 +287,7 @@ class EnvPlot:
|
|
|
287
287
|
Save the animation
|
|
288
288
|
|
|
289
289
|
Args:
|
|
290
|
-
|
|
290
|
+
|
|
291
291
|
ani_name: name of the animation, default is 'animation'
|
|
292
292
|
suffix: suffix of the animation, default is '.gif'
|
|
293
293
|
keep_len: length of the last frame, default is 30
|
|
@@ -4,7 +4,7 @@ world:
|
|
|
4
4
|
step_time: 0.1 # 10Hz calculate each step
|
|
5
5
|
sample_time: 0.1 # 10 Hz for render and data extraction
|
|
6
6
|
offset: [0, 0] # the offset of the world on x and y
|
|
7
|
-
collision_mode: '
|
|
7
|
+
collision_mode: 'stop' # 'stop', 'unobstructed', 'reactive'
|
|
8
8
|
|
|
9
9
|
robot:
|
|
10
10
|
- kinematics: {name: 'diff'} # omni, diff, acker
|
|
@@ -24,3 +24,4 @@ obstacle:
|
|
|
24
24
|
|
|
25
25
|
- shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] } # vertices
|
|
26
26
|
state: [0, 0, 0]
|
|
27
|
+
unobstructed: True
|
|
@@ -56,7 +56,7 @@ class ObjectBase:
|
|
|
56
56
|
id_iter = itertools.count()
|
|
57
57
|
vel_dim = (2, 1)
|
|
58
58
|
|
|
59
|
-
def __init__(self, shape: str='circle', shape_tuple=None, state=[0, 0, 0], velocity=[0, 0], goal=[10, 10, 0], kinematics: str='omni', role: str='obstacle', color='k', static=False, vel_min=[-1, -1], vel_max=[1, 1], acce=[inf, inf], angle_range=[-pi, pi], behavior=None, goal_threshold=0.1, sensors=None, kinematics_dict=dict(), arrive_mode='position', description=None, group=0, reso=0.1, state_dim=3, **kwargs) -> None:
|
|
59
|
+
def __init__(self, shape: str='circle', shape_tuple=None, state=[0, 0, 0], velocity=[0, 0], goal=[10, 10, 0], kinematics: str='omni', role: str='obstacle', color='k', static=False, vel_min=[-1, -1], vel_max=[1, 1], acce=[inf, inf], angle_range=[-pi, pi], behavior=None, goal_threshold=0.1, sensors=None, kinematics_dict=dict(), arrive_mode='position', description=None, group=0, reso=0.1, state_dim=3, unobstructed=False, **kwargs) -> None:
|
|
60
60
|
|
|
61
61
|
'''
|
|
62
62
|
parameters:
|
|
@@ -89,7 +89,7 @@ class ObjectBase:
|
|
|
89
89
|
|
|
90
90
|
arrive_mode: position or state
|
|
91
91
|
state_dim: the dimension of the state, default is 3
|
|
92
|
-
|
|
92
|
+
unobstructed: whether the object is unobstructed, default is False
|
|
93
93
|
'''
|
|
94
94
|
|
|
95
95
|
self._id = next(ObjectBase.id_iter)
|
|
@@ -117,6 +117,7 @@ class ObjectBase:
|
|
|
117
117
|
self.stop_flag = False
|
|
118
118
|
self.arrive_flag = False
|
|
119
119
|
self.collision_flag = False
|
|
120
|
+
self.unobstructed = unobstructed
|
|
120
121
|
|
|
121
122
|
# information
|
|
122
123
|
self.static = static
|
|
@@ -165,6 +166,8 @@ class ObjectBase:
|
|
|
165
166
|
|
|
166
167
|
self.plot_kwargs = kwargs.get('plot', dict())
|
|
167
168
|
|
|
169
|
+
self.collision_obj = []
|
|
170
|
+
|
|
168
171
|
|
|
169
172
|
def __repr__(self) -> str:
|
|
170
173
|
pass
|
|
@@ -307,7 +310,8 @@ class ObjectBase:
|
|
|
307
310
|
self.check_collision_status()
|
|
308
311
|
|
|
309
312
|
if world_param.collision_mode == 'stop':
|
|
310
|
-
self.stop_flag = self.
|
|
313
|
+
self.stop_flag = any([not obj.unobstructed for obj in self.collision_obj])
|
|
314
|
+
|
|
311
315
|
elif world_param.collision_mode == 'reactive':
|
|
312
316
|
pass
|
|
313
317
|
|
|
@@ -340,12 +344,22 @@ class ObjectBase:
|
|
|
340
344
|
|
|
341
345
|
collision_flags = [ self.check_collision(obj) for obj in env_param.objects if self.id != obj.id]
|
|
342
346
|
|
|
343
|
-
|
|
347
|
+
self.collision_obj = []
|
|
344
348
|
|
|
345
|
-
|
|
346
|
-
|
|
349
|
+
for obj in env_param.objects:
|
|
350
|
+
if self.id != obj.id:
|
|
351
|
+
if self.check_collision(obj):
|
|
352
|
+
if self.role == 'robot':
|
|
353
|
+
self.collision_obj.append(obj)
|
|
354
|
+
if not self.collision_flag: env_param.logger.warning( self.role + "{} is collided with {} at state {}".format(self.id, obj.id, list(np.round(self._state[:2, 0], 2))) )
|
|
355
|
+
|
|
356
|
+
self.collision_flag = any(collision_flags)
|
|
357
|
+
# new_collision_flag = any(collision_flags)
|
|
358
|
+
|
|
359
|
+
# if new_collision_flag and not self.collision_flag:
|
|
360
|
+
# env_param.logger.warning( self.role + "{} is collided at state {}".format(self.id, list(np.round(self._state[:2, 0], 2))))
|
|
347
361
|
|
|
348
|
-
|
|
362
|
+
|
|
349
363
|
|
|
350
364
|
|
|
351
365
|
def check_collision(self, obj):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|