Skip to content

AutoRally Gazebo Simulation

Brian Goldfain edited this page Oct 31, 2018 · 8 revisions

Introduction

The AutoRally simulation environment is built using Gazebo. All of the configuration and code run in simulation is broken up into two packages: autorally_gazebo and autorally_description.

autorally_gazebo

The directory nodes contains the code run only during simulation.

autorally_controller.py

Interfaces with the controllers that directly control actuation in gazebo.

ground_truth_republisher.py

Takes in the gazebo model states and publishes a ground truth state.

autorally_description

Contains most of the configuration files for gazebo. The urdf folder contains the 4 important model folders

models

Contains the sdf configuration for the custom models used in simulation.

worlds

Contains all of the .world files that represent the different gazebo worlds. World files are made up of models that are defined in models folder.

cad

Contains the actual .dae files that are used in the model folder

textures

Contains the images that are used to generate custom textures that are used in materials for the custom models

Running The Simulation

General Notes

Instead of running the state estimator a ground truth state is published by the simulation environment by default. The pose is relative to /odom and is publsihed on the topic /ground_truth/state

Running The State Estimator

alt text By default the state estimator is not launched by the simulation environment. If you would like to use the state estimator in simulation launch it before moving the vehicle.

Tracks

The repository has two different track that can be run

Marietta Track

There are two versions of the marietta track, one with just the track and one with other objects around the track.

TODO: include track image

How to launch the world without a vehicle

roslaunch autorally_gazebo autoRallyTrackWorld.launch

How to launch the world with a single platform

roslaunch autorally_gazebo autoRallyTrackGazeboSim.launch

How to change what world is used

Go into the autoRallyTrackWorld.launch file and change the line

<arg name="world_name" default="model://urdf/worlds/populated_marietta.world"/>

to

<arg name="world_name" default="model://urdf/worlds/empty_sky_AR.world"/>

CCRF Track

TODO: include track image

alt text The ccrf track boundary has collisions disabled.

How to launch the world without a vehicle

roslaunch autorally_gazebo autoRallyTrackCCRFWorld.launch

How to launch the world with a single platform

roslaunch autorally_gazebo autoRallyTrackCCRFGazeboSim.launch

Multiple Vehicles

Default Launch

Running code with multiple vehicles in simulation requires complete namespace separation of topics published and subscribed to by gazebo along with an instance of each node for each vehicle. This is because, by design, each physical AutoRally platform is designed to run as a self-contained ROS system with its own master. The multiple cars launch file pushes each vehicle into its own namespace: /alpha/* and /beta/* with the option of adding the same prefix to both vehicles). By default the following nodes are spawned from the autoRallyTrackMultipleCarsGazeboSim.launch file. An instance should exist for each vehicle.

  • WheelOdometry
  • autoRally_state_publisher
  • autorally_controller
  • controller_spawner
  • state_estimator
  • spawn_platform

To launch the world

roslaunch autorally_gazebo autoRallyTrackMultipleCarsGazeboSim.launch

You should see a lot of output and the gazebo gui will appear with both vehicles launched in the default AutoRally world. If there are any of the nodes fail to launch try relaunching a couple times before further investigation. If a vehicle chassis is right on top of the wheels it means that your controller is not functioning properly, try relaunching to resolve this issue.

At this point the normal AutoRally control topics and sensor topic with the correct namespace prefix should exist for each vehicle.

CAUTION: The state estimator is launched by default for each vehicle, but has not converge. Ensure convergence before starting any code

Working With Controllers

Controllers and other code must also be pushed into the namespace of the vehicle they will control:

<launch>
  <arg name="prefix" default="alpha"/>
  <group ns="$(arg prefix)">
    <!-- rest of launch file -->
  </group>
</launch>

Now you can append the following to your roslaunch command to change which car this controller is running on.

prefix:="VEHICLE_NAME"

If there are any remap commands in the launch file ensure that they do not have a preceding slash otherwise the namepsace will prevent the remap from happening successfully. For example

<!-- correct -->
<remap from="waypointFollower/Speeds" to="wheelSpeeds"/>

<!-- incorrect -->
<remap from="/waypointFollower/Speeds" to="/wheelSpeeds"/>

Launching More Than 2 Vehicles

CAUTION: Each additional vehicle significantly increases load and decreases the real time factor.

In order to launch more than 2 vehicles go into the autoRallyTrackMultipleCarsGazeboSim.launch file and add in as many copies of the following code but replace CAR_NAME with your desired name. Each car must have a unique name.

<group ns="$(arg namespace)/CAR_NAME">
    <include file="$(find autorally_gazebo)/launch/singlePlatform.launch">
      <arg name="namespace" value="$(arg namespace)/CAR_NAME" />
    </include>
  </group>

You should change the initial X and Y locations of the vehicle (otherwise they will spawn on top of each other). To do that you would pass in the arguments x, y, z, roll, pitch, yaw. For example this will spawn the vehicle at X = 0.6 and Y = -9.

<group ns="$(arg namespace)/CAR_NAME">
    <include file="$(find autorally_gazebo)/launch/singlePlatform.launch">
      <arg name="namespace" value="$(arg namespace)/CAR_NAME" />
      <arg name="x" value="0.6" />
      <arg name="y" value="-9" />
    </include>
  </group>

Parameters For singlePlatform.launch

'vehicle_namespace` the namespace and the vehicle specific prefix

x: initial X location of the robot in gazebo

y: initial Y location of the robot in gazebo

z: initial Z location of the robot in gazebo

roll: initial roll location of the robot in gazebo

pitch: initial pitch location of the robot in gazebo

yaw: initial yaw location of the robot in gazebo

Configuration Of Gazebo

URDF Prefix

AutoRally uses multiple third party Gazebo plugins configured in the URDF file to convert topics into actuation and Gazebo sensors into topics. These all require a namespace to be configured for each vehicle in the URDF file. This was achieved by using a parameter called prefix that is passed into xacro when the URDF file is created. This is done in the singlePlatform.launch file by

<param name="robot_description" command="$(find xacro)/xacro $(find autorally_description)/urdf/autoRallyPlatform.urdf.xacro prefix:=$(arg namespace)"/>

Where the arg namespace is passed in as an argument to the launch file. The corresponding property show up in the xacro file as

<xacro:arg name="prefix" default=""/>

and is used when setting up the plugins. For example the GPS configuration contains the line

<robotNamespace>$(arg prefix)</robotNamespace>

This is used internally in the plugin in order to give the correct prefix to the topic name.