-
Notifications
You must be signed in to change notification settings - Fork 103
RockFalls tutorial
A rock fall consists of a trigger mechanism and dynamic rocks. The trigger mechanism determines when the rocks should fall and the dynamic rocks are a collection of various 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 first placing the trigger and then choosing and placing the dynamic rocks.
A trigger is an SDF model that consists of a box detector and a triggered publisher. The box detector defines a 3D region which monitors for the presence of a robot. The box detector send 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 the box detector messages matches a criteria.
This two step process supports attachment of multiple triggers to a single box detector. 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:
-
<topic>/subt_performer_detector</topic>
: This is the topic on which the box detector publishes messages. -
<input type="ignition.msgs.Pose" topic="/subt_performer_detector">
: This is the message type and topic that the triggered publisher subscribes to. -
<match field="header.data">{key: "frame_id" value: "performer_detector_1"}</match> <match field="header.data">{key: "state" value: "1"}</match>
: This is matching criteria used by the triggered publisher for incoming messages. -
<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.
First, choose the size of the rock fall from the following options:
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 out your rock fall by driving a robot through the trigger area.