Skip to content

Commit ffa394f

Browse files
fix(autoware_overlay_rviz_plugin): topic type of traffic light (#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>
1 parent 39c8461 commit ffa394f

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
@@ -103,8 +103,7 @@ private Q_SLOTS:
103103
turn_signals_sub_;
104104
rclcpp::Subscription<autoware_vehicle_msgs::msg::HazardLightsReport>::SharedPtr
105105
hazard_lights_sub_;
106-
rclcpp::Subscription<autoware_perception_msgs::msg::TrafficLightGroupArray>::SharedPtr
107-
traffic_sub_;
106+
rclcpp::Subscription<autoware_perception_msgs::msg::TrafficLightGroup>::SharedPtr traffic_sub_;
108107
rclcpp::Subscription<tier4_planning_msgs::msg::VelocityLimit>::SharedPtr speed_limit_sub_;
109108

110109
std::mutex property_mutex_;
@@ -118,7 +117,7 @@ private Q_SLOTS:
118117
const autoware_vehicle_msgs::msg::HazardLightsReport::ConstSharedPtr & msg);
119118
void updateSpeedLimitData(const tier4_planning_msgs::msg::VelocityLimit::ConstSharedPtr msg);
120119
void updateTrafficLightData(
121-
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr msg);
120+
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr msg);
122121
void drawWidget(QImage & hud);
123122
};
124123
} // 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
@@ -112,9 +112,10 @@ void SignalDisplay::onInitialize()
112112
speed_limit_topic_property_->initialize(rviz_ros_node);
113113

114114
traffic_topic_property_ = std::make_unique<rviz_common::properties::RosTopicProperty>(
115-
"Traffic Topic", "/perception/traffic_light_recognition/traffic_signals",
116-
"autoware_perception_msgs/msgs/msg/TrafficLightGroupArray", "Topic for Traffic Light Data",
117-
this, SLOT(topic_updated_traffic()));
115+
"Traffic Topic",
116+
"/planning/scenario_planning/lane_driving/behavior_planning/debug/traffic_signal",
117+
"autoware_perception_msgs/msgs/msg/TrafficLightGroup", "Topic for Traffic Light Data", this,
118+
SLOT(topic_updated_traffic()));
118119
traffic_topic_property_->initialize(rviz_ros_node);
119120
}
120121

@@ -192,7 +193,7 @@ void SignalDisplay::onDisable()
192193
}
193194

194195
void SignalDisplay::updateTrafficLightData(
195-
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr msg)
196+
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr msg)
196197
{
197198
std::lock_guard<std::mutex> lock(property_mutex_);
198199

@@ -458,14 +459,13 @@ void SignalDisplay::topic_updated_traffic()
458459
// resubscribe to the topic
459460
traffic_sub_.reset();
460461
auto rviz_ros_node = context_->getRosNodeAbstraction().lock();
461-
traffic_sub_ =
462-
rviz_ros_node->get_raw_node()
463-
->create_subscription<autoware_perception_msgs::msg::TrafficLightGroupArray>(
464-
traffic_topic_property_->getTopicStd(),
465-
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable(),
466-
[this](const autoware_perception_msgs::msg::TrafficLightGroupArray::SharedPtr msg) {
467-
updateTrafficLightData(msg);
468-
});
462+
traffic_sub_ = rviz_ros_node->get_raw_node()
463+
->create_subscription<autoware_perception_msgs::msg::TrafficLightGroup>(
464+
traffic_topic_property_->getTopicStd(),
465+
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable(),
466+
[this](const autoware_perception_msgs::msg::TrafficLightGroup::SharedPtr msg) {
467+
updateTrafficLightData(msg);
468+
});
469469
}
470470

471471
} // 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)