# Working with the Ouster OS1

## Documentation

Detailed information about the ouster-ros package can be found on [Github](https://github.com/ouster-lidar/ouster-ros).

## Configuration

The ouster has to be connected to the jetson board via the usb-ethernet connector. The resulting ethernet connection `(eth1[00:3B:A3:00:6E])` has to be set to `Link-Local Only (IPv4)`.

The Ouster LiDAR can either be connected to the robot or to a personal laptop for testing. The Ouster package offers `.launch` files for running the node, recording from the sensor to a `.bag` file and replaying from a `.bag` file.

## Run

To launch all required OS1 ROS-nodes, the `sensor.launch` file can be launched by providing it the `sensor_hostname`, which consists of `os-<SERIAL_NUMBER>.local`

`roslaunch ouster_ros sensor.launch sensor_hostname:=os-122222003163.local` `viz:=false`

* `sensor_hostname` configures the node to the hardware
* `viz:=false` prevents the launch file from launching rviz on the robot

### Extract metadata

The recording of rosbags requires metadata about the sensor configuration. These can be extracted with the `service /ouster/get_config` which outputs the current metadata to the console. This string can then be saved to the `metadata.json` file.

## Record

The launch file for recording to rosbags requires both a absolute path to the `metadata.json` file and a absolute path to the generated `*.bag` file.

### **Local:**

{% code overflow="wrap" lineNumbers="true" %}

```bash
roslaunch ouster_ros record.launch sensor_hostname:=os-122222003163.local metadata:=/home/juri/ROSWorkspace/BA/src/ouster-ros/config/metadata.json bag_file:=/home/juri/ROSWorkspace/BA/bags/os1_test.bag
```

{% endcode %}

Change the `metadata.json` and the `os1_test.bag` file accordingly.

### **On robot:**

{% code overflow="wrap" lineNumbers="true" %}

```bash
roslaunch ouster_ros record.launch sensor_hostname:=os-122222003163.local metadata:=/home/unitree/catkin_ws/src/ouster-ros/config/metadata.json bag_file:=/home/unitree/catkin_ws/bags/os1_test.bag viz:=false
```

{% endcode %}

Change the `metadata.json` and the `os1_test.bag` file accordingly.

Note the change in path to `/home/`**`unitree/catkin_ws`** instead of `home/juri/ROSWorkspace` and the flag **`viz:=false`**

## Replay .bag recording

The mode to replay rosbags requires both the absolute path to the `metadata.json` and `*.bag` files. Since the replay is independent of live lidar measurements, the `sensor_hostname` doesn’t have to provided.

### **Local:**

{% code overflow="wrap" lineNumbers="true" %}

```bash
roslaunch ouster_ros replay.launch metadata:=/home/juri/ROSWorkspace/BA/src/ouster-ros/config/metadata.json bag_file:=/home/juri/ROSWorkspace/BA/bags/os1_test.bag
```

{% endcode %}

Change the `metadata.json` and the `os1_test.bag` file accordingly.

### **On robot:**

{% code overflow="wrap" lineNumbers="true" %}

```
roslaunch ouster_ros replay.launch metadata:=/home/unitree/catkin_ws/src/ouster-ros/config/metadata.json bag_file:=/home/unitree/catkin_ws/bags/os1_test.bag viz:=false
```

{% endcode %}

Change the `metadata.json` and the `os1_test.bag` file accordingly.

Note the change in path to `/home/`**`unitree/catkin_ws`** instead of `home/juri/ROSWorkspace` and the flag **`viz:=false`**
