/spin#

Caution

This documentation page has been auto-generated.

It may be missing some details.

/spin Quick Facts

Category

🧭 Navigation

Message type

nav2_msgs/action/Spin

Nav2 Behavior Plugin implementing a configurable spin behavior. It makes the robot rotate by a certaing angle.

For more information on this Behavior, check the Nav2 Spin Behavior documentation.

Quick snippets#

Send a goal from the command-line#
$ ros2 action send_goal /spin nav2_msgs/action/Spin # 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 nav2_msgs.action import Spin

class SpinActionClient(Node):

    def __init__(self):
        super().__init__('spin_client')
        self._action_client = ActionClient(self, Spin, '/spin')

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

        # TODO: adapt to the action's parameters
        # check https://docs.ros2.org/latest/api/nav2_msgs/action/Spin.html
        # 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 = SpinActionClient()

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

    rclpy.spin_until_future_complete(action_client, future)

    rclpy.shutdown()