ROS 2 rclcpp + rcl - rolling
rolling-a919a6e5
ROS 2 C++ Client Library with ROS Client Library
|
#include "rcl/allocator.h"
#include "rcl/context.h"
#include "rcl/init_options.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
Go to the source code of this file.
Functions | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_init (int argc, char const *const *argv, const rcl_init_options_t *options, rcl_context_t *context) |
Initialization of rcl. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t | rcl_shutdown (rcl_context_t *context) |
Shutdown a given rcl context. More... | |
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_init | ( | int | argc, |
char const *const * | argv, | ||
const rcl_init_options_t * | options, | ||
rcl_context_t * | context | ||
) |
Initialization of rcl.
This function can be run any number of times, so long as the given context has been properly prepared.
The given rcl_context_t must be zero initialized with the function rcl_get_zero_initialized_context() and must not be already initialized by this function. If the context is already initialized this function will fail and return the RCL_RET_ALREADY_INIT error code. A context may be initialized again after it has been finalized with the rcl_shutdown() function and zero initialized again with rcl_get_zero_initialized_context().
The argc
and argv
parameters may contain command line arguments for the program. rcl specific arguments will be parsed, but not removed. If argc
is 0
and argv
is NULL
no parameters will be parsed.
The options
argument must be non-NULL
and must have been initialized with rcl_init_options_init(). It is unmodified by this function, and the ownership is not transfered to the context, but instead a copy is made into the context for later reference. Therefore, the given options need to be cleaned up with rcl_init_options_fini() after this function returns.
Attribute | Adherence |
---|---|
Allocates Memory | Yes |
Thread-Safe | No |
Uses Atomics | Yes |
Lock-Free | Yes [1] |
[1] if atomic_is_lock_free()
returns true for atomic_uint_least64_t
[in] | argc | number of strings in argv |
[in] | argv | command line arguments; rcl specific arguments are removed |
[in] | options | options used during initialization |
[out] | context | resulting context object that represents this init |
Definition at line 46 of file init.c.
References rcl_context_impl_s::allocator, rcl_context_impl_s::argc, rcl_context_impl_s::argv, rcl_arguments_impl_s::enclave, rcl_context_s::global_arguments, rcl_arguments_s::impl, rcl_context_s::impl, rcl_init_options_s::impl, rcl_context_impl_s::init_options, rcl_automatic_discovery_range_to_string(), RCL_CHECK_ALLOCATOR, RCL_DEFAULT_DOMAIN_ID, RCL_ENCLAVE_NAME_VALID, rcl_enclave_name_validation_result_string(), rcl_get_automatic_discovery_range(), rcl_get_default_domain_id(), rcl_get_discovery_static_peers(), rcl_get_security_options_from_environment(), rcl_get_zero_initialized_arguments(), rcl_init_options_copy(), rcl_parse_arguments(), RCL_RET_ALREADY_INIT, RCL_RET_BAD_ALLOC, RCL_RET_ERROR, RCL_RET_INVALID_ARGUMENT, RCL_RET_OK, rcl_validate_enclave_name(), and rcl_context_impl_s::rmw_context.
Referenced by rclcpp::Context::init().
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_shutdown | ( | rcl_context_t * | context | ) |
Shutdown a given rcl context.
The given context must have been initialized with rcl_init(). If not, this function will fail with RCL_RET_ALREADY_SHUTDOWN.
When this function is called:
false
.Attribute | Adherence |
---|---|
Allocates Memory | Yes |
Thread-Safe | Yes |
Uses Atomics | Yes |
Lock-Free | Yes [1] |
[1] if atomic_is_lock_free()
returns true for atomic_uint_least64_t
[in,out] | context | object to shutdown |
Definition at line 281 of file init.c.
References rcl_context_s::impl, rcl_context_is_valid(), RCL_RET_ALREADY_SHUTDOWN, RCL_RET_INVALID_ARGUMENT, RCL_RET_OK, and rcl_context_impl_s::rmw_context.
Referenced by rclcpp::Context::init(), and rclcpp::Context::shutdown().