15 #ifndef RCLCPP__UTILITIES_HPP_
16 #define RCLCPP__UTILITIES_HPP_
24 #include "rclcpp/context.hpp"
25 #include "rclcpp/contexts/default_context.hpp"
26 #include "rclcpp/init_options.hpp"
27 #include "rclcpp/visibility_control.hpp"
37 std::ostringstream os;
78 char const *
const * argv,
79 const InitOptions & init_options = InitOptions(),
140 std::vector<std::string>
143 char const *
const * argv,
144 const InitOptions & init_options = InitOptions());
160 std::vector<std::string>
177 ok(
const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
196 const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context(),
197 const std::string & reason =
"user called rclcpp::shutdown()");
217 const std::function<
void()> & callback,
218 const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
236 const std::chrono::nanoseconds & nanoseconds,
237 const rclcpp::Context::SharedPtr & context = rclcpp::contexts::get_global_default_context());
253 return (y > 0) && (x > (std::numeric_limits<T>::max() - y));
270 return (y < 0) && (x < (std::numeric_limits<T>::min() - y));
287 return (y < 0) && (x > (std::numeric_limits<T>::max() + y));
304 return (y > 0) && (x < (std::numeric_limits<T>::min() + y));
333 std::vector<const char *>
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC void init(int argc, char const *const *argv, const InitOptions &init_options=InitOptions(), SignalHandlerOptions signal_handler_options=SignalHandlerOptions::All)
Initialize communications via the rmw implementation and set up a global signal handler.
RCLCPP_PUBLIC std::string to_string(const FutureReturnCode &future_return_code)
String conversion function for FutureReturnCode.
SignalHandlerOptions
Option to indicate which signal handlers rclcpp should install.
@ SigTerm
Install only a sigterm handler.
@ None
Do not install any signal handler.
@ All
Install both sigint and sigterm, this is the default behavior.
@ SigInt
Install only a sigint handler.
RCLCPP_PUBLIC bool ok(const rclcpp::Context::SharedPtr &context=rclcpp::contexts::get_global_default_context())
Check rclcpp's status.
bool add_will_underflow(const T x, const T y)
Safely check if addition will underflow.
RCLCPP_PUBLIC bool signal_handlers_installed()
Return true if the signal handlers are installed, otherwise false.
RCLCPP_PUBLIC bool sleep_for(const std::chrono::nanoseconds &nanoseconds, const rclcpp::Context::SharedPtr &context=rclcpp::contexts::get_global_default_context())
Use the global condition variable to block for the specified amount of time.
RCLCPP_PUBLIC std::vector< std::string > remove_ros_arguments(int argc, char const *const *argv)
Remove ROS-specific arguments from argument vector.
RCLCPP_PUBLIC std::vector< std::string > init_and_remove_ros_arguments(int argc, char const *const *argv, const InitOptions &init_options=InitOptions())
Initialize communications via the rmw implementation and set up a global signal handler.
RCLCPP_PUBLIC std::vector< const char * > get_c_vector_string(const std::vector< std::string > &strings_in)
Return the std::vector of C string from the given std::vector<std::string>.
RCLCPP_PUBLIC bool install_signal_handlers(SignalHandlerOptions signal_handler_options=SignalHandlerOptions::All)
Install the global signal handler for rclcpp.
bool sub_will_overflow(const T x, const T y)
Safely check if subtraction will overflow.
RCLCPP_PUBLIC const char * get_c_string(const char *string_in)
Return the given string.
RCLCPP_PUBLIC SignalHandlerOptions get_current_signal_handler_options()
Get the current signal handler options.
RCLCPP_PUBLIC void on_shutdown(const std::function< void()> &callback, const rclcpp::Context::SharedPtr &context=rclcpp::contexts::get_global_default_context())
Register a function to be called when shutdown is called on the context.
RCLCPP_PUBLIC bool uninstall_signal_handlers()
Uninstall the global signal handler for rclcpp.
RCLCPP_PUBLIC bool shutdown(const rclcpp::Context::SharedPtr &context=rclcpp::contexts::get_global_default_context(), const std::string &reason="user called rclcpp::shutdown()")
Shutdown rclcpp context, invalidating it for derived entities.
bool add_will_overflow(const T x, const T y)
Safely check if addition will overflow.
bool sub_will_underflow(const T x, const T y)
Safely check if subtraction will underflow.