Skip to content

Commit

Permalink
replace TrafficLightElement with TrafficSignalElement
Browse files Browse the repository at this point in the history
Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp>
  • Loading branch information
TomohitoAndo committed Jul 10, 2023
1 parent f900d48 commit aacf390
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,47 +139,47 @@ void TrafficLightPublishPanel::onSetTrafficLightState()
const auto shape = light_shape_combo_->currentText();
const auto status = light_status_combo_->currentText();

TrafficLightElement traffic_light;
TrafficSignalElement traffic_light;
traffic_light.confidence = traffic_light_confidence_input_->value();

if (color == "RED") {
traffic_light.color = TrafficLightElement::RED;
traffic_light.color = TrafficSignalElement::RED;
} else if (color == "AMBER") {
traffic_light.color = TrafficLightElement::AMBER;
traffic_light.color = TrafficSignalElement::AMBER;
} else if (color == "GREEN") {
traffic_light.color = TrafficLightElement::GREEN;
traffic_light.color = TrafficSignalElement::GREEN;
} else if (color == "WHITE") {
traffic_light.color = TrafficLightElement::WHITE;
traffic_light.color = TrafficSignalElement::WHITE;
} else if (color == "UNKNOWN") {
traffic_light.color = TrafficLightElement::UNKNOWN;
traffic_light.color = TrafficSignalElement::UNKNOWN;
}

if (shape == "CIRCLE") {
traffic_light.shape = TrafficLightElement::CIRCLE;
traffic_light.shape = TrafficSignalElement::CIRCLE;
} else if (shape == "LEFT_ARROW") {
traffic_light.shape = TrafficLightElement::LEFT_ARROW;
traffic_light.shape = TrafficSignalElement::LEFT_ARROW;
} else if (shape == "RIGHT_ARROW") {
traffic_light.shape = TrafficLightElement::RIGHT_ARROW;
traffic_light.shape = TrafficSignalElement::RIGHT_ARROW;
} else if (shape == "UP_ARROW") {
traffic_light.shape = TrafficLightElement::UP_ARROW;
traffic_light.shape = TrafficSignalElement::UP_ARROW;
} else if (shape == "DOWN_ARROW") {
traffic_light.shape = TrafficLightElement::DOWN_ARROW;
traffic_light.shape = TrafficSignalElement::DOWN_ARROW;
} else if (shape == "DOWN_LEFT_ARROW") {
traffic_light.shape = TrafficLightElement::DOWN_LEFT_ARROW;
traffic_light.shape = TrafficSignalElement::DOWN_LEFT_ARROW;
} else if (shape == "DOWN_RIGHT_ARROW") {
traffic_light.shape = TrafficLightElement::DOWN_RIGHT_ARROW;
traffic_light.shape = TrafficSignalElement::DOWN_RIGHT_ARROW;
} else if (shape == "UNKNOWN") {
traffic_light.shape = TrafficLightElement::UNKNOWN;
traffic_light.shape = TrafficSignalElement::UNKNOWN;
}

if (status == "SOLID_OFF") {
traffic_light.status = TrafficLightElement::SOLID_OFF;
traffic_light.status = TrafficSignalElement::SOLID_OFF;
} else if (status == "SOLID_ON") {
traffic_light.status = TrafficLightElement::SOLID_ON;
traffic_light.status = TrafficSignalElement::SOLID_ON;
} else if (status == "FLASHING") {
traffic_light.status = TrafficLightElement::FLASHING;
traffic_light.status = TrafficSignalElement::FLASHING;
} else if (status == "UNKNOWN") {
traffic_light.status = TrafficLightElement::UNKNOWN;
traffic_light.status = TrafficSignalElement::UNKNOWN;
}

TrafficSignal traffic_signal;
Expand Down Expand Up @@ -273,23 +273,23 @@ void TrafficLightPublishPanel::onTimer()

const auto & light = signal.elements.front();
switch (light.color) {
case TrafficLightElement::RED:
case TrafficSignalElement::RED:
color_label->setText("RED");
color_label->setStyleSheet("background-color: #FF0000;");
break;
case TrafficLightElement::AMBER:
case TrafficSignalElement::AMBER:
color_label->setText("AMBER");
color_label->setStyleSheet("background-color: #FFBF00;");
break;
case TrafficLightElement::GREEN:
case TrafficSignalElement::GREEN:
color_label->setText("GREEN");
color_label->setStyleSheet("background-color: #7CFC00;");
break;
case TrafficLightElement::WHITE:
case TrafficSignalElement::WHITE:
color_label->setText("WHITE");
color_label->setStyleSheet("background-color: #FFFFFF;");
break;
case TrafficLightElement::UNKNOWN:
case TrafficSignalElement::UNKNOWN:
color_label->setText("UNKNOWN");
color_label->setStyleSheet("background-color: #808080;");
break;
Expand All @@ -301,28 +301,28 @@ void TrafficLightPublishPanel::onTimer()
shape_label->setAlignment(Qt::AlignCenter);

switch (light.shape) {
case TrafficLightElement::CIRCLE:
case TrafficSignalElement::CIRCLE:
shape_label->setText("CIRCLE");
break;
case TrafficLightElement::LEFT_ARROW:
case TrafficSignalElement::LEFT_ARROW:
shape_label->setText("LEFT_ARROW");
break;
case TrafficLightElement::RIGHT_ARROW:
case TrafficSignalElement::RIGHT_ARROW:
shape_label->setText("RIGHT_ARROW");
break;
case TrafficLightElement::UP_ARROW:
case TrafficSignalElement::UP_ARROW:
shape_label->setText("UP_ARROW");
break;
case TrafficLightElement::DOWN_ARROW:
case TrafficSignalElement::DOWN_ARROW:
shape_label->setText("DOWN_ARROW");
break;
case TrafficLightElement::DOWN_LEFT_ARROW:
case TrafficSignalElement::DOWN_LEFT_ARROW:
shape_label->setText("DOWN_LEFT_ARROW");
break;
case TrafficLightElement::DOWN_RIGHT_ARROW:
case TrafficSignalElement::DOWN_RIGHT_ARROW:
shape_label->setText("DOWN_RIGHT_ARROW");
break;
case TrafficLightElement::UNKNOWN:
case TrafficSignalElement::UNKNOWN:
shape_label->setText("UNKNOWN");
break;
default:
Expand All @@ -333,16 +333,16 @@ void TrafficLightPublishPanel::onTimer()
status_label->setAlignment(Qt::AlignCenter);

switch (light.status) {
case TrafficLightElement::SOLID_OFF:
case TrafficSignalElement::SOLID_OFF:
status_label->setText("SOLID_OFF");
break;
case TrafficLightElement::SOLID_ON:
case TrafficSignalElement::SOLID_ON:
status_label->setText("SOLID_ON");
break;
case TrafficLightElement::FLASHING:
case TrafficSignalElement::FLASHING:
status_label->setText("FLASHING");
break;
case TrafficLightElement::UNKNOWN:
case TrafficSignalElement::UNKNOWN:
status_label->setText("UNKNOWN");
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace rviz_plugins
{

using autoware_auto_mapping_msgs::msg::HADMapBin;
using autoware_perception_msgs::msg::TrafficLightElement;
using autoware_perception_msgs::msg::TrafficSignalElement;
using autoware_perception_msgs::msg::TrafficSignal;
using autoware_perception_msgs::msg::TrafficSignalArray;
class TrafficLightPublishPanel : public rviz_common::Panel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ bool CrosswalkModule::isRedSignalForPedestrians() const
continue;
}

if (lights.front().color == TrafficLightElement::RED) {
if (lights.front().color == TrafficSignalElement::RED) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using autoware_auto_perception_msgs::msg::ObjectClassification;
using autoware_auto_perception_msgs::msg::PredictedObject;
using autoware_auto_perception_msgs::msg::PredictedObjects;
using autoware_auto_planning_msgs::msg::PathWithLaneId;
using autoware_perception_msgs::msg::TrafficLightElement;
using autoware_perception_msgs::msg::TrafficSignalElement;
using lanelet::autoware::Crosswalk;
using tier4_api_msgs::msg::CrosswalkStatus;
using tier4_autoware_utils::StopWatch;
Expand Down
10 changes: 5 additions & 5 deletions planning/behavior_velocity_intersection_module/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ bool hasAssociatedTrafficLight(lanelet::ConstLanelet lane)
bool isTrafficLightArrowActivated(
lanelet::ConstLanelet lane, const std::map<int, TrafficSignalStamped> & tl_infos)
{
using TrafficLightElement = autoware_perception_msgs::msg::TrafficLightElement;
using TrafficSignalElement = autoware_perception_msgs::msg::TrafficSignalElement;

const auto & turn_direction = lane.attributeOr("turn_direction", "else");
std::optional<int> tl_id = std::nullopt;
Expand All @@ -689,12 +689,12 @@ bool isTrafficLightArrowActivated(
}
const auto & tl_info = tl_info_it->second;
for (auto && tl_light : tl_info.signal.elements) {
if (tl_light.color != TrafficLightElement::GREEN) continue;
if (tl_light.status != TrafficLightElement::SOLID_ON) continue;
if (turn_direction == std::string("left") && tl_light.shape == TrafficLightElement::LEFT_ARROW)
if (tl_light.color != TrafficSignalElement::GREEN) continue;
if (tl_light.status != TrafficSignalElement::SOLID_ON) continue;
if (turn_direction == std::string("left") && tl_light.shape == TrafficSignalElement::LEFT_ARROW)
return true;
if (
turn_direction == std::string("right") && tl_light.shape == TrafficLightElement::RIGHT_ARROW)
turn_direction == std::string("right") && tl_light.shape == TrafficSignalElement::RIGHT_ARROW)
return true;
}
return false;
Expand Down
15 changes: 9 additions & 6 deletions planning/behavior_velocity_traffic_light_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ bool TrafficLightModule::isPassthrough(const double & signed_arc_length) const
bool TrafficLightModule::isTrafficSignalStop(
const autoware_perception_msgs::msg::TrafficSignal & tl_state) const
{
if (hasTrafficLightCircleColor(tl_state, TrafficLightElement::GREEN)) {
if (hasTrafficLightCircleColor(tl_state, TrafficSignalElement::GREEN)) {
return false;
}

Expand All @@ -354,14 +354,17 @@ bool TrafficLightModule::isTrafficSignalStop(
return true;
}
if (
turn_direction == "right" && hasTrafficLightShape(tl_state, TrafficLightElement::RIGHT_ARROW)) {
turn_direction == "right" &&
hasTrafficLightShape(tl_state, TrafficSignalElement::RIGHT_ARROW)) {
return false;
}
if (turn_direction == "left" && hasTrafficLightShape(tl_state, TrafficLightElement::LEFT_ARROW)) {
if (
turn_direction == "left" && hasTrafficLightShape(tl_state, TrafficSignalElement::LEFT_ARROW)) {
return false;
}
if (
turn_direction == "straight" && hasTrafficLightShape(tl_state, TrafficLightElement::UP_ARROW)) {
turn_direction == "straight" &&
hasTrafficLightShape(tl_state, TrafficSignalElement::UP_ARROW)) {
return false;
}

Expand Down Expand Up @@ -400,7 +403,7 @@ bool TrafficLightModule::getHighestConfidenceTrafficSignal(

if (
tl_state.elements.empty() ||
tl_state.elements.front().color == TrafficLightElement::UNKNOWN) {
tl_state.elements.front().color == TrafficSignalElement::UNKNOWN) {
reason = "TrafficLightUnknown";
continue;
}
Expand Down Expand Up @@ -472,7 +475,7 @@ bool TrafficLightModule::hasTrafficLightCircleColor(
{
const auto it_lamp =
std::find_if(tl_state.elements.begin(), tl_state.elements.end(), [&lamp_color](const auto & x) {
return x.shape == TrafficLightElement::CIRCLE && x.color == lamp_color;
return x.shape == TrafficSignalElement::CIRCLE && x.color == lamp_color;
});

return it_lamp != tl_state.elements.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TrafficLightModule : public SceneModuleInterface
{
public:
using TrafficSignal = autoware_perception_msgs::msg::TrafficSignal;
using TrafficLightElement = autoware_perception_msgs::msg::TrafficLightElement;
using TrafficSignalElement = autoware_perception_msgs::msg::TrafficSignalElement;
enum class State { APPROACH, GO_OUT };

struct DebugData
Expand Down

0 comments on commit aacf390

Please sign in to comment.