Skip to content

Commit 382f32c

Browse files
fix(autoware_overlay_rviz_plugin): topic type of traffic light (autowarefoundation#8098)
* fix(autoware_overlay_rviz_plugin): topic type of traffic light Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> * style(pre-commit): autofix --------- Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Signed-off-by: Tomohito ANDO <tomohito.ando@tier4.jp>
1 parent a363f9e commit 382f32c

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

common/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/include/signal_display.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ private Q_SLOTS:
102102
turn_signals_sub_;
103103
rclcpp::Subscription<autoware_vehicle_msgs::msg::HazardLightsReport>::SharedPtr
104104
hazard_lights_sub_;
105-
rclcpp::Subscription<autoware_perception_msgs::msg::TrafficLightGroupArray>::SharedPtr
106-
traffic_sub_;
105+
rclcpp::Subscription<autoware_perception_msgs::msg::TrafficLightGroup>::SharedPtr traffic_sub_;
107106
rclcpp::Subscription<tier4_planning_msgs::msg::VelocityLimit>::SharedPtr speed_limit_sub_;
108107

109108
std::mutex property_mutex_;
@@ -117,7 +116,7 @@ private Q_SLOTS:
117116
const autoware_vehicle_msgs::msg::HazardLightsReport::ConstSharedPtr & msg);
118117
void updateSpeedLimitData(const tier4_planning_msgs::msg::VelocityLimit::ConstSharedPtr msg);
119118
void updateTrafficLightData(
120-
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr msg);
119+
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr msg);
121120
void drawWidget(QImage & hud);
122121
};
123122
} // namespace autoware_overlay_rviz_plugin

common/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/include/traffic_display.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include <autoware_perception_msgs/msg/traffic_light_element.hpp>
2727
#include <autoware_perception_msgs/msg/traffic_light_group.hpp>
28-
#include <autoware_perception_msgs/msg/traffic_light_group_array.hpp>
2928

3029
#include <OgreColourValue.h>
3130
#include <OgreMaterial.h>
@@ -40,8 +39,8 @@ class TrafficDisplay
4039
TrafficDisplay();
4140
void drawTrafficLightIndicator(QPainter & painter, const QRectF & backgroundRect);
4241
void updateTrafficLightData(
43-
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr & msg);
44-
autoware_perception_msgs::msg::TrafficLightGroupArray current_traffic_;
42+
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr & msg);
43+
autoware_perception_msgs::msg::TrafficLightGroup current_traffic_;
4544

4645
private:
4746
QImage traffic_light_image_;

common/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/signal_display.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ void SignalDisplay::onInitialize()
109109
speed_limit_topic_property_->initialize(rviz_ros_node);
110110

111111
traffic_topic_property_ = std::make_unique<rviz_common::properties::RosTopicProperty>(
112-
"Traffic Topic", "/perception/traffic_light_recognition/traffic_signals",
113-
"autoware_perception_msgs/msgs/msg/TrafficLightGroupArray", "Topic for Traffic Light Data",
114-
this, SLOT(topic_updated_traffic()));
112+
"Traffic Topic",
113+
"/planning/scenario_planning/lane_driving/behavior_planning/debug/traffic_signal",
114+
"autoware_perception_msgs/msgs/msg/TrafficLightGroup", "Topic for Traffic Light Data", this,
115+
SLOT(topic_updated_traffic()));
115116
traffic_topic_property_->initialize(rviz_ros_node);
116117
}
117118

@@ -189,7 +190,7 @@ void SignalDisplay::onDisable()
189190
}
190191

191192
void SignalDisplay::updateTrafficLightData(
192-
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr msg)
193+
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr msg)
193194
{
194195
std::lock_guard<std::mutex> lock(property_mutex_);
195196

@@ -454,14 +455,13 @@ void SignalDisplay::topic_updated_traffic()
454455
// resubscribe to the topic
455456
traffic_sub_.reset();
456457
auto rviz_ros_node = context_->getRosNodeAbstraction().lock();
457-
traffic_sub_ =
458-
rviz_ros_node->get_raw_node()
459-
->create_subscription<autoware_perception_msgs::msg::TrafficLightGroupArray>(
460-
traffic_topic_property_->getTopicStd(),
461-
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable(),
462-
[this](const autoware_perception_msgs::msg::TrafficLightGroupArray::SharedPtr msg) {
463-
updateTrafficLightData(msg);
464-
});
458+
traffic_sub_ = rviz_ros_node->get_raw_node()
459+
->create_subscription<autoware_perception_msgs::msg::TrafficLightGroup>(
460+
traffic_topic_property_->getTopicStd(),
461+
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable(),
462+
[this](const autoware_perception_msgs::msg::TrafficLightGroup::SharedPtr msg) {
463+
updateTrafficLightData(msg);
464+
});
465465
}
466466

467467
} // namespace autoware_overlay_rviz_plugin

common/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/traffic_display.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ TrafficDisplay::TrafficDisplay()
4848
}
4949

5050
void TrafficDisplay::updateTrafficLightData(
51-
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr & msg)
51+
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr & msg)
5252
{
5353
current_traffic_ = *msg;
5454
}
@@ -68,8 +68,8 @@ void TrafficDisplay::drawTrafficLightIndicator(QPainter & painter, const QRectF
6868
backgroundRect.top() + circleRect.height() / 2));
6969
painter.drawEllipse(circleRect);
7070

71-
if (!current_traffic_.traffic_light_groups.empty()) {
72-
switch (current_traffic_.traffic_light_groups[0].elements[0].color) {
71+
if (!current_traffic_.elements.empty()) {
72+
switch (current_traffic_.elements[0].color) {
7373
case 1:
7474
painter.setBrush(QBrush(tl_red_));
7575
painter.drawEllipse(circleRect);

0 commit comments

Comments
 (0)