nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
Functions
parameter.h File Reference

Parameter server API. More...

#include "nros/types.h"
Include dependency graph for parameter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nros_ret_t nros_executor_declare_param_bool (struct nros_executor_t *executor, const char *name, bool value)
 Declare a boolean parameter on the executor's server.
 
nros_ret_t nros_executor_declare_param_double (struct nros_executor_t *executor, const char *name, double value)
 Declare a double parameter on the executor's server.
 
nros_ret_t nros_executor_declare_param_integer (struct nros_executor_t *executor, const char *name, int64_t value)
 Declare an integer parameter on the executor's server.
 
nros_ret_t nros_executor_declare_param_string (struct nros_executor_t *executor, const char *name, const char *value)
 Declare a string parameter on the executor's server.
 
nros_ret_t nros_executor_get_param_bool (struct nros_executor_t *executor, const char *name, bool *out_value)
 Get a boolean parameter from the executor's server.
 
nros_ret_t nros_executor_get_param_double (struct nros_executor_t *executor, const char *name, double *out_value)
 Get a double parameter from the executor's server.
 
nros_ret_t nros_executor_get_param_integer (struct nros_executor_t *executor, const char *name, int64_t *out_value)
 Get an integer parameter from the executor's server.
 
nros_ret_t nros_executor_get_param_string (struct nros_executor_t *executor, const char *name, char *out_value, size_t max_len)
 Get a string parameter into a caller-provided null-terminated buffer.
 
bool nros_executor_has_param (struct nros_executor_t *executor, const char *name)
 Check if a parameter exists on the executor's server.
 
nros_ret_t nros_executor_register_parameter_services (struct nros_executor_t *executor)
 Register the 6 ROS 2 parameter services on the executor's node.
 
nros_ret_t nros_executor_set_param_bool (struct nros_executor_t *executor, const char *name, bool value)
 Set a boolean parameter on the executor's server.
 
nros_ret_t nros_executor_set_param_double (struct nros_executor_t *executor, const char *name, double value)
 Set a double parameter on the executor's server.
 
nros_ret_t nros_executor_set_param_integer (struct nros_executor_t *executor, const char *name, int64_t value)
 Set an integer parameter on the executor's server.
 
nros_ret_t nros_executor_set_param_string (struct nros_executor_t *executor, const char *name, const char *value)
 Set a string parameter on the executor's server.
 
nros_ret_t nros_param_declare_bool (struct nros_param_server_t *server, const char *name, bool default_value)
 Declare a boolean parameter.
 
nros_ret_t nros_param_declare_bool_array (struct nros_param_server_t *server, const char *name, const bool *data, size_t len)
 Declare a boolean array parameter (bool[]).
 
nros_ret_t nros_param_declare_byte_array (struct nros_param_server_t *server, const char *name, const uint8_t *data, size_t len)
 Declare a byte array parameter (uint8_t[]).
 
nros_ret_t nros_param_declare_double (struct nros_param_server_t *server, const char *name, double default_value)
 Declare a double parameter.
 
nros_ret_t nros_param_declare_double_array (struct nros_param_server_t *server, const char *name, const double *data, size_t len)
 Declare a double array parameter (double[]).
 
nros_ret_t nros_param_declare_integer (struct nros_param_server_t *server, const char *name, int64_t default_value)
 Declare an integer parameter.
 
nros_ret_t nros_param_declare_integer_array (struct nros_param_server_t *server, const char *name, const int64_t *data, size_t len)
 Declare an integer array parameter (int64_t[]).
 
nros_ret_t nros_param_declare_string (struct nros_param_server_t *server, const char *name, const char *default_value)
 Declare a string parameter.
 
nros_ret_t nros_param_declare_string_array (struct nros_param_server_t *server, const char *name, const char *const *data, size_t len)
 Declare a string array parameter (array of const char*).
 
nros_ret_t nros_param_get_bool (const struct nros_param_server_t *server, const char *name, bool *value)
 Get a boolean parameter value.
 
nros_ret_t nros_param_get_bool_array (const struct nros_param_server_t *server, const char *name, const bool **data, size_t *len)
 Get a boolean array parameter (returns stored pointer + length).
 
nros_ret_t nros_param_get_byte_array (const struct nros_param_server_t *server, const char *name, const uint8_t **data, size_t *len)
 Get a byte array parameter (returns stored pointer + length).
 
nros_ret_t nros_param_get_double (const struct nros_param_server_t *server, const char *name, double *value)
 Get a double parameter value.
 
nros_ret_t nros_param_get_double_array (const struct nros_param_server_t *server, const char *name, const double **data, size_t *len)
 Get a double array parameter (returns stored pointer + length).
 
nros_ret_t nros_param_get_integer (const struct nros_param_server_t *server, const char *name, int64_t *value)
 Get an integer parameter value.
 
nros_ret_t nros_param_get_integer_array (const struct nros_param_server_t *server, const char *name, const int64_t **data, size_t *len)
 Get an integer array parameter (returns stored pointer + length).
 
nros_ret_t nros_param_get_string (const struct nros_param_server_t *server, const char *name, char *value, size_t max_len)
 Get a string parameter value.
 
nros_ret_t nros_param_get_string_array (const struct nros_param_server_t *server, const char *name, const char *const **data, size_t *len)
 Get a string array parameter (returns stored pointer + length).
 
enum nros_parameter_type_t nros_param_get_type (const struct nros_param_server_t *server, const char *name)
 Get the type of a parameter.
 
bool nros_param_has (const struct nros_param_server_t *server, const char *name)
 Check if a parameter exists.
 
nros_ret_t nros_param_server_fini (struct nros_param_server_t *server)
 Finalise a parameter server.
 
size_t nros_param_server_get_count (const struct nros_param_server_t *server)
 Get the number of declared parameters.
 
struct nros_param_server_t nros_param_server_get_zero_initialized (void)
 Get a zero-initialized parameter server.
 
nros_ret_t nros_param_server_init (struct nros_param_server_t *server, struct nros_parameter_t *storage, size_t capacity)
 Initialise a parameter server with user-provided storage.
 
nros_ret_t nros_param_server_set_callback (struct nros_param_server_t *server, nros_param_callback_t callback, void *context)
 Set a parameter change callback.
 
nros_ret_t nros_param_set_bool (struct nros_param_server_t *server, const char *name, bool value)
 Set a boolean parameter value.
 
nros_ret_t nros_param_set_bool_array (struct nros_param_server_t *server, const char *name, const bool *data, size_t len)
 Set a boolean array parameter (replaces stored pointer + length).
 
nros_ret_t nros_param_set_byte_array (struct nros_param_server_t *server, const char *name, const uint8_t *data, size_t len)
 Set a byte array parameter (replaces stored pointer + length).
 
nros_ret_t nros_param_set_double (struct nros_param_server_t *server, const char *name, double value)
 Set a double parameter value.
 
nros_ret_t nros_param_set_double_array (struct nros_param_server_t *server, const char *name, const double *data, size_t len)
 Set a double array parameter (replaces stored pointer + length).
 
nros_ret_t nros_param_set_integer (struct nros_param_server_t *server, const char *name, int64_t value)
 Set an integer parameter value.
 
nros_ret_t nros_param_set_integer_array (struct nros_param_server_t *server, const char *name, const int64_t *data, size_t len)
 Set an integer array parameter (replaces stored pointer + length).
 
nros_ret_t nros_param_set_string (struct nros_param_server_t *server, const char *name, const char *value)
 Set a string parameter value.
 
nros_ret_t nros_param_set_string_array (struct nros_param_server_t *server, const char *name, const char *const *data, size_t len)
 Set a string array parameter (replaces stored pointer + length).
 

Detailed Description

Parameter server API.

Declare, get, and set typed parameters on a local parameter server.

Function Documentation

◆ nros_executor_declare_param_bool()

nros_ret_t nros_executor_declare_param_bool ( struct nros_executor_t executor,
const char *  name,
bool  value 
)

Declare a boolean parameter on the executor's server.

◆ nros_executor_declare_param_double()

nros_ret_t nros_executor_declare_param_double ( struct nros_executor_t executor,
const char *  name,
double  value 
)

Declare a double parameter on the executor's server.

◆ nros_executor_declare_param_integer()

nros_ret_t nros_executor_declare_param_integer ( struct nros_executor_t executor,
const char *  name,
int64_t  value 
)

Declare an integer parameter on the executor's server.

◆ nros_executor_declare_param_string()

nros_ret_t nros_executor_declare_param_string ( struct nros_executor_t executor,
const char *  name,
const char *  value 
)

Declare a string parameter on the executor's server.

◆ nros_executor_get_param_bool()

nros_ret_t nros_executor_get_param_bool ( struct nros_executor_t executor,
const char *  name,
bool *  out_value 
)

Get a boolean parameter from the executor's server.

◆ nros_executor_get_param_double()

nros_ret_t nros_executor_get_param_double ( struct nros_executor_t executor,
const char *  name,
double *  out_value 
)

Get a double parameter from the executor's server.

◆ nros_executor_get_param_integer()

nros_ret_t nros_executor_get_param_integer ( struct nros_executor_t executor,
const char *  name,
int64_t *  out_value 
)

Get an integer parameter from the executor's server.

◆ nros_executor_get_param_string()

nros_ret_t nros_executor_get_param_string ( struct nros_executor_t executor,
const char *  name,
char *  out_value,
size_t  max_len 
)

Get a string parameter into a caller-provided null-terminated buffer.

◆ nros_executor_has_param()

bool nros_executor_has_param ( struct nros_executor_t executor,
const char *  name 
)

Check if a parameter exists on the executor's server.

◆ nros_executor_register_parameter_services()

nros_ret_t nros_executor_register_parameter_services ( struct nros_executor_t executor)

Register the 6 ROS 2 parameter services on the executor's node.

Creates service servers for:

  • ~/get_parameters
  • ~/set_parameters
  • ~/set_parameters_atomically
  • ~/list_parameters
  • ~/describe_parameters
  • ~/get_parameter_types

After this call, parameters declared via nros_executor_declare_param_*() are visible to ros2 param tooling.

◆ nros_executor_set_param_bool()

nros_ret_t nros_executor_set_param_bool ( struct nros_executor_t executor,
const char *  name,
bool  value 
)

Set a boolean parameter on the executor's server.

◆ nros_executor_set_param_double()

nros_ret_t nros_executor_set_param_double ( struct nros_executor_t executor,
const char *  name,
double  value 
)

Set a double parameter on the executor's server.

◆ nros_executor_set_param_integer()

nros_ret_t nros_executor_set_param_integer ( struct nros_executor_t executor,
const char *  name,
int64_t  value 
)

Set an integer parameter on the executor's server.

◆ nros_executor_set_param_string()

nros_ret_t nros_executor_set_param_string ( struct nros_executor_t executor,
const char *  name,
const char *  value 
)

Set a string parameter on the executor's server.

◆ nros_param_declare_bool()

nros_ret_t nros_param_declare_bool ( struct nros_param_server_t server,
const char *  name,
bool  default_value 
)

Declare a boolean parameter.

Parameters
serverPointer to an initialized parameter server.
nameParameter name (null-terminated).
default_valueDefault boolean value.
Return values
NROS_RET_OKon success.

◆ nros_param_declare_bool_array()

nros_ret_t nros_param_declare_bool_array ( struct nros_param_server_t server,
const char *  name,
const bool *  data,
size_t  len 
)

Declare a boolean array parameter (bool[]).

◆ nros_param_declare_byte_array()

nros_ret_t nros_param_declare_byte_array ( struct nros_param_server_t server,
const char *  name,
const uint8_t *  data,
size_t  len 
)

Declare a byte array parameter (uint8_t[]).

◆ nros_param_declare_double()

nros_ret_t nros_param_declare_double ( struct nros_param_server_t server,
const char *  name,
double  default_value 
)

Declare a double parameter.

Parameters
serverPointer to an initialized parameter server.
nameParameter name (null-terminated).
default_valueDefault double value.
Return values
NROS_RET_OKon success.

◆ nros_param_declare_double_array()

nros_ret_t nros_param_declare_double_array ( struct nros_param_server_t server,
const char *  name,
const double *  data,
size_t  len 
)

Declare a double array parameter (double[]).

◆ nros_param_declare_integer()

nros_ret_t nros_param_declare_integer ( struct nros_param_server_t server,
const char *  name,
int64_t  default_value 
)

Declare an integer parameter.

Parameters
serverPointer to an initialized parameter server.
nameParameter name (null-terminated).
default_valueDefault integer value.
Return values
NROS_RET_OKon success.

◆ nros_param_declare_integer_array()

nros_ret_t nros_param_declare_integer_array ( struct nros_param_server_t server,
const char *  name,
const int64_t *  data,
size_t  len 
)

Declare an integer array parameter (int64_t[]).

◆ nros_param_declare_string()

nros_ret_t nros_param_declare_string ( struct nros_param_server_t server,
const char *  name,
const char *  default_value 
)

Declare a string parameter.

Parameters
serverPointer to an initialized parameter server.
nameParameter name (null-terminated).
default_valueDefault string value (null-terminated).
Return values
NROS_RET_OKon success.

◆ nros_param_declare_string_array()

nros_ret_t nros_param_declare_string_array ( struct nros_param_server_t server,
const char *  name,
const char *const *  data,
size_t  len 
)

Declare a string array parameter (array of const char*).

◆ nros_param_get_bool()

nros_ret_t nros_param_get_bool ( const struct nros_param_server_t server,
const char *  name,
bool *  value 
)

Get a boolean parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueOutput: parameter value.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_get_bool_array()

nros_ret_t nros_param_get_bool_array ( const struct nros_param_server_t server,
const char *  name,
const bool **  data,
size_t *  len 
)

Get a boolean array parameter (returns stored pointer + length).

◆ nros_param_get_byte_array()

nros_ret_t nros_param_get_byte_array ( const struct nros_param_server_t server,
const char *  name,
const uint8_t **  data,
size_t *  len 
)

Get a byte array parameter (returns stored pointer + length).

◆ nros_param_get_double()

nros_ret_t nros_param_get_double ( const struct nros_param_server_t server,
const char *  name,
double *  value 
)

Get a double parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueOutput: parameter value.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_get_double_array()

nros_ret_t nros_param_get_double_array ( const struct nros_param_server_t server,
const char *  name,
const double **  data,
size_t *  len 
)

Get a double array parameter (returns stored pointer + length).

◆ nros_param_get_integer()

nros_ret_t nros_param_get_integer ( const struct nros_param_server_t server,
const char *  name,
int64_t *  value 
)

Get an integer parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueOutput: parameter value.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_get_integer_array()

nros_ret_t nros_param_get_integer_array ( const struct nros_param_server_t server,
const char *  name,
const int64_t **  data,
size_t *  len 
)

Get an integer array parameter (returns stored pointer + length).

◆ nros_param_get_string()

nros_ret_t nros_param_get_string ( const struct nros_param_server_t server,
const char *  name,
char *  value,
size_t  max_len 
)

Get a string parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueOutput buffer for the string.
max_lenMaximum length of the output buffer.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_get_string_array()

nros_ret_t nros_param_get_string_array ( const struct nros_param_server_t server,
const char *  name,
const char *const **  data,
size_t *  len 
)

Get a string array parameter (returns stored pointer + length).

◆ nros_param_get_type()

enum nros_parameter_type_t nros_param_get_type ( const struct nros_param_server_t server,
const char *  name 
)

Get the type of a parameter.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
Returns
Parameter type, or NROS_PARAMETER_NOT_SET if not found.

◆ nros_param_has()

bool nros_param_has ( const struct nros_param_server_t server,
const char *  name 
)

Check if a parameter exists.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
Returns
true if the parameter exists, false otherwise.

◆ nros_param_server_fini()

nros_ret_t nros_param_server_fini ( struct nros_param_server_t server)

Finalise a parameter server.

Parameters
serverPointer to an initialized parameter server.
Return values
NROS_RET_OKon success.

◆ nros_param_server_get_count()

size_t nros_param_server_get_count ( const struct nros_param_server_t server)

Get the number of declared parameters.

Parameters
serverPointer to an initialized parameter server.
Returns
Number of parameters.

◆ nros_param_server_get_zero_initialized()

struct nros_param_server_t nros_param_server_get_zero_initialized ( void  )

Get a zero-initialized parameter server.

Returns
Zero-initialized nros_param_server_t.

◆ nros_param_server_init()

nros_ret_t nros_param_server_init ( struct nros_param_server_t server,
struct nros_parameter_t storage,
size_t  capacity 
)

Initialise a parameter server with user-provided storage.

Parameters
serverPointer to a zero-initialized parameter server.
storagePointer to a user-provided parameter array.
capacityMaximum number of parameters the array can hold.
Return values
NROS_RET_OKon success.

◆ nros_param_server_set_callback()

nros_ret_t nros_param_server_set_callback ( struct nros_param_server_t server,
nros_param_callback_t  callback,
void *  context 
)

Set a parameter change callback.

Parameters
serverPointer to an initialized parameter server.
callbackCallback function, or NULL to clear.
contextUser context.
Return values
NROS_RET_OKon success.

◆ nros_param_set_bool()

nros_ret_t nros_param_set_bool ( struct nros_param_server_t server,
const char *  name,
bool  value 
)

Set a boolean parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueNew boolean value.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_set_bool_array()

nros_ret_t nros_param_set_bool_array ( struct nros_param_server_t server,
const char *  name,
const bool *  data,
size_t  len 
)

Set a boolean array parameter (replaces stored pointer + length).

◆ nros_param_set_byte_array()

nros_ret_t nros_param_set_byte_array ( struct nros_param_server_t server,
const char *  name,
const uint8_t *  data,
size_t  len 
)

Set a byte array parameter (replaces stored pointer + length).

◆ nros_param_set_double()

nros_ret_t nros_param_set_double ( struct nros_param_server_t server,
const char *  name,
double  value 
)

Set a double parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueNew double value.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_set_double_array()

nros_ret_t nros_param_set_double_array ( struct nros_param_server_t server,
const char *  name,
const double *  data,
size_t  len 
)

Set a double array parameter (replaces stored pointer + length).

◆ nros_param_set_integer()

nros_ret_t nros_param_set_integer ( struct nros_param_server_t server,
const char *  name,
int64_t  value 
)

Set an integer parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueNew integer value.
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_set_integer_array()

nros_ret_t nros_param_set_integer_array ( struct nros_param_server_t server,
const char *  name,
const int64_t *  data,
size_t  len 
)

Set an integer array parameter (replaces stored pointer + length).

◆ nros_param_set_string()

nros_ret_t nros_param_set_string ( struct nros_param_server_t server,
const char *  name,
const char *  value 
)

Set a string parameter value.

Parameters
serverPointer to an initialized parameter server.
nameParameter name.
valueNew string value (null-terminated).
Return values
NROS_RET_OKon success.
NROS_RET_NOT_FOUNDif the parameter does not exist.

◆ nros_param_set_string_array()

nros_ret_t nros_param_set_string_array ( struct nros_param_server_t server,
const char *  name,
const char *const *  data,
size_t  len 
)

Set a string array parameter (replaces stored pointer + length).