/detect_targetΒΆ

Caution

This documentation page has been auto-generated.

It may be missing some details.

/detect_target Quick Facts

Category

🧭 Navigation

Message type

pal_nav2_msgs/action/DetectTarget

Action Server responsible for detecting and localizing a Target with respect to the robot. It can load multiple plugins for the detection of different Targets using different sensors.

For more information, check the πŸ“‘ Target Detection.

Quick snippetsΒΆ

Send a goal from the command-lineΒΆ
$ ros2 action send_goal /detect_target pal_nav2_msgs/action/DetectTarget # press Tab to complete the message prototype

How to use in your codeΒΆ

Call the action from a Python scriptΒΆ
#!/usr/bin/env python

import rclpy
from rclpy.action import ActionClient
from rclpy.node import Node

from pal_nav2_msgs.action import DetectTarget

class DetectTargetActionClient(Node):

    def __init__(self):
        super().__init__('detect_target_client')
        self._action_client = ActionClient(self, DetectTarget, '/detect_target')

    def send_goal(self, a, b):
        goal_msg = DetectTarget.Goal()

        # TODO: adapt to the action's parameters
        # check the pal_nav2_msgs/action/DetectTargetGoal message
        # definition for the possible goal parameters
        # goal_msg.a = a
        # goal_msg.b = b

        self._action_client.wait_for_server()

        return self._action_client.send_goal_async(goal_msg)

if __name__ == '__main__':
    rclpy.init(args=args)

    action_client = DetectTargetActionClient()

    # TODO: adapt to your action's parameters
    future = action_client.send_goal(a, b)

    rclpy.spin_until_future_complete(action_client, future)

    rclpy.shutdown()