Ouster OS-1 ROS Gazebo Simulation in MCity and Citysim

In this post, we will adapt OSRF’s car_demo and citysim packages to simulate a Toyota Prius driving around a simulated city environment with an OS-1-64 lidar sensor.

During ROSCon 2017, Ian Chen and Carlos Aguero gave a presentation entitled, “Vehicle and city simulation with Gazebo and ROS” (slides here). They developed a URDF model of the Prius configured with various sensors operating on both MCity and Sonoma Raceway in Gazebo. This was in support of the Toyota Prius Challenge.

This was followed up by a blog post on the OSRF website publicizing the work and making the car_demo package available.

Following that release, a blog post was published describing citysim. This is a more detailed simulation world consisting of pedestrians, other vehicles, and multiple city blocks. This simulation also leveraged the Prius vehicle model. A quick intro video was developed:

System Installation

There are several installation steps required to get the packages to properly build. These instructions assume the user is running Ubuntu 18.04 with ROS Melodic and Gazebo 9. Later on in this post, the process of using a docker container to run these demos is described which is compatible with any Linux workstation.

First, we will install the car_demo package so that we can validate the Prius model and view the model in MCity. Depending on your set-up you may need to install the fake-localization package:

$ sudo apt install ros-melodic-fake-localization

Additionally, the ignition-math and ignition-msgs libraries may need to be installed:

$ hg clone https://bitbucket.org/ignitionrobotics/ign-math /tmp/ign-math
$ cd /tmp/ign-math/
$ hg pull && hg update ign-math3
$ mkdir build
$ cd build
$ cmake ..
$ make -j4
$ sudo make install

$ hg clone https://bitbucket.org/ignitionrobotics/ign-msgs /tmp/ign-msgs
$ cd /tmp/ign-msgs
$ hg pull && hg update ign-msgs0
$ mkdir build
$ cd build
$ cmake ..
$ make -j4
$ sudo make install

To get the OS-1 sensor model, you need to clone a forked version of the ouster_example package.

At this point, you should be able to clone the forked version of the car_demo package and compile it using catkin_make.

Lastly, it’s necessary to copy the Gazebo model files from the package to the default Gazebo models directory:

$ sudo mv /path/to/catkin_ws/src/car_demo/car_demo/models ~/.gazebo/models

The demos assume that the user has a joystick available that can publish joy ROS messages. The joystick_translator node interprets these messages and sends commands to the simulated Prius model. For more information setting up a joystick with ROS, see this guide.

Package Modifications and Simulation

There were several changes made to the original car_demo and citysim packages in order to integrate the OS-1-64 model. The OS-1 model is referenced from the ouster_description package in the ouster_example package. A detailed overview of the development of the OS-1 lidar sensor ROS Gazebo model can be viewed here.

The primary changes occurred in the prius_os1.urdf file. The OS-1-64 was integrated and placed on the roof of the Prius. The lidar and radars from the original file were removed but the cameras were kept. The demo_os1.rviz RViz configuration file was also updated to be compatible with the new sensor layout. The mcity.world  file wasn’t modified but a new launch file, demo_os1_mcity.launch was created to reference the updated prius_os1.urdf and demo_os1.rviz files.

The demo can be launched by running:

$ roslaunch car_demo demo_os1_mcity.launch

If the joystick is properly configured, these inputs will control the simulated Prius:

– The right stick controls throttle and brake
– The left stick controls steering
– Y puts the car into DRIVE
– A puts the car into REVERSE
– B puts the car into NEUTRAL

An example image of the simulation is depicted below:

OS-1 ROS Gazebo Simulation with Prius in MCity
OS-1 ROS Gazebo Simulation with Prius in MCity

The citysim world requirements are included in the forked car_demo package. The demo_os1_simcity.launch file is used to launch a simulation with the Prius in the citysim world. To launch a simulation, run:

$ roslaunch car_demo demo_os1_simcity.launch

An example image of the simulation is depicted below:

OS-1 ROS Gazebo Simulation with Prius in citysim
OS-1 ROS Gazebo (top) and RViz (bottom) Simulation with Prius in citysim

Running the Simulation from a Docker Container

Docker is a tool designed to make it easier to create, deploy, and run applications in a loosely isolated environment called a container. Developers can package up an application with all of the libraries and other dependencies and deploy the application as a single package. For this use case, it ensures that the OS-1 integrated car_demo and citysim demos can be run locally without having to maintain the dependencies.

In order to use Docker, it first needs to be installed. The installation script, install-docker.sh, is located in the repository. Run the script:

$ ./install-docker.sh

This script will install Nvidia-docker if you have Nvidia drivers on the host machine.

Verify the installation succeeded by checking the Docker service:

$ sudo systemctl status docker

The output will look something like this:

Docker System Service Status
Docker System Service Status

You can also check the Docker version:
$ docker -v

Lastly, add the current user to the Docker group:
$ sudo groupadd docker
$ sudo usermod -aG docker $USER

Log out and back in and docker should be installed and configured.

To run the demos via Docker container, navigate to the car_demo package location and run the run-docker.sh script:
$ sudo chmod 766 run-docker
$ ./run-docker.sh

Once you are running the Docker container, ensure the catkin workspace is sourced:

$ source ~/catkin_ws/devel/setup.bash

Use the same roslaunch commands as before to run the demos.

For the Mcity demo:
$ roslaunch car_demo demo_os1_mcity.launch

For the citysim demo:
$ roslaunch car_demo demo_os1_simcity.launch

Leave a Reply

Your email address will not be published.