FollowObject Action
Package: nav2_msgs
Category: Other
goal definition
Message Definitions
Goal Message
Field |
Type |
Description |
pose_topic |
string |
Topic to publish the pose of the object to follow |
tracked_frame |
string |
Target frame to follow (Optional, used if pose_topic is not set) |
max_duration |
builtin_interfaces/Duration |
Duration parameter - specifies time limits for action completion, timeout controls, or reports elapsed/remaining time for performance monitoring and safety |
Result Message
Field |
Type |
Description |
NONE |
uint16 |
Success status code indicating the action completed without errors |
TF_ERROR |
uint16 |
Error code indicating a transform/localization failure |
FAILED_TO_DETECT_OBJECT |
uint16 |
Integer parameter - represents counts, indices, or identifiers for navigation elements like waypoint numbers, node IDs, or status codes |
FAILED_TO_CONTROL |
uint16 |
Error code indicating control system failure during docking maneuver |
UNKNOWN |
uint16 |
Generic error code for unexpected or unclassified failures |
total_elapsed_time |
builtin_interfaces/Duration |
Total time taken to complete the action |
error_code |
uint16 |
Contextual error code, if any |
num_retries |
uint16 |
Number of retries attempted |
error_msg |
string |
Error message, if any |
Feedback Message
Field |
Type |
Description |
NONE |
uint16 |
Success status code indicating the action completed without errors |
INITIAL_PERCEPTION |
uint16 |
Status indicating the robot is performing initial dock detection and perception |
CONTROLLING |
uint16 |
Status indicating the robot is under precise control for final docking approach |
STOPPING |
uint16 |
Integer parameter - represents counts, indices, or identifiers for navigation elements like waypoint numbers, node IDs, or status codes |
RETRY |
uint16 |
Status indicating the docking process is retrying after a failed attempt |
state |
uint16 |
Current following state |
following_time |
builtin_interfaces/Duration |
Duration parameter - specifies time limits for action completion, timeout controls, or reports elapsed/remaining time for performance monitoring and safety |
num_retries |
uint16 |
Number of retries attempted |
Usage Examples
Python
import rclpy
from rclpy.node import Node
from rclpy.action import ActionClient
from nav2_msgs.action import FollowObject
class Nav2ActionClient(Node):
def __init__(self):
super().__init__('nav2_action_client')
self.action_client = ActionClient(self, FollowObject, 'follow_object')
def send_goal(self):
goal_msg = FollowObject.Goal()
# Set appropriate fields for FollowObject
self.action_client.wait_for_server()
future = self.action_client.send_goal_async(
goal_msg, feedback_callback=self.feedback_callback)
return future
def feedback_callback(self, feedback_msg):
self.get_logger().info(f'Received feedback: {feedback_msg.feedback}')
C++
#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
#include "nav2_msgs/action/follow_object.hpp"
class Nav2ActionClient : public rclcpp::Node
{
public:
using FollowObjectAction = nav2_msgs::action::FollowObject;
using GoalHandle = rclcpp_action::ClientGoalHandle<FollowObjectAction>;
Nav2ActionClient() : Node("nav2_action_client")
{
action_client_ = rclcpp_action::create_client<FollowObjectAction>(
this, "follow_object");
}
void send_goal()
{
auto goal_msg = FollowObjectAction::Goal();
// Set appropriate fields for FollowObject
action_client_->wait_for_action_server();
auto send_goal_options = rclcpp_action::Client<FollowObjectAction>::SendGoalOptions();
send_goal_options.feedback_callback =
std::bind(&Nav2ActionClient::feedback_callback, this,
std::placeholders::_1, std::placeholders::_2);
action_client_->async_send_goal(goal_msg, send_goal_options);
}
private:
rclcpp_action::Client<FollowObjectAction>::SharedPtr action_client_;
void feedback_callback(GoalHandle::SharedPtr,
const std::shared_ptr<const FollowObjectAction::Feedback> feedback)
{
RCLCPP_INFO(this->get_logger(), "Received feedback");
}
};