15 #ifndef RCLCPP__UTILITIES_HPP_
16 #define RCLCPP__UTILITIES_HPP_
24 #include "rclcpp/context.hpp"
25 #include "rclcpp/init_options.hpp"
26 #include "rclcpp/visibility_control.hpp"
36 std::ostringstream os;
77 char const *
const * argv,
78 const InitOptions & init_options = InitOptions(),
139 std::vector<std::string>
142 char const *
const * argv,
143 const InitOptions & init_options = InitOptions());
159 std::vector<std::string>
176 ok(rclcpp::Context::SharedPtr context =
nullptr);
195 rclcpp::Context::SharedPtr context =
nullptr,
196 const std::string & reason =
"user called rclcpp::shutdown()");
215 on_shutdown(std::function<
void()> callback, rclcpp::Context::SharedPtr context =
nullptr);
233 const std::chrono::nanoseconds & nanoseconds,
234 rclcpp::Context::SharedPtr context =
nullptr);
250 return (y > 0) && (x > (std::numeric_limits<T>::max() - y));
267 return (y < 0) && (x < (std::numeric_limits<T>::min() - y));
284 return (y < 0) && (x > (std::numeric_limits<T>::max() + y));
301 return (y > 0) && (x < (std::numeric_limits<T>::min() + y));
330 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.
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 void on_shutdown(std::function< void()> callback, rclcpp::Context::SharedPtr context=nullptr)
Register a function to be called when shutdown is called on the context.
RCLCPP_PUBLIC bool sleep_for(const std::chrono::nanoseconds &nanoseconds, rclcpp::Context::SharedPtr context=nullptr)
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.
RCLCPP_PUBLIC bool shutdown(rclcpp::Context::SharedPtr context=nullptr, const std::string &reason="user called rclcpp::shutdown()")
Shutdown rclcpp context, invalidating it for derived entities.
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 bool ok(rclcpp::Context::SharedPtr context=nullptr)
Check rclcpp's status.
RCLCPP_PUBLIC SignalHandlerOptions get_current_signal_handler_options()
Get the current signal handler options.
RCLCPP_PUBLIC bool uninstall_signal_handlers()
Uninstall the global signal handler for rclcpp.
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.