> For the complete documentation index, see [llms.txt](https://roar.gitbook.io/roar_py_rl-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roar.gitbook.io/roar_py_rl-documentation/environment-details/sim-environments/observation-space.md).

# Observation Space

## General

The observation space provided to the agent involves

1. All sensor attached to the vehicle instance
   1. Basically the `RoarRLSimEnv` will take in an instance of `RoarPyActor` and the observation space of the environment will be a superset of that `RoarPyActor`'s `get_gym_observation_spec()`&#x20;
   2. In Roar's internal RL code, we added the following sensors to the actor
      1. local coordinate velocimeter
      2. gyroscope (angular velocity sensor)
2. Information of waypoints relative to the current position of the vehicle.
   1. We will discuss this more in the next section

## Waypoint Information Observation

Instead of inputting an entire occupancy map into the network, we directly feed numerical information about waypoints near the vehicle as the observation provided to the agent. This is how it works:

1. During initialization of the environment we specify an array of relative distances (that is an array of floating point values) we want to trace for waypoint information observations
2. Then in each step we perform trace one by one, and storing them inside `waypoints_information` key in the final observation dict.

How we trace those relative distances is described below

Remember in the [Reward Function](/roar_py_rl-documentation/environment-details/sim-environments/reward-function.md) page we described how we would treat the list of waypoints provided to us as a circular path and trace in each step the closest point $$\hat{\vec{p}}\_v$$ on the path relative to the position of the vehicle $$\vec{p}\_v$$.

Basically for each relative distance $$d$$, we trace along the circular path forward $$d$$ meters and find an interpolated waypoint $$\vec{w}$$, which contains the global position of the interpolated waypoint, the rotation of that interpolated waypoint, and the road width of that waypoint. Then we concatenate:

1. Relative 2d(x,y) position of the waypoint in the vehicle's local coordinate
2. Yaw of that waypoint in the vehicle's local coordinate
3. Road width of the interpolated waypoint

into a vector as the observation. We repeat this for every relative distances defines during environment initialization and stack all vectors into a matrix. Then that matrix is fed into the agent as a way to understand the road information around the vehicle.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://roar.gitbook.io/roar_py_rl-documentation/environment-details/sim-environments/observation-space.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
