Skip to content

Commit

Permalink
Merge pull request #69 from ll7/64-update-readme-svg_map_parser-pedes…
Browse files Browse the repository at this point in the history
…trian

64 update readme svg map parser pedestrian
  • Loading branch information
ll7 authored Oct 21, 2024
2 parents 0299de9 + 6b4228e commit 4ab4db7
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 564 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ python3 examples/demo_offensive.py
python3 examples/demo_defensive.py
```

[Visualization](./docs/SIM_VIEW.md)

### 6. Run StableBaselines Training (Docker)

```sh
Expand All @@ -98,6 +100,9 @@ docker compose build && docker compose run \
### 7. Edit Maps

The preferred way to create maps: [SVG Editor](./docs/SVG_MAP_EDITOR.md)

This Method is deprecated:
```sh
sudo apt-get update && sudo apt-get install -y python3-tk
```
Expand All @@ -114,3 +119,19 @@ python3 -m map_editor
docker-compose build && docker-compose run \
robotsf-cuda python ./scripts/hparam_opt.py
```

### 9. Extension: Pedestrian as Adversarial-Agent

The pedestrian is an adversarial agent who tries to find weak points in the vehicle's policy.

The Environment is built according to gymnasium rules, so that multiple RL algorithms can be used to train the pedestrian.

It is important to know that the pedestrian always spawns near the robot.

![demo_ped](./docs/video/demo_ped.gif)

```sh
python3 examples/demo_pedestrian.py
```

[Visualization](./docs/SIM_VIEW.md)
23 changes: 23 additions & 0 deletions docs/SIM_VIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# robot-sf

## SIM VIEW

### About

The [sim_view.py](../robot_sf/render/sim_view.py) file manages the visualization of the simulation.\
If you want to change the colors or display more information you have to adjust this file.

### Key Events

Multiple key shortcuts are implemented:

- **Arrow keys**: Move camera
- **CTRL + Arrow keys**: Move fast
- **ALT + Arrow keys**: Move slow
- **+**: Scale up
- **-**: Scale down
- **r**: Reset view
- **f**: Focus Robot
- **p**: Focus Pedestrian
- **h**: Display help
- **q**: Display information: none -> robot -> pedestrian if present -> none -> ...
80 changes: 80 additions & 0 deletions docs/SVG_MAP_EDITOR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# robot-sf

## SVG Map Editor

### About

This file explains how to build a map for robot-sf using a svg-editor.
All examples are made with [inkscape](https://inkscape.org/).
![example](./img/inkscape_example.png)

### Setup

These settings should be checked before building a map.

- Use **px** as global unit (File -> Document Properties)

- Use absolute coordinates for your path, marked by the **M**.\
(Edit -> Preferences -> Input/Output -> SVG Output -> Path string format -> Absolute)

*Inkscape version: 1.3.2*

[Further reference](https://github.com/ll7/robot_sf_ll7/issues/40)

### Building the map

Colours can be selected as desired, as the simulation uses its own colour scheme.
However, it is best to remain consistent to make the map easier to understand.

The most important part is setting the label. In Inkscape this can be done by double-clicking the object in the layers-and-objects list on the right side or by right-clicking the object and selecting the object properties.

Use layers to make it clearer.

#### Obstacles

Obstacles should be avoided by the vehicle and the pedestrians.\
Draw them by using the rectangle tool.\
Set the label to **obstacle**

[Obstacle Issue](https://github.com/ll7/robot_sf_ll7/issues/55)

#### Robot

The robot needs a spawn zone to define his starting position and a goal zone he needs to reach to finish the episode.\
Multiple zones can be used.\
Draw them by using the rectangle tool.\
Set the labels to **robot_spawn_zone** and **robot_goal_zone**

The robot path defines the route the robot takes, while reaching the goal zone.\
Use the pen tool for this and perform multiple left clicks to set waypoints along the path.\
The path should not start or end inside the spawn/goal zone, but just before it.\
Set the label to **robot_route_\<spawn\>_\<goal\>**

(e.g. robot_route_1_0 -> Using Spawn 1 and Goal 0.\
The zone numbers are counted from bottom to top in the list on the right-hand side)

#### NPC Pedestrians

The Pedestrians also need a spawn/goal zone. If they reach the goal they will spawn again at the start\
Set the labels to **ped_spawn_zone** and **ped_goal_zone**

For the path you don't need to set specific waypoints, just make sure the path doesn't collide with an obstacle.\
Set the label to **ped_route_\<spawn\>_\<goal\>**

### Colours

Colours used in the example map:

- obstacle: #000000
- robot_spawn_zone: #ffdf00
- robot_goal_zone: #ff6c00
- robot_route: #0300d5 and #0078d5
- ped_spawn_zone: #23ff00
- ped_goal_zone: #107400
- ped_route: #c40202

The colours for the simulation can be found here: [sim_view.py](../robot_sf/render/sim_view.py)

### New Features

If you want to implement new features: [svg_map_parser.py](../robot_sf/nav/svg_map_parser.py)
Binary file added docs/img/inkscape_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/video/demo_ped.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 0 additions & 129 deletions maps/svg_maps/03_mid_object.svg

This file was deleted.

Loading

0 comments on commit 4ab4db7

Please sign in to comment.