Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Scan, dock and deliver' scoring plugin #333

Merged
merged 21 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 76 additions & 16 deletions vrx_gazebo/include/vrx_gazebo/scan_dock_scoring_plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,21 @@ class DockChecker
/// Default value is 10.
/// <symbol>: Required string with format <COLOR>_<SHAPE>, where
/// color can be "red", "green", "blue", "yellow" and color can be "triangle",
/// "circle", "cross". If this parameter is present, a ROS message will be
/// sent in OnReady(). The vehicle should dock in the bay matching this color
/// and shape.
/// "circle", "cross", "rectangle". If this parameter is present, a ROS message
/// will be sent in OnReady(). The vehicle should dock in the bay matching this
/// color and shape.
/// <targets>: Contains at least one of the following blocks:
/// <target>: A shooting target. It has the following elements:
/// <topic>: The name of the topic where the "libContainPlugin" publishes
/// information for this target.
/// <bonus_points>: The points awarded for hitting this target.
///
/// Here's an example:
/// <plugin name="scan_dock_scoring_plugin"
/// filename="libscan_dock_scoring_plugin.so">
/// <!-- Parameters for scoring_plugin -->
/// <vehicle>wamv</vehicle>
/// <task_name>scan_dock</task_name>
/// <task_name>scan_dock_deliver</task_name>
/// <initial_state_duration>3</initial_state_duration>
/// <ready_state_duration>3</ready_state_duration>
/// <running_state_duration>300</running_state_duration>
Expand All @@ -271,37 +276,81 @@ class DockChecker
/// <!-- Color sequence checker -->
/// <robot_namespace>vrx</robot_namespace>
/// <color_sequence_service>scan_dock/color_sequence</color_sequence_service>
/// <color_1>red</color_1>
/// <color_1>blue</color_1>
/// <color_2>green</color_2>
/// <color_3>blue</color_3>
/// <color_3>red</color_3>
///
/// <!-- Dock checkers -->
/// <bays>
/// <bay>
/// <name>bay1</name>
/// <internal_activation_topic>
/// /vrx/dock_2018/bay_1_internal/contain
/// <internal_activation_topic>/vrx/dock_2022/bay_1/contain
/// </internal_activation_topic>
/// <external_activation_topic>
/// /vrx/dock_2018/bay_1_external/contain
/// <external_activation_topic>/vrx/dock_2022/bay_1_external/contain
/// </external_activation_topic>
/// <symbol_topic>/vrx/dock_2022_placard1/symbol</symbol_topic>
/// <min_dock_time>10.0</min_dock_time>
/// <dock_allowed>false</dock_allowed>
/// <symbol>red_circle</symbol>
/// </bay>
///

/// <bay>
/// <name>bay2</name>
/// <internal_activation_topic>
/// /vrx/dock_2018/bay_2_internal/contain
/// <internal_activation_topic>/vrx/dock_2022/bay_2/contain
/// </internal_activation_topic>
/// <external_activation_topic>
/// /vrx/dock_2018/bay_2_external/contain
/// <external_activation_topic>/vrx/dock_2022/bay_2_external/contain
/// </external_activation_topic>
/// <symbol_topic>/vrx/dock_2022_placard2/symbol</symbol_topic>
/// <min_dock_time>10.0</min_dock_time>
/// <dock_allowed>true</dock_allowed>
/// <symbol>red_circle</symbol>
/// <symbol>blue_circle</symbol>
/// </bay>

/// <bay>
/// <name>bay3</name>
/// <internal_activation_topic>/vrx/dock_2022/bay_3/contain
/// </internal_activation_topic>
/// <external_activation_topic>/vrx/dock_2022/bay_3_external/contain
/// </external_activation_topic>
/// <symbol_topic>/vrx/dock_2022_placard3/symbol</symbol_topic>
/// <min_dock_time>10.0</min_dock_time>
/// <dock_allowed>true</dock_allowed>
/// <symbol>yellow_rectangle</symbol>
/// </bay>
/// </bays>
///
/// <!-- Shooting targets -->
/// <targets>
/// <!-- Placard #1 -->
/// <target>
/// <topic>vrx/dock_2022_placard1_big_hole/contain</topic>
/// <bonus_points>5</bonus_points>
/// </target>
/// <target>
/// <topic>vrx/dock_2022_placard1_small_hole/contain</topic>
/// <bonus_points>10</bonus_points>
/// </target>

/// <!-- Placard #2 -->
/// <target>
/// <topic>vrx/dock_2022_placard2_big_hole/contain</topic>
/// <bonus_points>5</bonus_points>
/// </target>
/// <target>
/// <topic>vrx/dock_2022_placard2_small_hole/contain</topic>
/// <bonus_points>10</bonus_points>
/// </target>

/// <!-- Placard #3 -->
/// <target>
/// <topic>vrx/dock_2022_placard3_big_hole/contain</topic>
/// <bonus_points>5</bonus_points>
/// </target>
/// <target>
/// <topic>vrx/dock_2022_placard3_small_hole/contain</topic>
/// <bonus_points>10</bonus_points>
/// </target>
/// </targets>
/// </plugin>
class ScanDockScoringPlugin : public ScoringPlugin
{
Expand Down Expand Up @@ -363,6 +412,17 @@ class ScanDockScoringPlugin : public ScoringPlugin

/// \brief Expected color sequence.
private: std::vector<std::string> expectedSequence;

/// \brief A mutex.
private: std::mutex mutex;

/// \brief The shooting bonus.
private: double shootingBonus = 0.0;

#if GAZEBO_MAJOR_VERSION >= 8
/// \brief Ignition Transport node used for communication.
private: ignition::transport::Node ignNode;
#endif
};

#endif
10 changes: 5 additions & 5 deletions vrx_gazebo/models/dock_2016/model.sdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
<pose><%=placard_x%> <%=placard_y%> <%=placard_z%> <%=placard_roll%> <%=placard_pitch%> <%=placard_yaw%></pose>
<include>
<static>true</static>
<pose> 0 0 0.25 0 0 0</pose>
<pose>0 0 0.25 0 0 0</pose>
<uri>model://placard</uri>
</include>
<link name="link_symbols">
<static>true</static>
<pose> 0 0.07 0.75 0 0 0 </pose>
<pose>0 0.07 0.75 0 0 0</pose>
<visual name="visual_circle">
<pose>0 0 0 1.571 0 0</pose>
<geometry>
Expand All @@ -96,7 +96,7 @@
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_circle</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_h_cross</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_v_cross</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_triangle</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_triangle</visual>
</visuals>
<shuffle>true</shuffle>
<robot_namespace>vrx/dock_2016_placard<%= i %></robot_namespace>
Expand All @@ -120,14 +120,14 @@
</box>
</geometry>
<transparency>1</transparency>
</visual>
</visual>
<visual name="visual_triangle">
<pose> -0.5 0 -0.5 1.571 0 0</pose>
<geometry>
<mesh><uri>model://symbol_triangle/mesh/triangle.dae</uri></mesh>
</geometry>
<transparency>1</transparency>
</visual>
</visual>
</link>

<joint name="placard_to_visual" type="fixed">
Expand Down
12 changes: 6 additions & 6 deletions vrx_gazebo/models/dock_2016_dynamic/model.sdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
<model name="dock_2016_placard<%= i %>">
<pose><%=placard_x%> <%=placard_y%> <%=placard_z%> <%=placard_roll%> <%=placard_pitch%> <%=placard_yaw%></pose>
<include>
<pose> 0 0 0.25 0 0 0</pose>
<pose>0 0 0.25 0 0 0</pose>
<uri>model://placard</uri>
</include>
<link name="link_symbols">
<inertial>
<mass>0.01</mass>
</inertial>
<pose> 0 0.1 0.75 0 0 0 </pose>
<visual name="visual_circle">
<pose>0 0.1 0.75 0 0 0</pose>
<visual name="visual_circle">
<pose>0 0 0 1.571 0 0</pose>
<geometry>
<cylinder>
Expand All @@ -96,7 +96,7 @@
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_circle</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_h_cross</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_v_cross</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_triangle</visual>
<visual>robotx_dock_2016::dock_2016_placard<%= i %>::link_symbols::visual_triangle</visual>
</visuals>
<shuffle>true</shuffle>
<robot_namespace>vrx/dock_2016_placard<%= i %></robot_namespace>
Expand All @@ -120,14 +120,14 @@
</box>
</geometry>
<transparency>1</transparency>
</visual>
</visual>
<visual name="visual_triangle">
<pose> -0.5 0 -0.5 1.571 0 0</pose>
<geometry>
<mesh><uri>model://symbol_triangle/mesh/triangle.dae</uri></mesh>
</geometry>
<transparency>1</transparency>
</visual>
</visual>
</link>

<joint name="placard_to_visual" type="fixed">
Expand Down
4 changes: 2 additions & 2 deletions vrx_gazebo/models/dock_2018_dynamic/model.sdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
</include>
<link name="link_symbols">
<% if i == 1%>
<pose> 0 -0.1 0.75 0 0 0 </pose>
<pose>0 -0.1 0.75 0 0 0</pose>
<% else %>
<pose> 0 0.1 0.75 0 0 0 </pose>
<pose>0 0.1 0.75 0 0 0</pose>
<% end %>
<visual name="visual_circle">
<pose>0 0 0 1.571 0 0</pose>
Expand Down
77 changes: 74 additions & 3 deletions vrx_gazebo/models/dock_2022/model.sdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</include>
<%
# Constants
dock_x = 3.75
dock_x = 5.75
dock_y = 3
dock_z = 1.5
dock_roll = 0
Expand Down Expand Up @@ -76,12 +76,12 @@
<pose><%=placard_x%> <%=placard_y%> <%=placard_z%> <%=placard_roll%> <%=placard_pitch%> <%=placard_yaw%></pose>
<include>
<static>true</static>
<pose> 0 -0.2 0.25 0 0 3.14159</pose>
<pose>0 -0.2 0.25 0 0 3.14159</pose>
<uri>model://placard_2022</uri>
</include>
<link name="link_symbols">
<static>true</static>
<pose> 0 0.07 0 0 0 0 </pose>
<pose>0 0.07 0 0 0 0 </pose>
<visual name="visual_circle">
<pose>0 0 0 1.571 0 0</pose>
<geometry>
Expand Down Expand Up @@ -138,6 +138,38 @@
</geometry>
<transparency>1</transparency>
</visual>

<!-- Uncomment to see the activation areas -->
<!-- <visual name="visual_activation_big_box_<%= i %>">
<pose>0.6 -0.27 1.33 0 0 0</pose>
<geometry>
<box>
<size>0.5 0.5 0.5</size>
</box>
</geometry>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/Green</name>
</script>
</material>
</visual>

<visual name="visual_activation_small_box_<%= i %>">
<pose>-0.6 -0.27 1.33 0 0 0</pose>
<geometry>
<box>
<size>0.25 0.5 0.25</size>
</box>
</geometry>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/Green</name>
</script>
</material>
</visual> -->

</link>

<joint name="placard_to_visual" type="fixed">
Expand All @@ -146,6 +178,45 @@
<child>link_symbols</child>
</joint>

<!-- Uncomment to see the activation areas -->
<!-- For visualizing ContainPlugin volume
Make sure that the size and location are consistent with plugin -->
<!-- <link name="bay_visualization">
<visual name="bay_box">
<pose frame="placard::link">0 -4.5 -1.5 0 0 0</pose>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/Green</name>
</script>
</material>
<geometry>
<box>
<size>1.5 4 2</size>
</box>
</geometry>
<transparency>0.0</transparency>
</visual>
<visual name="bay_box_exterior">
<pose frame="placard::link">0 -9.5 -1.5 0 0 0</pose>
<material>
<script>
<uri>file://media/materials/scripts/gazebo.material</uri>
<name>Gazebo/Red</name>
</script>
</material>
<geometry>
<box>
<size>5.5 1.5 2</size>
</box>
</geometry>
</visual>
</link>
<joint name="placard_to_bay" type="fixed">
<child>placard::link</child>
<parent>bay_visualization</parent>
</joint> -->

</model>
<%
placard_x += placard_offset_x
Expand Down
1 change: 1 addition & 0 deletions vrx_gazebo/models/dock_2022_base/model.sdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<selfCollide>false</selfCollide>
<%
layout = [
'X X X X',
'X X X X',
'X X X X',
'XXXXXXXXXX',
Expand Down
1 change: 1 addition & 0 deletions vrx_gazebo/models/dock_2022_base_dynamic/model.sdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<selfCollide>false</selfCollide>
<%
layout = [
'X X X X',
'X X X X',
'X X X X',
'XXXXXXXXXX',
Expand Down
Loading