include
pilz_utils
wait_for_message.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_MESSAGE_H
18
#define PILZ_UTILS_WAIT_FOR_MESSAGE_H
19
20
#include <string>
21
22
#include <
ros/duration.h
>
23
#include <
ros/ros.h
>
24
25
#include <
pilz_utils/wait_for_timeouts.h
>
26
27
namespace
pilz_utils
28
{
32
template
<
class
T>
33
static
void
waitForMessage
(
const
std::string topic_name,
34
const
double
retry_timeout =
DEFAULT_RETRY_TIMEOUT
,
35
const
double
msg_output_period =
DEFAULT_MSG_OUTPUT_PERIOD
)
36
{
37
while
((ros::topic::waitForMessage<T>(topic_name,
ros::Duration
(retry_timeout)) ==
nullptr
) &&
ros::ok
())
38
{
39
ROS_DEBUG_STREAM_DELAYED_THROTTLE
(msg_output_period,
"Waiting for message on topic \""
+ topic_name +
"\"..."
);
40
}
41
}
42
43
}
// namespace pilz_utils
44
45
#endif // PILZ_UTILS_WAIT_FOR_MESSAGE_H
wait_for_timeouts.h
pilz_utils::DEFAULT_MSG_OUTPUT_PERIOD
static constexpr double DEFAULT_MSG_OUTPUT_PERIOD
Definition:
wait_for_timeouts.h:23
pilz_utils::waitForMessage
static void waitForMessage(const std::string topic_name, const double retry_timeout=DEFAULT_RETRY_TIMEOUT, const double msg_output_period=DEFAULT_MSG_OUTPUT_PERIOD)
Waits (infinitely) until a message arrives on the specified topic.
Definition:
wait_for_message.h:33
pilz_utils::DEFAULT_RETRY_TIMEOUT
static constexpr double DEFAULT_RETRY_TIMEOUT
Definition:
wait_for_timeouts.h:22
ros::ok
ROSCPP_DECL bool ok()
ROS_DEBUG_STREAM_DELAYED_THROTTLE
#define ROS_DEBUG_STREAM_DELAYED_THROTTLE(period, args)
ros.h
duration.h
ros::Duration
pilz_utils
Definition:
get_param.h:26
pilz_utils
Author(s):
autogenerated on Mon Feb 28 2022 23:13:40