Skip to content

Commit

Permalink
add docs for actions/observations,
Browse files Browse the repository at this point in the history
refactor basic usage and rename stuff
  • Loading branch information
luigiberducci committed Mar 22, 2024
1 parent 350bace commit 7f42364
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 7 deletions.
42 changes: 41 additions & 1 deletion docs/src/usage/actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,44 @@
Actions
=====================

Work in progress on actions.
Several **types of actions** for longitudinal and lateral control are available in every track.

Lateral actions:

- `steering_angle`: the action sets the target steering angle of the vehicle in `rad`, which is then converted to steering speed.

- `steering_speed`: the action directly sets the steering speed of the vehicle in `rad/s`.

Longitudinal actions:

- `speed`: the action sets the target speed of the vehicle in `m/s`, which is then converted to acceleration.

- `accl`: the action directly sets the vehicle acceleration in `m/s^2`.

**Note:** All the agents will have the same observation type.

Actions Configuration
---------------------
The environment comes with a *default* action type, which can be changed using the environment configuration.

Actions can be configured at the environment creation:

.. code:: python
import gymnasium as gym
env = gym.make(
"f110_gym:f110-v0",
config={
"control_input": ["accl", "steering_speed"]
})
obs, infos = env.reset()
or after the environment creation:

.. code:: python
import gymnasium as gym
env = gym.make("f110_gym:f110-v0")
env.configure({"control_input": ["speed", "steering_angle"]})
obs, infos = env.reset()
2 changes: 1 addition & 1 deletion docs/src/usage/basic_usage.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _basic_usage:

Basic Usage Example
Basic example
=====================

The environment can work out of the box without too much customization.
Expand Down
39 changes: 35 additions & 4 deletions docs/src/usage/index.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
Usage
Getting Started
==============

Making an environment
----------------------

This is a quick example of how to make a simple environment:

.. code:: python
import gymnasium as gym
env = gym.make("f110_gym:f110-v0", render_mode="human")
obs, infos = env.reset()
while not done:
# sample random action
actions = env.action_space.sample()
# step simulation
obs, step_reward, done, info = racecar_env.step(actions)
env.render()
Configuration
-------------

Here is the list of configurable options for the environment:
- Track
- Observations
- Actions
- Rewards
- Dynamics
- Rendering
- Extra tools

.. toctree::
:caption: Usage
:maxdepth: 2
:caption: Getting started
:maxdepth: 1

basic_usage
actions
observations
actions
rewards
dynamics
customized_usage
Expand Down
43 changes: 42 additions & 1 deletion docs/src/usage/observations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,45 @@
Observations
=====================

Work in progress.
For the environment, several **types of observations** can be used.

- `original` : Original observation from the old simulator. This is default for compatibility.
- `kinematic_state` : Kinematic state observation, which includes `pose_x, pose_y, delta, linear_vel_x, pose_theta`.
- `dynamic_state` : Dynamic state observation, which includes `pose_x, pose_y, delta, linear_vel_x, pose_theta, ang_vel_z, beta`.
- `features` : Customisable observation, which includes all the features defined in the `features` argument.

**Note:** All the agents will have the same observation type.

Observations Configuration
--------------------------
Each environment comes with a *default* observation,
which can be changed or customised using environment configurations.

Observations can be configured at the environment creation:

.. code:: python
import gymnasium as gym
env = gym.make(
"f110_gym:f110-v0",
config={
"observation_config": {
"type": "features",
"features": ["linear_vel_x", "scan"]
},
})
obs, infos = env.reset()
or after the environment creation:

.. code:: python
import gymnasium as gym
env = gym.make("f110_gym:f110-v0")
env.configure({
"observation_config": {
"type": "features",
"features": ["linear_vel_x", "scan"]}
})
obs, infos = env.reset()

0 comments on commit 7f42364

Please sign in to comment.