Complete the code to initialize the Navigation2 stack node in ROS 2.
auto nav2_node = std::make_shared<[1]>();The Navigation2 stack uses a LifecycleNode to manage its states and transitions.
Complete the code to send a navigation goal using the Nav2 action client.
auto goal_msg = nav2_msgs::action::NavigateToPose::Goal();
goal_msg.pose = target_pose;
action_client->[1](goal_msg);The Nav2 action client uses send_goal_async to send goals asynchronously.
Fix the error in the lifecycle transition call to activate the Nav2 node.
nav2_node->[1](nav2_lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE);The correct method to trigger lifecycle transitions is trigger_transition.
Fill both blanks to create a Behavior Tree node that checks if the robot has reached its goal.
class IsGoalReached : public BT::[1]Node { public: IsGoalReached(const std::string & name, const BT::NodeConfiguration & config) : BT::[2]Node(name, config) {} };
Behavior Tree condition nodes check states like goal reached, so both blanks use Condition.
Fill all three blanks to define a ROS 2 parameter for the Nav2 planner plugin name with a default value.
rclcpp::NodeOptions options; options.[1]("planner_plugin", "nav2_navfn_planner/NavfnPlanner"); auto planner_node = std::make_shared<nav2::Planner>(options); planner_node->declare_parameter("planner_plugin", [2]); std::string plugin_name = planner_node->get_parameter("planner_plugin").[3]();
Use set_parameter on options to set default, declare_parameter on node, and as_string() to get the parameter value as string.
