rcl_action  master
C API providing common functionality for ROS actions.
Classes | Macros | Typedefs | Enumerations | Functions | Variables
types.h File Reference
#include "rcl_action/visibility_control.h"
#include "action_msgs/msg/goal_info.h"
#include "action_msgs/msg/goal_status.h"
#include "action_msgs/msg/goal_status_array.h"
#include "action_msgs/srv/cancel_goal.h"
#include "rcl/allocator.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rosidl_generator_c/action_type_support_struct.h"
Include dependency graph for types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rcl_action_goal_status_array_t
 
struct  rcl_action_cancel_response_t
 

Macros

#define RCL_RET_ACTION_NAME_INVALID   2000
 Action name does not pass validation return code. More...
 
#define RCL_RET_ACTION_GOAL_ACCEPTED   2100
 Action goal accepted return code. More...
 
#define RCL_RET_ACTION_GOAL_REJECTED   2101
 Action goal rejected return code. More...
 
#define RCL_RET_ACTION_CLIENT_INVALID   2102
 Action client is invalid return code. More...
 
#define RCL_RET_ACTION_CLIENT_TAKE_FAILED   2103
 Action client failed to take response return code. More...
 
#define RCL_RET_ACTION_SERVER_INVALID   2200
 Action server is invalid return code. More...
 
#define RCL_RET_ACTION_SERVER_TAKE_FAILED   2201
 Action server failed to take request return code. More...
 
#define RCL_RET_ACTION_GOAL_HANDLE_INVALID   2300
 Action goal handle invalid return code. More...
 
#define RCL_RET_ACTION_GOAL_EVENT_INVALID   2301
 Action invalid event return code. More...
 
#define UUID_SIZE   16
 
#define uuidcmp(uuid0, uuid1)   (0 == memcmp(uuid0, uuid1, UUID_SIZE))
 
#define zerouuid   (uint8_t[UUID_SIZE]) {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 
#define uuidcmpzero(uuid)   uuidcmp(uuid, (zerouuid))
 
#define GOAL_STATE_UNKNOWN   action_msgs__msg__GoalStatus__STATUS_UNKNOWN
 
#define GOAL_STATE_ACCEPTED   action_msgs__msg__GoalStatus__STATUS_ACCEPTED
 
#define GOAL_STATE_EXECUTING   action_msgs__msg__GoalStatus__STATUS_EXECUTING
 
#define GOAL_STATE_CANCELING   action_msgs__msg__GoalStatus__STATUS_CANCELING
 
#define GOAL_STATE_SUCCEEDED   action_msgs__msg__GoalStatus__STATUS_SUCCEEDED
 
#define GOAL_STATE_CANCELED   action_msgs__msg__GoalStatus__STATUS_CANCELED
 
#define GOAL_STATE_ABORTED   action_msgs__msg__GoalStatus__STATUS_ABORTED
 
#define GOAL_STATE_NUM_STATES   7
 

Typedefs

typedef struct rcl_action_server_t rcl_action_server_t
 
typedef action_msgs__msg__GoalInfo rcl_action_goal_info_t
 
typedef action_msgs__msg__GoalStatus rcl_action_goal_status_t
 
typedef struct rcl_action_goal_status_array_t rcl_action_goal_status_array_t
 
typedef action_msgs__srv__CancelGoal_Request rcl_action_cancel_request_t
 
typedef struct rcl_action_cancel_response_t rcl_action_cancel_response_t
 
typedef int8_t rcl_action_goal_state_t
 Goal states. More...
 
typedef enum rcl_action_goal_event_t rcl_action_goal_event_t
 Goal state transition events. More...
 

Enumerations

enum  rcl_action_goal_event_t {
  GOAL_EVENT_EXECUTE = 0, GOAL_EVENT_CANCEL_GOAL, GOAL_EVENT_SUCCEED, GOAL_EVENT_ABORT,
  GOAL_EVENT_CANCELED, GOAL_EVENT_NUM_EVENTS
}
 Goal state transition events. More...
 

Functions

RCL_ACTION_PUBLIC rcl_action_goal_info_t rcl_action_get_zero_initialized_goal_info (void)
 Return a rcl_action_goal_info_t with members set to zero values. More...
 
RCL_ACTION_PUBLIC rcl_action_goal_status_array_t rcl_action_get_zero_initialized_goal_status_array (void)
 Return a rcl_action_goal_status_array_t with members set to NULL. More...
 
RCL_ACTION_PUBLIC rcl_action_cancel_request_t rcl_action_get_zero_initialized_cancel_request (void)
 Return a rcl_action_cancel_request_t with members set to NULL. More...
 
RCL_ACTION_PUBLIC rcl_action_cancel_response_t rcl_action_get_zero_initialized_cancel_response (void)
 Return a rcl_action_cancel_response_t with members set to NULL. More...
 
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_goal_status_array_init (rcl_action_goal_status_array_t *status_array, const size_t num_status, const rcl_allocator_t allocator)
 Initialize a rcl_action_goal_status_array_t. More...
 
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_goal_status_array_fini (rcl_action_goal_status_array_t *status_array)
 Finalize a rcl_action_goal_status_array_t. More...
 
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_cancel_response_init (rcl_action_cancel_response_t *cancel_response, const size_t num_goals_canceling, const rcl_allocator_t allocator)
 Initialize a rcl_action_cancel_response_t. More...
 
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_cancel_response_fini (rcl_action_cancel_response_t *cancel_response)
 Finalize a rcl_action_cancel_response_t. More...
 

Variables

const char * goal_state_descriptions []
 User friendly error messages for invalid trasntions. More...
 
const char * goal_event_descriptions []
 

Macro Definition Documentation

◆ RCL_RET_ACTION_NAME_INVALID

#define RCL_RET_ACTION_NAME_INVALID   2000

Action name does not pass validation return code.

◆ RCL_RET_ACTION_GOAL_ACCEPTED

#define RCL_RET_ACTION_GOAL_ACCEPTED   2100

Action goal accepted return code.

◆ RCL_RET_ACTION_GOAL_REJECTED

#define RCL_RET_ACTION_GOAL_REJECTED   2101

Action goal rejected return code.

◆ RCL_RET_ACTION_CLIENT_INVALID

#define RCL_RET_ACTION_CLIENT_INVALID   2102

Action client is invalid return code.

◆ RCL_RET_ACTION_CLIENT_TAKE_FAILED

#define RCL_RET_ACTION_CLIENT_TAKE_FAILED   2103

Action client failed to take response return code.

◆ RCL_RET_ACTION_SERVER_INVALID

#define RCL_RET_ACTION_SERVER_INVALID   2200

Action server is invalid return code.

◆ RCL_RET_ACTION_SERVER_TAKE_FAILED

#define RCL_RET_ACTION_SERVER_TAKE_FAILED   2201

Action server failed to take request return code.

◆ RCL_RET_ACTION_GOAL_HANDLE_INVALID

#define RCL_RET_ACTION_GOAL_HANDLE_INVALID   2300

Action goal handle invalid return code.

◆ RCL_RET_ACTION_GOAL_EVENT_INVALID

#define RCL_RET_ACTION_GOAL_EVENT_INVALID   2301

Action invalid event return code.

◆ UUID_SIZE

#define UUID_SIZE   16

◆ uuidcmp

#define uuidcmp (   uuid0,
  uuid1 
)    (0 == memcmp(uuid0, uuid1, UUID_SIZE))

◆ zerouuid

#define zerouuid   (uint8_t[UUID_SIZE]) {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

◆ uuidcmpzero

#define uuidcmpzero (   uuid)    uuidcmp(uuid, (zerouuid))

◆ GOAL_STATE_UNKNOWN

#define GOAL_STATE_UNKNOWN   action_msgs__msg__GoalStatus__STATUS_UNKNOWN

◆ GOAL_STATE_ACCEPTED

#define GOAL_STATE_ACCEPTED   action_msgs__msg__GoalStatus__STATUS_ACCEPTED

◆ GOAL_STATE_EXECUTING

#define GOAL_STATE_EXECUTING   action_msgs__msg__GoalStatus__STATUS_EXECUTING

◆ GOAL_STATE_CANCELING

#define GOAL_STATE_CANCELING   action_msgs__msg__GoalStatus__STATUS_CANCELING

◆ GOAL_STATE_SUCCEEDED

#define GOAL_STATE_SUCCEEDED   action_msgs__msg__GoalStatus__STATUS_SUCCEEDED

◆ GOAL_STATE_CANCELED

#define GOAL_STATE_CANCELED   action_msgs__msg__GoalStatus__STATUS_CANCELED

◆ GOAL_STATE_ABORTED

#define GOAL_STATE_ABORTED   action_msgs__msg__GoalStatus__STATUS_ABORTED

◆ GOAL_STATE_NUM_STATES

#define GOAL_STATE_NUM_STATES   7

Typedef Documentation

◆ rcl_action_server_t

◆ rcl_action_goal_info_t

typedef action_msgs__msg__GoalInfo rcl_action_goal_info_t

◆ rcl_action_goal_status_t

typedef action_msgs__msg__GoalStatus rcl_action_goal_status_t

◆ rcl_action_goal_status_array_t

◆ rcl_action_cancel_request_t

typedef action_msgs__srv__CancelGoal_Request rcl_action_cancel_request_t

◆ rcl_action_cancel_response_t

◆ rcl_action_goal_state_t

typedef int8_t rcl_action_goal_state_t

Goal states.

◆ rcl_action_goal_event_t

Goal state transition events.

Enumeration Type Documentation

◆ rcl_action_goal_event_t

Goal state transition events.

Enumerator
GOAL_EVENT_EXECUTE 
GOAL_EVENT_CANCEL_GOAL 
GOAL_EVENT_SUCCEED 
GOAL_EVENT_ABORT 
GOAL_EVENT_CANCELED 
GOAL_EVENT_NUM_EVENTS 

Function Documentation

◆ rcl_action_get_zero_initialized_goal_info()

RCL_ACTION_PUBLIC rcl_action_goal_info_t rcl_action_get_zero_initialized_goal_info ( void  )

Return a rcl_action_goal_info_t with members set to zero values.

◆ rcl_action_get_zero_initialized_goal_status_array()

RCL_ACTION_PUBLIC rcl_action_goal_status_array_t rcl_action_get_zero_initialized_goal_status_array ( void  )

Return a rcl_action_goal_status_array_t with members set to NULL.

Should be called to get a null rcl_action_goal_status_array_t before passing to rcl_action_server_get_goal_status_array().

◆ rcl_action_get_zero_initialized_cancel_request()

RCL_ACTION_PUBLIC rcl_action_cancel_request_t rcl_action_get_zero_initialized_cancel_request ( void  )

Return a rcl_action_cancel_request_t with members set to NULL.

Should be called to get a null rcl_action_cancel_request_t before passing to

rcl_action_cancel_request_init().

◆ rcl_action_get_zero_initialized_cancel_response()

RCL_ACTION_PUBLIC rcl_action_cancel_response_t rcl_action_get_zero_initialized_cancel_response ( void  )

Return a rcl_action_cancel_response_t with members set to NULL.

Should be called to get a null rcl_action_cancel_response_t before passing to rcl_action_cancel_response_init().

◆ rcl_action_goal_status_array_init()

RCL_ACTION_PUBLIC rcl_ret_t rcl_action_goal_status_array_init ( rcl_action_goal_status_array_t status_array,
const size_t  num_status,
const rcl_allocator_t  allocator 
)

Initialize a rcl_action_goal_status_array_t.

After calling this function on a rcl_action_goal_status_array_t, it can be populated and used to get and send status array messages with an action server using rcl_action_get_goal_status_array() and rcl_action_publish_status() respectively.

Example usage:

#include <rcl/rcl.h>
rcl_action_goal_status_array_t goal_status_array =
size_t num_status = 42;
&goal_status_array,
num_status,
// ... error handling, and when done with message, finalize
// ... error handling

Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[out]status_arraya preallocated, zero-initialized, goal status array message to be initialized.
[in]num_statusthe number of status messages to allocate space for. Must be greater than zero
[in]allocatora valid allocator
Returns
RCL_RET_OK if cancel response was initialized successfully, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_ALREADY_INIT if the status array has already been initialized, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

◆ rcl_action_goal_status_array_fini()

RCL_ACTION_PUBLIC rcl_ret_t rcl_action_goal_status_array_fini ( rcl_action_goal_status_array_t status_array)

Finalize a rcl_action_goal_status_array_t.

After calling, the goal status array message will no longer be valid.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in,out]status_arraythe goal status array message to be deinitialized
Returns
RCL_RET_OK if the goal status array was deinitialized successfully, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_ERROR if an unspecified error occurs.

◆ rcl_action_cancel_response_init()

RCL_ACTION_PUBLIC rcl_ret_t rcl_action_cancel_response_init ( rcl_action_cancel_response_t cancel_response,
const size_t  num_goals_canceling,
const rcl_allocator_t  allocator 
)

Initialize a rcl_action_cancel_response_t.

After calling this function on a rcl_action_cancel_response_t, it can be populated and used to process cancel requests with an action server using rcl_action_process_cancel_request().

Example usage:

#include <rcl/rcl.h>
size_t num_goals_canceling = 10;
&cancel_response,
num_goals_canceling,
// ... error handling, and when done processing response, finalize
// ... error handling

Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[out]cancel_responsea preallocated, zero-initialized, cancel response message to be initialized.
[in]num_goals_cancelingthe number of goals that are canceling to add to the response Must be greater than zero
[in]allocatora valid allocator
Returns
RCL_RET_OK if cancel response was initialized successfully, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_ALREADY_INIT if the cancel response has already been initialized, or
RCL_RET_BAD_ALLOC if allocating memory failed, or
RCL_RET_ERROR if an unspecified error occurs.

◆ rcl_action_cancel_response_fini()

RCL_ACTION_PUBLIC rcl_ret_t rcl_action_cancel_response_fini ( rcl_action_cancel_response_t cancel_response)

Finalize a rcl_action_cancel_response_t.

After calling, the cancel response message will no longer be valid.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Parameters
[in,out]cancel_responsethe cancel response message to be deinitialized
Returns
RCL_RET_OK if the cancel response was deinitialized successfully, or
RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or
RCL_RET_ERROR if an unspecified error occurs.

Variable Documentation

◆ goal_state_descriptions

const char* goal_state_descriptions[]

User friendly error messages for invalid trasntions.

◆ goal_event_descriptions

const char* goal_event_descriptions[]