Skip to content

RockFalls tutorial

Angela Maio edited this page Jun 30, 2023 · 6 revisions

A rock fall consists of a trigger mechanism and dynamic rocks. The trigger mechanism determines when the rock fall occurs and the dynamic rocks are a collection of rocks sizes that spawn into existence in response to a trigger event.

This tutorial will walk through the process of creating a new rock fall by placing the trigger, and choosing and placing the dynamic rocks, and then testing.

Trigger Placement

A trigger is an SDF model that consists of a box detector and a triggered publisher. The box detector defines a 3D region in which the presence of a robot is monitored. The box detector sends a message on a topic when a robot enters or leaves the region. The triggered publisher listens to the messages sent by the box detector and sends a new message on a different topic when a box detector message matches a set of criteria.

This two step process supports attachment of multiple triggers to a single box detector, and allows all box detector to publish on a common topic. In this tutorial we will attach together one box detector and one triggered publisher.

Paste the following snippet into your SDF world to get started with trigger placement.

<model name="performer_detector_1">
  <static>true</static>
  <pose>0 0 0 0 0 0</pose>
  <link name='body'>
    <visual name="v1">
      <transparency>1.0</transparency>
      <geometry>
        <box>
          <size>20 30 10</size>
        </box>
      </geometry>
    </visual>
    <material>
      <ambient>0.0 1.0 0.0 1</ambient>
      <diffuse>0.0 1.0 0.0 1</diffuse>
      <specular>0.5 0.5 0.5 1</specular>
    </material>
    <cast_shadows>false</cast_shadows>
  </link>
  <plugin filename="libignition-gazebo-performer-detector-system.so"
    name="ignition::gazebo::systems::PerformerDetector">
    <topic>/subt_performer_detector</topic>
    <geometry>
      <box>
        <size>20 30 10</size>
      </box>
    </geometry>
  </plugin>

  <!--TriggeredPublisher that publishes on the "deploy" topic of dynamic_rocks_1 when a performer enters the region defined in performer_detector_1-->
  <plugin name="ignition::gazebo::systems::TriggeredPublisher" filename="libignition-gazebo-triggered-publisher-system.so">
    <input type="ignition.msgs.Pose" topic="/subt_performer_detector">
      <match field="header.data">{key: "frame_id" value: "performer_detector_1"}</match>
      <match field="header.data">{key: "state" value: "1"}</match>
    </input>
    <output type="ignition.msgs.Empty" topic="/model/dynamic_rocks_1/breadcrumbs/Rock/deploy"/>
 </plugin>
</model>

Next, modify the <pose> and <box><size> of the performer_detector_1 model. You can use the Entity Tree, Transform Control, and Component Inspector GUI plugins to aid in the placement of the performer_detector_1 model.

Take note of the following lines in the above snippet:

  1. <topic>/subt_performer_detector</topic> : This is the topic on which the box detector publishes messages.
  2. <input type="ignition.msgs.Pose" topic="/subt_performer_detector"> : This is the message type and topic that the triggered publisher subscribes to.
  3. <match field="header.data">{key: "frame_id" value: "performer_detector_1"}</match> <match field="header.data">{key: "state" value: "1"}</match> : This is the matching criteria used by the triggered publisher for incoming messages.
  4. <output type="ignition.msgs.Empty" topic="/model/dynamic_rocks_1/breadcrumbs/Rock/deploy"/> : This is the message type and topic on which the triggered publisher publishes when the matching criteria is met.

Dynamic rock placement

First, choose the size of the rock fall from the following options:

  1. Large. This rock fall can occur once.
  2. Medium. This rock fall can occur 5 times.
  3. Medium 3. This rock fall can occur 3 times.
  4. Small. This rock fall can occur 5 times.

Next, copy the following snippet into your SDF world file. Make sure to replace the <uri> with the rock fall model you chose. The <name> of the model should match the name used in the <output ... /> line in the triggered publisher.

<include>
  <name>dynamic_rocks_1</name>
  <pose>0 0 0 0 0 0</pose>
  <uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Medium Rock Fall</uri>
</include>

Finally, adjust the pose of the rock model using the GUI Transform Control plugin and copy the model's final pose into your SDF file using the Component Inspector GUI plugin.

Test

Test out your rock fall by driving a robot through the trigger area.

You can also manually trigger the rock fall from the command line using:

ign topic -t /model/dynamic_rocks_1/breadcrumbs/Rock/deploy -m ignition.msgs.Empty -p 'unused: true'
Clone this wiki locally