Skip to content

Commit

Permalink
Update doc of dynamic random obstacles
Browse files Browse the repository at this point in the history
  • Loading branch information
hanruihua committed Dec 22, 2024
1 parent 397fd0a commit d50ebdb
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 16 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

## ir-sim 2.2.0

- Rename the module from ir_sim to be irsim, rename the package name from ir_sim to be ir-sim
- Rename the module from ir_sim to irsim, rename the package name from ir_sim to ir-sim
- Add citation for the project
- Refine the comments for the functions

Expand Down
12 changes: 12 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ The simple demonstrations of the simulator are shown below:
:caption: API Documentation:

api/modules


Academic Cases
--------------

- `rl-rvo-nav(RAL & ICRA2023) <https://github.com/hanruihua/rl_rvo_nav>`_

- `RDA_planner(RAL & IROS2023) <https://github.com/hanruihua/RDA_planner>`_

Code Repository
---------------
`IR-SIM <https://github.com/hanruihua/ir-sim>`_
2 changes: 1 addition & 1 deletion doc/source/usage/configure_behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The demonstration of the `rvo` behavior is shown in the following figure:
- **`accer`:** The acceleration of the object.
- **`factor`:** The factor to adjust the collision penalty.

Full list of behavior parameters can be found in the [YAML Configuration](../get_started/configuration/).
Full list of behavior parameters can be found in the [YAML Configuration](../yaml_config/configuration/).


## Advanced Configuration for Custom Behavior
Expand Down
78 changes: 77 additions & 1 deletion doc/source/usage/configure_dynamic_random_env.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,83 @@ The dynamic, random, and clutter environment is useful to test the navigation an

## Random Obstacles Configuration Parameters

Python script:

```python
import irsim

env = irsim.make()

for i in range(1000):

env.step()
env.render(0.05)

if env.done():
break

env.end()
```

YAML File:

```yaml
world:
height: 50 # the height of the world
width: 50 # the height of the world
control_mode: 'keyboard'

robot:
- kinematics: {name: 'acker'}
shape: {name: 'rectangle', length: 4.6, width: 1.6, wheelbase: 3}
state: [5, 5, 0, 0]
goal: [40, 40, 0]
vel_max: [4, 1]

sensors:
- type: 'lidar2d'
range_min: 0
range_max: 20
angle_range: 3.14
number: 100

plot:
show_trajectory: True

obstacle:

- number: 20
kinematics: {name: 'omni'}
distribution: {name: 'random', range_low: [10, 10, -3.14], range_high: [40, 40, 3.14]}
behavior: {name: 'rvo', wander: True, range_low: [10, 10, -3.14], range_high: [40, 40, 3.14], vxmax: 2, vymax: 2, factor: 3.0}
vel_max: [4, 4]
vel_min: [-4, -4]
shape:
- {name: 'circle', radius: 1.0, random_shape: True}
- {name: 'polygon', random_shape: true, avg_radius_range: [0.5, 2.0], irregularity_range: [0, 0.4], spikeyness_range: [0, 0.4], num_vertices_range: [4, 6]}
```
The demonstration is shown in the following figure:
```{image} gif/random_obstacles.gif
:alt: random_obstacles
:width: 400px
:align: center
```
## Important Parameters Explained
The parameters to generate random obstacles with various shapes are the settings of `behavior`, `distribution`, and `shape` in the `obstacle` section.

- For the `rvo` behavior, set the `wander` to `True` to enable the random movement of the obstacles when they reach the goal position. And the `rvo` behavior is used to avoid the collision among obstacles. `range_low` and `range_high` are the lower and upper bounds of the random distribution of the goal position of the obstacles.

- The `distribution` parameter is used to set the random distribution of the obstacles in a certain area. The `range_low` and `range_high` are the lower and upper bounds of the random distribution of the initial position of the obstacles.

- The `shape` parameter is used to set the random shape of the obstacles by setting the `random_shape` to `True`. For circular obstacles, the `radius` will be randomly generated within `radius_range`. For polygon obstacles, `avg_radius_range`, `irregularity_range`, `num_vertices_range`, and `spikeyness_range` defines which type of polygon will be generated. See [random_generate_polygon](#irsim.lib.algorithm.generation.random_generate_polygon) for details.


The details of the parameters are listed in the [YAML Configuration](../yaml_config/configuration/)

```python
:::{tip}
To generate a convex polygon, you can set `spikeyness_range` to [0, 0] or set `is_convex` to True.
:::
2 changes: 1 addition & 1 deletion doc/source/usage/configure_lidar2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ To configure the 2D LiDAR sensor, the sensor name of `lidar2d` should be defined
- **number**: The number of beams.
- **alpha**: The transparency of the laser beam.

A full list of parameters can be found in the [YAML Configuration](#../get_started/configuration/).
A full list of parameters can be found in the [YAML Configuration](#../yaml_config/configuration/).


## Advanced Configuration with noise
Expand Down
2 changes: 1 addition & 1 deletion doc/source/usage/configure_robots_obstacles.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ The demonstration of the multiple robots and obstacles in the simulation are sho
```

:::{note}
- The `distribution` parameter specifies how the robots and obstacles are distributed within the environment. Options include `'manual'` and `'random'`. Details are provided in the [YAML Configuration](#../get_started/configuration)
- The `distribution` parameter specifies how the robots and obstacles are distributed within the environment. Options include `'manual'` and `'random'`. Details are provided in the [YAML Configuration](#../yaml_config/configuration/)
:::

Binary file added doc/source/usage/gif/random_obstacles.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/source/usage/make_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ world:
## Explanation
The `world` section specifies the properties of the world. The `height` and `width` parameters specify the size of the world. The `step_time` parameter specifies the time step for the simulation. The `sample_time` parameter specifies the time step for rendering and data extraction. The `offset` parameter specifies the offset of the world on the x and y axes. The `control_mode` parameter specifies the control mode of the simulation. The `collision_mode` parameter specifies the collision mode of the simulation. The `obstacle_map` parameter specifies the path of the obstacle map. Details of the parameters can be found in the [YAML Configuration](#../get_started/configuration).
The `world` section specifies the properties of the world. The `height` and `width` parameters specify the size of the world. The `step_time` parameter specifies the time step for the simulation. The `sample_time` parameter specifies the time step for rendering and data extraction. The `offset` parameter specifies the offset of the world on the x and y axes. The `control_mode` parameter specifies the control mode of the simulation. The `collision_mode` parameter specifies the collision mode of the simulation. The `obstacle_map` parameter specifies the path of the obstacle map. Details of the parameters can be found in the [YAML Configuration](#../yaml_config/configuration/).

:::{tip}
The default YAML configuration file is same as the name of python script. Thus, if you create a python script named `test.py`, the default YAML configuration file is `test.yaml`. And you can simply use `irsim.make()` to create the environment. Please place the YAML configuration file in the same directory as the python script.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/usage/save_animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can render the environment by calling the [env.render()](#irsim.env.env_base

## Save the animation

You can save the animation of the simulation as a gif file very easily by setting the `save_ani` to be `True` in the `make()` function:
You can save the animation of the simulation as a gif file very easily by setting the `save_ani` to `True` in the `make()` function:

```python

Expand Down Expand Up @@ -41,7 +41,7 @@ The principle of the animation generation is to save the images of each frame an

## 3D Plot

You can simply set the `projection` parameter to be `3d` in `irsim.make` function to render the 3D plot of the simulation. The example is shown below:
You can simply set the `projection` parameter to `3d` in `irsim.make` function to render the 3D plot of the simulation. The example is shown below:

```python

Expand Down
2 changes: 1 addition & 1 deletion irsim/lib/algorithm/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def random_generate_polygon(
number=1,
center_range=[0, 0, 10, 10],
center_range=[0, 0, 0, 0],
avg_radius_range=[0.1, 1],
irregularity_range=[0, 1],
spikeyness_range=[0, 1],
Expand Down
10 changes: 5 additions & 5 deletions irsim/usage/12dynamic_obstacle/dynamic_obstacle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ obstacle:
shape: {name: 'circle', radius: 1.0} # radius
state: [5, 5, 0]

- shape: {name: 'rectangle', length: 1.5, width: 1.2} # radius
state: [6, 5, 1]
# - shape: {name: 'rectangle', length: 1.5, width: 1.2} # radius
# state: [6, 5, 1]

- shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] } # vertices
state: [0, 0, 0]
unobstructed: True
# - shape: {name: 'linestring', vertices: [[5, 5], [4, 0], [1, 6]] } # vertices
# state: [0, 0, 0]
# unobstructed: True
2 changes: 1 addition & 1 deletion irsim/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def random_point_range(range_low=[0, 0, -pi], range_high=[10, 10, pi]):
if isinstance(range_low, list):
range_low = np.c_[range_low]

if isinstance(range_low, list):
if isinstance(range_high, list):
range_high = np.c_[range_high]

return np.random.uniform(range_low, range_high)
Expand Down
2 changes: 1 addition & 1 deletion irsim/world/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def step(self, velocity=None, **kwargs):
"""

if self.static or self.stop_flag or self.kf is None:
self._velocity = np.zeros_like(velocity)
self._velocity = np.zeros(self.vel_shape)
return self.state
else:
self.pre_process()
Expand Down

0 comments on commit d50ebdb

Please sign in to comment.