Skip to content

Commit 6ff556f

Browse files
authored
Backports to iron (#73)
* Fix polygons not clearing (#72) * Add behavior tree to navigate to start before starting fields navigation * snake case * comments * rviz visualization for demo * Update rviz_config.rviz * Linting and add to other demo * Fix polygons not clearing, credit to tonynajjar --------- Co-authored-by: Marc Morcos <[email protected]> * Rviz Visualization Config (#67) * Add behavior tree to navigate to start before starting fields navigation * snake case * comments * rviz visualization for demo * Update rviz_config.rviz * Linting and add to other demo * Add behavior tree to navigate to start before starting fields navigation (#65) * Add behavior tree to navigate to start before starting fields navigation * snake case * comments * Old format for behavior tree --------- Co-authored-by: Marc Morcos <[email protected]>
1 parent 48ba3e7 commit 6ff556f

File tree

5 files changed

+731
-2
lines changed

5 files changed

+731
-2
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
This Behavior Tree computes a complete coverage path over a selected space, navigates to the start point of the path, then follows the coverage path.
3+
Can also take the coverage_path instead of Nav Path for segmented swaths from turns
4+
for changes in operational modes (e.g. raise tool, turn off payload in turns not in field).
5+
6+
Field filepath is set by the Navigator plugin in the action request, but also may be hardcoded
7+
or set using the polygons input port instead for dynamically computed values instead of from file.
8+
9+
It might be wise to still have the planner server on hand to connect to the coverage path in realistic uses.
10+
11+
This BT shows set polygon usage with the coverage server
12+
-->
13+
14+
<root main_tree_to_execute="MainTree">
15+
<BehaviorTree ID="MainTree">
16+
<RateController hz="0.0000001"> <!-- once, for demo -->
17+
<Sequence name="NavigateWithoutReplanning">
18+
<!-- May use:
19+
'polygons="{field_polygon}" polygons_frame_id="{polygon_frame_id}"' if set polygon via NavigateCompleteCoverage
20+
or file_field="{field_filepath}" if setting polygon file via NavigateCompleteCoverage -->
21+
22+
<!-- Compute path to cover fields -->
23+
<ComputeCoveragePath nav_path="{path}" polygons="{field_polygon}" polygons_frame_id="{polygon_frame_id}" error_code_id="{compute_coverage_error_code}"/>
24+
25+
<!-- Go to start of path before navigating -->
26+
<GetPoseFromPath path="{path}" pose="{start_pose}" index="0" />
27+
<ComputePathToPose goal="{start_pose}" path="{path_to_start}" planner_id="GridBased" error_code_id="{compute_path_error_code}"/>
28+
<FollowPath path="{path_to_start}" controller_id="FollowPath" error_code_id="{follow_path_error_code}"/>
29+
30+
<!-- Follow computed path -->
31+
<FollowPath path="{path}" controller_id="FollowPath" error_code_id="{follow_path_error_code}"/>
32+
</Sequence>
33+
</RateController>
34+
</BehaviorTree>
35+
</root>

opennav_coverage_bt/src/compute_complete_coverage_path.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void ComputeCoveragePathAction::on_tick()
4646
// Convert from vector of Polygons to coverage sp. message
4747
std::vector<geometry_msgs::msg::Polygon> polys;
4848
getInput("polygons", polys);
49+
goal_.polygons.clear();
4950
goal_.polygons.resize(polys.size());
5051
for (unsigned int i = 0; i != polys.size(); i++) {
5152
for (unsigned int j = 0; j != polys[i].points.size(); j++) {

opennav_coverage_demo/launch/coverage_demo_launch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
def generate_launch_description():
2626
nav2_bringup_dir = get_package_share_directory('nav2_bringup')
2727
coverage_demo_dir = get_package_share_directory('opennav_coverage_demo')
28+
rviz_config_file = os.path.join(coverage_demo_dir, 'rviz_config.rviz')
2829

2930
world = os.path.join(coverage_demo_dir, 'blank.world')
3031
param_file_path = os.path.join(coverage_demo_dir, 'demo_params.yaml')
@@ -66,7 +67,7 @@ def generate_launch_description():
6667
rviz_cmd = IncludeLaunchDescription(
6768
PythonLaunchDescriptionSource(
6869
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
69-
launch_arguments={'namespace': ''}.items())
70+
launch_arguments={'namespace': '', 'rviz_config': rviz_config_file}.items())
7071

7172
# start navigation
7273
bringup_cmd = IncludeLaunchDescription(

opennav_coverage_demo/launch/row_coverage_demo_launch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
def generate_launch_description():
2626
nav2_bringup_dir = get_package_share_directory('nav2_bringup')
2727
coverage_demo_dir = get_package_share_directory('opennav_coverage_demo')
28+
rviz_config_file = os.path.join(coverage_demo_dir, 'rviz_config.rviz')
2829

2930
world = os.path.join(coverage_demo_dir, 'blank.world')
3031
param_file_path = os.path.join(coverage_demo_dir, 'demo_params.yaml')
@@ -66,7 +67,7 @@ def generate_launch_description():
6667
rviz_cmd = IncludeLaunchDescription(
6768
PythonLaunchDescriptionSource(
6869
os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')),
69-
launch_arguments={'namespace': ''}.items())
70+
launch_arguments={'namespace': '', 'rviz_config': rviz_config_file}.items())
7071

7172
# start navigation
7273
bringup_cmd = IncludeLaunchDescription(

0 commit comments

Comments
 (0)