Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation rehaul #120

Open
wants to merge 25 commits into
base: v1.0.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add docs for dynamics, rendering, custom example
Berducci, Luigi committed Apr 5, 2024
commit 685282589ca2a077c8bcde2bbca0cca300cdfb94
12 changes: 6 additions & 6 deletions docs/src/usage/customized_usage.rst
Original file line number Diff line number Diff line change
@@ -7,10 +7,6 @@ For a basic usage example, see :ref:`basic_usage`.

The environment also provides options for customization.

Custom Map
------------
Work in progress on how to add a custom map.

Random Track Generator
-----------------------

@@ -35,6 +31,10 @@ For example, to generate 3 random maps and store them in the directory `custom_m
python examples/random_trackgen.py --seed 42 --n-maps 3 --outdir custom_maps


.. image:: ../../../../src/assets/random_trackgen.png
.. image:: /assets/random_trackgen.png
:width: 800
:align: center
:align: center

Custom Map
------------
Work in progress on how to add a custom map.
50 changes: 47 additions & 3 deletions docs/src/usage/dynamics.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
_dynamics:
.. _dynamics:

Dynamics
Vehicle Dynamics
=====================

Work in progress.
The vehicle dynamics are modeled using a single-track model, as in [AlKM17]_.

We support two vehicle dynamics models:
- Kinematic Single-Track Model (`ks`): Simpler model that considers only the kinematics of the vehicle, i.e., the position, orientation, and velocity, ignoring the forces that act on the vehicle.
- Single-Track Model (`st`): More complex model that considers the forces that act on the vehicle, such as the tire forces.

Despite the fact that the single-track model is a simplified model, it is able to capture the
tire slip effects on the slip angle, which is important for accurate simulation at the physical
limits of the vehicle.


Dynamics Configuration
----------------------
The environment comes with a *default* dynamics model, which can be changed using the environment configuration.

The dynamics model can be configured at the environment creation:

.. code:: python

import gymnasium as gym

env = gym.make(
"f110_gym:f110-v0",
config={
"model": "ks"
})
obs, infos = env.reset()

or after the environment creation:

.. code:: python

import gymnasium as gym

env = gym.make("f110_gym:f110-v0")
env.configure({
"model": "ks",
})
obs, infos = env.reset()



.. rubric:: References

.. [AlKM17] Althoff, M.; Koschi, M.; Manzinger, S..: CommonRoad: Composable benchmarks for motion planning on roads. In: 2017 IEEE Intelligent Vehicles Symposium (IV). IEEE, 2017.
64 changes: 63 additions & 1 deletion docs/src/usage/rendering.rst
Original file line number Diff line number Diff line change
@@ -3,4 +3,66 @@
Rendering
=====================

Work in progress.
The environment rendering is done with `pygame`.

As by default in gymnasium environments,
there are multiple rendering modes available:

- `human`: for real-time rendering with `pygame`;

- `rgb_array`: for collecting the current frame as a numpy array;

- `rgb_array_list`: for collecting multiple frames into a list. This is useful to generate smooth videos when using frame-skipping.

Additionally, for fast rendering and debugging, we add:

- `human-fast`: faster-than-real-time rendering. Up to 10x faster based on the host machine.

Rendering Configuration
------------------------

The user can customize the rendering mode with the `rendering_mode` parameter in the environment configuration.

.. code:: python

import gymnasium as gym

env = gym.make(
"f110_gym:f110-v0",
render_mode="human-fast",
)
obs, infos = env.reset()
done = False

while not done:
action = env.action_space.sample()
obs, reward, done, infos = env.step(action)
env.render()


.. note::
When rendering in `human` mode,
the user can interact to change the agent to focus on by pressing the left/right/middle mouse button,
as described by the instructions diplayed in the top of the window.

Parameter Configuration
-----------------------

The user can customize the rendering parameters in the `f1tenth_gym.rendering/rendering.yaml` file:

- `window_size`: width and height of the window in pixels

- `focus_on`: agent id to focus on (e.g., `agent_0`) or `null` for map view

- `zoom_in_factor`: zoom in factor. 1.0 is no zoom, >1.0 is zoom in, <1.0 is zoom out

- `show_wheels`: it toggles the visualization of the vehicle wheels

- `car_tickness`: thickness of the car border

- `show_info`: it toggles the visualization of the instruction text

- `vehicle_palette`: cyclic list of colors for the vehicles (e.g., first agent takes the first color, second agent takes the second color, etc. and then it starts again from the first color)