wait_for_service.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Pilz GmbH & Co. KG
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef PILZ_UTILS_WAIT_FOR_SERVICE_H
18 #define PILZ_UTILS_WAIT_FOR_SERVICE_H
19 
20 #include <string>
21 
22 #include <ros/duration.h>
23 #include <ros/ros.h>
24 
26 
27 namespace pilz_utils
28 {
32 static inline void waitForService(const std::string service_name,
33  const double retry_timeout = DEFAULT_RETRY_TIMEOUT,
34  const double msg_output_period = DEFAULT_MSG_OUTPUT_PERIOD)
35 {
36  while (!ros::service::waitForService(service_name, ros::Duration(retry_timeout)) && ros::ok())
37  {
38  ROS_WARN_STREAM_DELAYED_THROTTLE(msg_output_period, "Waiting for service \"" + service_name + "\"...");
39  }
40 }
41 
42 } // namespace pilz_utils
43 
44 #endif // PILZ_UTILS_WAIT_FOR_SERVICE_H
static constexpr double DEFAULT_MSG_OUTPUT_PERIOD
static constexpr double DEFAULT_RETRY_TIMEOUT
static void waitForService(const std::string service_name, const double retry_timeout=DEFAULT_RETRY_TIMEOUT, const double msg_output_period=DEFAULT_MSG_OUTPUT_PERIOD)
Waits until the specified service starts.
ROSCPP_DECL bool ok()
#define ROS_WARN_STREAM_DELAYED_THROTTLE(period, args)
ROSCPP_DECL bool waitForService(const std::string &service_name, int32_t timeout)


pilz_utils
Author(s):
autogenerated on Sun Jan 24 2021 03:55:46