-
Notifications
You must be signed in to change notification settings - Fork 229
Creating a new AutoRally track
The AutoRally gazebo simulator comes with 2 tracks that represent a simulated version of the marietta street track and CCRF track. These are two real tracks that exist in the world, but it is very easy to create a new simulated track.
You will be working in two packages, autorally_description and autorally_gazebo.
-
Create a blending texture. go to autorally_description/urdf/textures/* you will see two textures blended_texture_marietta.png or blended_texture_ccrf.png. This file uses the alpha of an image to indicate how two textures should be blended together. The two tracks already made use this feature to distinguish between grass off of the track and dirt on the track, but you can blend any two textures as you see fit. The clear section of the image represents the dirt (or texture 1) and the colored in is grass (or texture 2). The actual color of the image does not matter for this step. Create a image for your own track with its own name and place it in the textures folder. Remember that your texture will be stretched across the entire ground plane in gazebo later so make sure it is a good resolution for be scaled that high.
-
Create a gazebo material for the texture in autorally_description/urdf/gazebo.material. Copy the below text at the bottom and fill in the image names and material name.
material Gazebo/Texture_YOUR_TRACK_NAME
{
technique
{
pass
{
ambient 0.1 0.1 0.1 0.1
diffuse 0.8 0.8 0.8 1.0
specular 0.01 0.01 0.01 1.0 2.0
texture_unit
{
texture textures/TRACK_TEXTURE.jpg
filtering trilinear
scale .01 .01
}
texture_unit
{
texture textures/YOUR_BLENDED_TEXTURE_FROM_STEP_1.png
colour_op alpha_blend
}
texture_unit
{
texture textures/NOT_TRACK_TEXTURE.jpg
colour_op_ex blend_current_alpha src_texture src_current
alpha_op_ex source1 src_manual src_current 1.0
scale .01 .01
}
}
}
}
-
Creating the track boundary in CAD. Use any CAD software (I have used inventor) and import the texture you created in step 1 and properly scale it to the actual size of the track. Using the line/curve tool trace the boundary of your track. Then use the sweep tool to fit a 6 in cylinder to the line you traced. Export this as a .dae file (or .stl and use meshlab to convert to a .dae).
-
Creating a gazebo model of the boundary. Create a folder in autorally_description/urdf/models of your track name. You need to create two files in there. A model.sdf and model.config
model.sdf
<?xml version="1.0"?>
<sdf version="1.5">
<model name="track">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<mesh>
<uri>model://urdf/cad/YOUR_TRACK_CAD_FILE.dae</uri>
<scale>1.0 1.0 1.0</scale>
</mesh>
</geometry>
<surface>
<friction>
<ode>
<mu>100</mu>
<mu2>50</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<cast_shadows>false</cast_shadows>
<geometry>
<mesh>
<uri>model://urdf/cad/YOUR_TRACK_CAD_FILE.dae</uri>
<scale>1.0 1.0 1.0</scale>
</mesh>
</geometry>
<material>
<script>
<uri>model://urdf/gazebo.material</uri>
<name>Gazebo/Black</name>
</script>
</material>
</visual>
</link>
</model>
</sdf>
model.config
<?xml version="1.0"?>
<model>
<name>TRACK_NAME</name>
<version>1.0</version>
<sdf version="1.5">model.sdf</sdf>
<author>
<name>NAME</name>
<email>EMAIL</email>
</author>
<description>
TODO
</description>
</model>
- Creating a gazebo model for the track plane. in autorally_description/urdf/models create a folder with your track name prepended with Blended. You again need to create two files model.sdf and model.config.
<?xml version="1.0"?>
<sdf version="1.5">
<model name="NAME">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>90 90</size>
</plane>
</geometry>
<surface>
<friction>
<ode>
<mu>100</mu>
<mu2>50</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<cast_shadows>false</cast_shadows>
<geometry>
<plane>
<normal>0 0 1</normal>
<size>90 90</size> <!-- the size of your texture -->
</plane>
</geometry>
<material>
<script>
<uri>model://urdf/gazebo.material</uri>
<name>Gazebo/YOUR_TEXTURE_NAME</name>
</script>
</material>
</visual>
</link>
</model>
</sdf>
model.config
<?xml version="1.0"?>
<model>
<name>TODO NAME</name>
<version>1.0</version>
<sdf version="1.5">model.sdf</sdf>
<author>
<name>NAME</name>
<email>EMAIL</email>
</author>
<description>
TODO
</description>
</model>
- Create a .world file. In autorally_description/urdf/worlds create a .world file with your track name. This is where to add other things as well, look at the populated_marietta for how to do that. You might have to play around with orientation and centering of your CAD models to get it right.
<?xml version="1.0" ?>
<sdf version="1.6">
<world name="default">
<scene>
<sky>
<clouds>
<speed>12</speed>
</clouds>
</sky>
<ambient>1.0 1.0 1.0 1.0</ambient>
<shadows>true</shadows>
</scene>
<!-- A global light source -->
<include>
<uri>model://urdf/models/sun</uri>
</include>
<!-- A ground plane -->
<include>
<name>blended_plane</name>
<uri>model://urdf/models/YOUR_TRACK_MODEL_NAME</uri>
<pose>-22.5 -18.5 0 0 0 0</pose>
</include>
<include>
<name>blended_track</name>
<uri>model://urdf/models/YOUR_TRACK_BARRIER_CAD_MODEL_NAME</uri>
<pose>-22.5 -18.5 0.0762 0 0 0</pose>
</include>
</world>
</sdf>
- You can now change the autoRallyTrackGazeboSim.launch file to use your world and things should just work.