-
Notifications
You must be signed in to change notification settings - Fork 229
AutoRally Gazebo Simulation
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
.
The directory nodes contains the code run only during simulation.
Interfaces with the controllers that directly control actuation in gazebo.
Takes in the gazebo model states and publishes a ground truth state.
Contains most of the configuration files for gazebo. The urdf folder contains the 4 important model folders
Contains the sdf configuration for the custom models used in simulation.
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.
Contains the actual .dae files that are used in the model folder
Contains the images that are used to generate custom textures that are used in materials for the custom models
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
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.
The repository has two different track that can be run
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
roslaunch autorally_gazebo autoRallyTrackWorld.launch
roslaunch autorally_gazebo autoRallyTrackGazeboSim.launch
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"/>
TODO: include track image
The ccrf track boundary has collisions disabled.
roslaunch autorally_gazebo autoRallyTrackCCRFWorld.launch
roslaunch autorally_gazebo autoRallyTrackCCRFGazeboSim.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
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"/>
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>
'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
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.