Skip to content

Commit

Permalink
doc keyboard control
Browse files Browse the repository at this point in the history
  • Loading branch information
hanruihua committed Dec 22, 2024
1 parent ce66a78 commit edbc7f2
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
82 changes: 81 additions & 1 deletion doc/source/usage/configure_keyboard_control.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,82 @@
Configure keyboard control
=======
==========================

The keyboard control is a manual control method that allows you to control the robot using the keyboard.

## Keyboard Control Configuration Parameters

Please make sure the dependencies are installed before running the simulation with keyboard. The dependencies can be installed using the following command:

```bash
pip install ir-sim[keyboard]
```

To start with the keyboard control, you can simply to specify the `control_mode` parameter in the `world` section as `keyboard`. The example of the keyboard control is shown below:

```python
import irsim

env = irsim.make()

for i in range(1000):

env.step()
env.render(0.05)

if env.done():
break

env.end()
```

```yaml
world:
height: 50
width: 50
control_mode: 'keyboard'
obstacle_map: 'cave.png'
mdownsample: 2

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]
plot:
show_trail: True
traj_color: 'g'
show_trajectory: True
show_goal: False

sensors:
- type: 'lidar2d'
range_min: 0
range_max: 20
angle_range: 3.14
number: 100
alpha: 0.4
```
The demonstration controlled by the keyboard is shown below:
```{image} gif/keyboard.gif
:alt: Select Parameters
:width: 400px
:align: center
```
## Keyboard Control Key Mapping
| Key | Function |
|----------|---------------------------------|
| `w` | Forward |
| `s` | Back Forward |
| `a` | Turn Left |
| `d` | Turn Right |
| `q` | Decrease Linear Velocity |
| `e` | Increase Linear Velocity |
| `z` | Decrease Angular Velocity |
| `c` | Increase Angular Velocity |
| `alt+num`| Change Current Control Robot ID |
| `r` | Reset the Environment |
Binary file added doc/source/usage/gif/keyboard.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit edbc7f2

Please sign in to comment.