Skip to content

Commit

Permalink
fix(autoware_overlay_rviz_plugin): topic type of traffic light (#8098)
Browse files Browse the repository at this point in the history
* fix(autoware_overlay_rviz_plugin): topic type of traffic light

Signed-off-by: Tomohito Ando <[email protected]>

* style(pre-commit): autofix

---------

Signed-off-by: Tomohito Ando <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
TomohitoAndo and pre-commit-ci[bot] authored Jul 19, 2024
1 parent 39c8461 commit ffa394f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ private Q_SLOTS:
turn_signals_sub_;
rclcpp::Subscription<autoware_vehicle_msgs::msg::HazardLightsReport>::SharedPtr
hazard_lights_sub_;
rclcpp::Subscription<autoware_perception_msgs::msg::TrafficLightGroupArray>::SharedPtr
traffic_sub_;
rclcpp::Subscription<autoware_perception_msgs::msg::TrafficLightGroup>::SharedPtr traffic_sub_;
rclcpp::Subscription<tier4_planning_msgs::msg::VelocityLimit>::SharedPtr speed_limit_sub_;

std::mutex property_mutex_;
Expand All @@ -118,7 +117,7 @@ private Q_SLOTS:
const autoware_vehicle_msgs::msg::HazardLightsReport::ConstSharedPtr & msg);
void updateSpeedLimitData(const tier4_planning_msgs::msg::VelocityLimit::ConstSharedPtr msg);
void updateTrafficLightData(
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr msg);
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr msg);
void drawWidget(QImage & hud);
};
} // namespace autoware_overlay_rviz_plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <autoware_perception_msgs/msg/traffic_light_element.hpp>
#include <autoware_perception_msgs/msg/traffic_light_group.hpp>
#include <autoware_perception_msgs/msg/traffic_light_group_array.hpp>

#include <OgreColourValue.h>
#include <OgreMaterial.h>
Expand All @@ -40,8 +39,8 @@ class TrafficDisplay
TrafficDisplay();
void drawTrafficLightIndicator(QPainter & painter, const QRectF & backgroundRect);
void updateTrafficLightData(
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr & msg);
autoware_perception_msgs::msg::TrafficLightGroupArray current_traffic_;
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr & msg);
autoware_perception_msgs::msg::TrafficLightGroup current_traffic_;

private:
QImage traffic_light_image_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ void SignalDisplay::onInitialize()
speed_limit_topic_property_->initialize(rviz_ros_node);

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

Expand Down Expand Up @@ -192,7 +193,7 @@ void SignalDisplay::onDisable()
}

void SignalDisplay::updateTrafficLightData(
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr msg)
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr msg)
{
std::lock_guard<std::mutex> lock(property_mutex_);

Expand Down Expand Up @@ -458,14 +459,13 @@ void SignalDisplay::topic_updated_traffic()
// resubscribe to the topic
traffic_sub_.reset();
auto rviz_ros_node = context_->getRosNodeAbstraction().lock();
traffic_sub_ =
rviz_ros_node->get_raw_node()
->create_subscription<autoware_perception_msgs::msg::TrafficLightGroupArray>(
traffic_topic_property_->getTopicStd(),
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable(),
[this](const autoware_perception_msgs::msg::TrafficLightGroupArray::SharedPtr msg) {
updateTrafficLightData(msg);
});
traffic_sub_ = rviz_ros_node->get_raw_node()
->create_subscription<autoware_perception_msgs::msg::TrafficLightGroup>(
traffic_topic_property_->getTopicStd(),
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable(),
[this](const autoware_perception_msgs::msg::TrafficLightGroup::SharedPtr msg) {
updateTrafficLightData(msg);
});
}

} // namespace autoware_overlay_rviz_plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TrafficDisplay::TrafficDisplay()
}

void TrafficDisplay::updateTrafficLightData(
const autoware_perception_msgs::msg::TrafficLightGroupArray::ConstSharedPtr & msg)
const autoware_perception_msgs::msg::TrafficLightGroup::ConstSharedPtr & msg)
{
current_traffic_ = *msg;
}
Expand All @@ -68,8 +68,8 @@ void TrafficDisplay::drawTrafficLightIndicator(QPainter & painter, const QRectF
backgroundRect.top() + circleRect.height() / 2));
painter.drawEllipse(circleRect);

if (!current_traffic_.traffic_light_groups.empty()) {
switch (current_traffic_.traffic_light_groups[0].elements[0].color) {
if (!current_traffic_.elements.empty()) {
switch (current_traffic_.elements[0].color) {
case 1:
painter.setBrush(QBrush(tl_red_));
painter.drawEllipse(circleRect);
Expand Down

0 comments on commit ffa394f

Please sign in to comment.