Skip to content

vrx_classic_create_docks_tutorial

M1chaelM edited this page May 5, 2023 · 1 revision

Overview

In this tutorial we will demonstrate how to create new docks with your own dimensions and shapes.

The vrx_gazebo ROS package contains multiple models related to docks:

  • dock_block: The basic floating building block. More complex docks are created by combining these blocks together.
  • dock_block_2x2: A 2x2 grid of dock blocks.
  • dock_block_3x3: A 3x3 grid of dock blocks.
  • dock_block_4x4: A 4x4 grid of dock blocks.
  • dock_2016_base: A dock similar to the one used during the 2016 RobotX competition with an m shape (three bays).
  • dock_2016: The complete 2016 floating dock with the three placards and symbols.
  • dock_2018_base: A dock similar to the one used during the 2018 RobotX competition with an H shape (two bays).
  • dock_2018: The complete 2018 floating dock with the two placards and symbols.

How to create a new dock

The docks are created using Embedded Ruby templates. This way, we can easily automate the creation of custom docks. Follow the next steps to create your own dock.

First, create a new directory for your dock (e.g.: my_dock_base):

#!bash

mkdir -p ~/vrx_ws/src/vrx/vrx_gazebo/models/my_dock_base && cd ~/vrx_ws/src/vrx/vrx_gazebo/models/my_dock_base

Next, create and edit the model.config file inside the my_dock_base directory:

gedit model.config

Paste and save the following content:

<?xml version="1.0"?>
<model>
  <name>my_dock_base</name>
  <version>1.0</version>
  <sdf version="1.6">model.sdf</sdf>

  <author>
    <name>Carlos Agüero</name>
    <email>caguero@openrobotics.org</email>
  </author>

  <description>
    My custom dock base.
  </description>
</model>

Next, create the model.sdf.erb file inside the my_dock_base directory and edit it with your favorite editor:

<?xml version="1.0" ?>
<sdf version="1.6">

  <model name="robotx_dock_2016_base">
    <selfCollide>false</selfCollide>
    <%
    layout = [
    'X  X',
    'X  X',
    'X  X',
    'XXXXXXX',
    'XXXX',
    'XXXXXXX',
    'X  X',
    'X  X',
    'X  X',
    ]
    %>
    <%= ERB.new(File.read('dock_generator.erb'),
                      nil, '-', 'dock').result(binding) %>
  </model>
</sdf>

Note: The layout variable controls the layout of the dock. Feel free to modify this variable to your own needs. Every X will be transformed into a 4x4 grid dock block. Try not to use a large number of blocks, as these will be converted into visuals that might impact the performance of the simulation.

Now that you have added a new dock model, open the vrx_gazebo/CMakeLists.txt file and add your model under the section for Dock base files:

# Dock base files that need to be processed with erb
set (dock_base_erb_files
  models/dock_2016_base/model.sdf.erb
  models/dock_2018_base/model.sdf.erb

  # THIS IS THE ONLY LINE THAT NEEDS TO BE ADDED.
  models/my_dock_base/model.sdf.erb
)

Finally, generate your new dock:

cd ~/vrx_ws/
catkin_make

Use the new dock in Gazebo

Launch your simulation:

roslaunch vrx_gazebo vrx.launch

To insert your new dock:

  • Select the "Insert" tab in the left sidebar menu.
  • Scroll down to the models in your vrx_gazebo/models path
  • Use the mouse to elect my_dock_base
  • Move the mouse over the main window to drag the new dock model into the environment.
  • Left click to place the model.

my_dock.png

Clone this wiki locally