# Motion Planning LiDAR A1M8

### RPLidar

These instructions are for an SLAMTEC RPLIDAR A1M8. This unit is used on the TurtleBot4 and can be added to the Unitree Go2.

### Architecture

The collision avoidance and path checking code pre-computes 9 different paths, 4 to the left, one straight ahead, 4 to the right, and one to the back. For each of the 9 possible paths, the code checks whether the path approaches any detected object to within `half_width_robot`. If not, the path is considered to be a valid choice and the motion system can execute that path.

### Assumptions

The code assumes that any unpredictable barriers (e.g. humans crossing the path of the robot) will be avoided using separate code within the `action` driver, such as by issuing a "STOP" command when an object is detected in front of the robot.

### Setup

Run `rptest.py` (located in `system_hw_test`) to determine the `sensor_mounting_angle` and the `angles_blanked`. These values depend on how you mounted the sensor and the radial position of any fixed obstructions, such as mounting brackets.

```py
"""
Robot and sensor configuration
"""
half_width_robot = 0.20  # the width of the robot is 40 cm
relevant_distance_max = 1.1  # meters
relevant_distance_min = 0.16 # meters
sensor_mounting_angle = 180.0  # corrects for how sensor is mounted
angles_blanked = [[-180.0, -160.0], [32.0, 46.6]]
```

#### How to determine the sensor\_mounting\_angle and the angles\_blanked

* `sensor_mounting_angle`: The `sensor_mounting_angle` refers to the angle between the LIDAR sensor's scanning plane and the horizontal plane of your robot or platform. The `sensor_mounting_angle` can be read physically from the LIDAR. Refer to the following image for guidance:

![sensor\_mounting\_angle](/files/VVfDYp0vnyCwdP4dPruX)

* `angles_blanked`: The `angles_blanked` array can be used to prevent fixed obstructions in the field of view of the LIDAR from producing erroneous object avoidance messages.

### Unitree RPLidar

Determine the serial port the sensor is using:

```bash
ls /dev/tty.*
ls /dev/cu.*
```

Then, run

```bash
uv run rptest.py --serial /dev/cu.usbserial-0001
```

### TurtleBot4

By default, the TurtleBot4 is configured to use the RPLidar A1M8. You can verify this by running:

```bash
ls -l /dev/RPLIDAR
```

To see the raw LIDAR data, provide the robot's URID (such as `OM742d35Cc6634`) and run:

```bash
uv run rptest.py --URID OM123435Cc1234
```

Typically, this command would be executed on your laptop, connected to the TurtleBot4 via Zenoh.

### Using the RPLidar A1M8 in OM1

Configure the `.json5` as needed:

```python
"""
Robot and sensor configuration
"""
{
  "type": "RPLidar",
  "config": {
    "use_zenoh": true, # or false, if you are using serial to connect directly to the LIDAR
    "serial_port": "/dev/cu.usbserial-0001",
    "half_width_robot": 0.21, # the width of the robot is 40 cm
    "relevant_distance_max": 1.1, # meters
    "sensor_mounting_angle": 180.0, # corrects for how sensor is mounted relative to robot
    "angles_blanked": [[-180.0, -160.0], [32.0, 46.6]]
  }
}
```


---

# Agent Instructions: 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://docs.openmind.com/robotics/motion_planning_lidara1m8.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.
