rclcpp  master
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 
49 
54 void
55 init(int argc, char * argv[]);
56 
58 
60 bool
61 ok();
62 
65 void
66 shutdown();
67 
69 
71 void
72 on_shutdown(std::function<void(void)> callback);
73 
75 
89 
91 
100 void
102 
104 
109 bool
110 sleep_for(const std::chrono::nanoseconds & nanoseconds);
111 
112 } // namespace rclcpp
113 
114 #endif // RCLCPP__UTILITIES_HPP_
void init(int argc, char *argv[])
Initialize communications via the rmw implementation and set up a global signal handler.
rcl_guard_condition_t * get_sigint_guard_condition(rcl_wait_set_t *wait_set)
Get a handle to the rmw guard condition that manages the signal handler.
T to_string(T... args)
Definition: allocator_common.hpp:24
bool sleep_for(const std::chrono::nanoseconds &nanoseconds)
Use the global condition variable to block for the specified amount of time.
void release_sigint_guard_condition(rcl_wait_set_t *wait_set)
Release the previously allocated guard condition that manages the signal handler. ...
void shutdown()
Notify the signal handler and rmw that rclcpp is shutting down.
void on_shutdown(std::function< void(void)> callback)
Register a function to be called when shutdown is called.
T str(T... args)
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
bool ok()
Check rclcpp&#39;s status.