Skip to content

[nav2_behavior_tree] Add force_use_current_pose to ComputePathToPoseAction #4925

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ class ComputePathToPoseAction : public BtActionNode<nav2_msgs::action::ComputePa
{
BT::InputPort<geometry_msgs::msg::PoseStamped>("goal", "Destination to plan to"),
BT::InputPort<geometry_msgs::msg::PoseStamped>(
"start", "Start pose of the path if overriding current robot pose"),
"start",
"Used as the planner start pose instead of the current robot pose, if use_start is"
" not false (i.e. not provided or set to true)"),
BT::InputPort<bool>(
"use_start", "For using or not using (i.e. ignoring) the provided start pose"),
BT::InputPort<std::string>(
"planner_id", "",
"Mapped name to the planner plugin type to use"),
Expand Down
3 changes: 2 additions & 1 deletion nav2_behavior_tree/nav2_tree_nodes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@

<Action ID="ComputePathToPose">
<input_port name="goal">Destination to plan to</input_port>
<input_port name="start">Start pose of the path if overriding current robot pose</input_port>
<input_port name="start">Use as the planner start pose instead of the current robot pose, if use_start is not false (i.e. not provided or set to true)</input_port>
<input_port name="use_start">For using or not using (i.e. ignoring) the provided start pose</input_port>
<input_port name="planner_id">Mapped name to the planner plugin type to use</input_port>
<input_port name="server_name">Server name</input_port>
<input_port name="server_timeout">Server timeout</input_port>
Expand Down
21 changes: 19 additions & 2 deletions nav2_behavior_tree/plugins/action/compute_path_to_pose_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,25 @@
{
getInput("goal", goal_.goal);
getInput("planner_id", goal_.planner_id);
if (getInput("start", goal_.start)) {
goal_.use_start = true;

// if "use_start" is provided try to enforce it (true or false), but we cannot enforce true if
// start is not provided
goal_.use_start = false;
if (getInput("use_start", goal_.use_start)) {
if (goal_.use_start && !getInput("start", goal_.start)) {

Check warning on line 40 in nav2_behavior_tree/plugins/action/compute_path_to_pose_action.cpp

View check run for this annotation

Codecov / codecov/patch

nav2_behavior_tree/plugins/action/compute_path_to_pose_action.cpp#L40

Added line #L40 was not covered by tests
// in case we don't have a "start" pose
goal_.use_start = false;
RCLCPP_ERROR(

Check warning on line 43 in nav2_behavior_tree/plugins/action/compute_path_to_pose_action.cpp

View check run for this annotation

Codecov / codecov/patch

nav2_behavior_tree/plugins/action/compute_path_to_pose_action.cpp#L42-L43

Added lines #L42 - L43 were not covered by tests
node_->get_logger(),
"use_start is set to true but no start pose was provided, falling back to default "
"behavior, i.e. using the current robot pose");
}
} else {
// else if "use_start" is not provided, but "start" is, then use it in order to not change
// the legacy behavior
if (getInput("start", goal_.start)) {
goal_.use_start = true;
}
}
}

Expand Down
Loading