rclcpp  beta1
C++ ROS Client Library API
utilities.hpp
Go to the documentation of this file.
1 // Copyright 2014 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__UTILITIES_HPP_
16 #define RCLCPP__UTILITIES_HPP_
17 
18 #include <chrono>
19 #include <functional>
20 
22 
23 #include "rcl/guard_condition.h"
24 #include "rcl/wait.h"
25 
26 #include "rmw/macros.h"
27 #include "rmw/rmw.h"
28 
29 #ifdef ANDROID
30 #include <string>
31 #include <sstream>
32 
33 namespace std
34 {
35 template<typename T>
36 std::string to_string(T value)
37 {
39  os << value;
40  return os.str();
41 }
42 }
43 #endif
44 
45 namespace rclcpp
46 {
47 namespace utilities
48 {
49 
51 
56 void
57 init(int argc, char * argv[]);
58 
60 
62 bool
63 ok();
64 
67 void
68 shutdown();
69 
71 
73 void
74 on_shutdown(std::function<void(void)> callback);
75 
77 
91 
93 
102 void
104 
106 
111 bool
112 sleep_for(const std::chrono::nanoseconds & nanoseconds);
113 
114 } // namespace utilities
115 } // namespace rclcpp
116 
117 #endif // RCLCPP__UTILITIES_HPP_
bool ok()
Check rclcpp&#39;s status.
void init(int argc, char *argv[])
Initialize communications via the rmw implementation and set up a global signal handler.
T to_string(T... args)
Definition: allocator_common.hpp:24
T str(T... args)
bool sleep_for(const std::chrono::nanoseconds &nanoseconds)
Use the global condition variable to block for the specified amount of time.
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
void shutdown()
Notify the signal handler and rmw that rclcpp is shutting down.
void release_sigint_guard_condition(rcl_wait_set_t *waitset)
Release the previously allocated guard condition that manages the signal handler. ...
void on_shutdown(std::function< void(void)> callback)
Register a function to be called when shutdown is called.
rcl_guard_condition_t * get_sigint_guard_condition(rcl_wait_set_t *waitset)
Get a handle to the rmw guard condition that manages the signal handler.