Skip to content

Commit 65bd3f5

Browse files
committed
feat(tier4_autoware_utils): add published time debug class into utils
Signed-off-by: Berkay Karaman <brkay54@gmail.com>
1 parent b56f132 commit 65bd3f5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2020 Tier IV, 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 TIER4_AUTOWARE_UTILS__ROS__PUBLISHED_TIME_PUBLISHER_HPP_
16+
#define TIER4_AUTOWARE_UTILS__ROS__PUBLISHED_TIME_PUBLISHER_HPP_
17+
18+
#include <rclcpp/rclcpp.hpp>
19+
20+
#include <autoware_common_msgs/msg/published_time.hpp>
21+
22+
namespace tier4_autoware_utils
23+
{
24+
using autoware_common_msgs::msg::PublishedTime;
25+
26+
class PublishedTimePublisher
27+
{
28+
public:
29+
explicit PublishedTimePublisher(
30+
rclcpp::Node * node, const std::string & name = "~/debug/published_time",
31+
const rclcpp::QoS & qos = rclcpp::QoS(1))
32+
{
33+
pub_published_time_ = node->create_publisher<PublishedTime>(name, qos);
34+
}
35+
36+
void publish(const rclcpp::Time & header_stamp) const
37+
{
38+
PublishedTime published_time;
39+
40+
published_time.header_stamp = header_stamp;
41+
published_time.published_stamp = rclcpp::Clock().now();
42+
43+
pub_published_time_->publish(published_time);
44+
}
45+
46+
private:
47+
rclcpp::Publisher<PublishedTime>::SharedPtr pub_published_time_;
48+
};
49+
} // namespace tier4_autoware_utils
50+
51+
#endif // TIER4_AUTOWARE_UTILS__ROS__PUBLISHED_TIME_PUBLISHER_HPP_

common/tier4_autoware_utils/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<depend>autoware_auto_perception_msgs</depend>
1616
<depend>autoware_auto_planning_msgs</depend>
1717
<depend>autoware_auto_vehicle_msgs</depend>
18+
<depend>autoware_common_msgs</depend>
1819
<depend>builtin_interfaces</depend>
1920
<depend>diagnostic_msgs</depend>
2021
<depend>geometry_msgs</depend>

0 commit comments

Comments
 (0)