roslib
    Preparing search index...

    Class Action<TGoal, TFeedback, TResult>

    A ROS 2 action client.

    Type Parameters

    • TGoal = unknown
    • TFeedback = unknown
    • TResult = unknown
    Index

    Constructors

    • Type Parameters

      • TGoal = unknown
      • TFeedback = unknown
      • TResult = unknown

      Parameters

      • options: { actionType: string; name: string; ros: Ros }
        • actionType: string

          The action type, like 'example_interfaces/Fibonacci'.

        • name: string

          The action name, like '/fibonacci'.

        • ros: Ros

          The ROSLIB.Ros connection handle.

      Returns Action<TGoal, TFeedback, TResult>

    Properties

    actionType: string
    isAdvertised: boolean = false
    name: string
    ros: Ros

    Methods

    • Advertise the action. This turns the Action object from a client into a server. The callback will be called with every goal sent to this action.

      Parameters

      • actionCallback: (goal: TGoal, id: string) => void

        This works similarly to the callback for a C++ action.

      • cancelCallback: (id: string) => void

        A callback function to execute when the action is canceled.

      Returns void

    • Cancels an action goal.

      Parameters

      • id: string

        The ID of the action goal to cancel.

      Returns void

    • Helper function to send action feedback inside an action handler.

      Parameters

      • id: string

        The action goal ID.

      • feedback: TFeedback

        The feedback to send.

      Returns void

    • Sends an action goal. Returns the feedback in the feedback callback while the action is running and the result in the result callback when the action is completed. Does nothing if this action is currently advertised.

      Parameters

      • goal: TGoal

        The action goal to send.

      • resultCallback: (result: TResult) => void

        The callback function when the action is completed.

      • OptionalfeedbackCallback: (feedback: TFeedback) => void

        The callback function when the action pulishes feedback.

      • OptionalfailedCallback: (error: string) => void = console.error

        The callback function when the action failed.

      Returns string | undefined

    • Helper function to set an action as canceled.

      Parameters

      • id: string

        The action goal ID.

      • result: TResult

        The result to set.

      Returns void

    • Helper function to set an action as failed.

      Parameters

      • id: string

        The action goal ID.

      Returns void

    • Helper function to set an action as succeeded.

      Parameters

      • id: string

        The action goal ID.

      • result: TResult

        The result to set.

      Returns void