Skip to content

Commit

Permalink
Rename traffic light classes to match filenames
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Palczuk <[email protected]>
  • Loading branch information
TauTheLepton committed Jul 29, 2024
1 parent b39433a commit a06f4b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@

namespace traffic_simulator
{
class TrafficLightsPublisherBase
class TrafficLightPublisherBase
{
public:
virtual auto publish(const TrafficLightsBase & traffic_lights) const -> void = 0;
virtual ~TrafficLightsPublisherBase() = default;
virtual ~TrafficLightPublisherBase() = default;
};

template <typename MessageType>
class TrafficLightsPublisher : public TrafficLightsPublisherBase
class TrafficLightPublisher : public TrafficLightPublisherBase
{
public:
template <typename NodeTypePointer>
explicit TrafficLightsPublisher(
explicit TrafficLightPublisher(
const NodeTypePointer & node_ptr, const std::string & topic_name,
const std::string & frame = "camera_link")
: TrafficLightsPublisherBase(),
: TrafficLightPublisherBase(),
frame_(frame),
clock_ptr_(node_ptr->get_clock()),
traffic_light_state_array_publisher_(rclcpp::create_publisher<MessageType>(
node_ptr, topic_name, rclcpp::QoS(10).transient_local()))
{
}

~TrafficLightsPublisher() override = default;
~TrafficLightPublisher() override = default;

auto publish(const TrafficLightsBase & traffic_lights) const -> void override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ConventionalTrafficLights : public TrafficLightsBase
const NodeTypePointer & node_ptr, const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils)
: TrafficLightsBase(node_ptr, hdmap_utils),
backward_compatible_publisher_ptr_(
std::make_unique<TrafficLightsPublisher<traffic_simulator_msgs::msg::TrafficLightArrayV1>>(
std::make_unique<TrafficLightPublisher<traffic_simulator_msgs::msg::TrafficLightArrayV1>>(
node_ptr, "/simulation/traffic_lights"))
{
}
Expand All @@ -47,7 +47,7 @@ class ConventionalTrafficLights : public TrafficLightsBase
marker_publisher_ptr_->drawMarkers(traffic_lights_map_);
}

const std::unique_ptr<TrafficLightsPublisherBase> backward_compatible_publisher_ptr_;
const std::unique_ptr<TrafficLightPublisherBase> backward_compatible_publisher_ptr_;
};

class V2ITrafficLights : public TrafficLightsBase
Expand Down Expand Up @@ -81,7 +81,7 @@ class V2ITrafficLights : public TrafficLightsBase
template <typename NodeTypePointer>
auto makePublisher(
const NodeTypePointer & node_ptr, const std::string & architecture_type,
const std::string & topic_name) -> std::unique_ptr<TrafficLightsPublisherBase>
const std::string & topic_name) -> std::unique_ptr<TrafficLightPublisherBase>
{
/*
Here autoware_perception_msgs is used for all awf/universe/....
Expand All @@ -93,7 +93,7 @@ class V2ITrafficLights : public TrafficLightsBase
*/
if (architecture_type.find("awf/universe") != std::string::npos) {
return std::make_unique<
TrafficLightsPublisher<autoware_perception_msgs::msg::TrafficSignalArray>>(
TrafficLightPublisher<autoware_perception_msgs::msg::TrafficSignalArray>>(
node_ptr, topic_name);
} else {
throw common::SemanticError(
Expand All @@ -102,8 +102,8 @@ class V2ITrafficLights : public TrafficLightsBase
}
}

const std::unique_ptr<TrafficLightsPublisherBase> publisher_ptr_;
const std::unique_ptr<TrafficLightsPublisherBase> legacy_topic_publisher_ptr_;
const std::unique_ptr<TrafficLightPublisherBase> publisher_ptr_;
const std::unique_ptr<TrafficLightPublisherBase> legacy_topic_publisher_ptr_;
};

class TrafficLights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
namespace traffic_simulator
{
template <>
auto TrafficLightsPublisher<autoware_auto_perception_msgs::msg::TrafficSignalArray>::publish(
auto TrafficLightPublisher<autoware_auto_perception_msgs::msg::TrafficSignalArray>::publish(
const TrafficLightsBase & traffic_lights) const -> void
{
traffic_light_state_array_publisher_->publish(traffic_lights.generateAutowareAutoPerceptionMsg());
}

template <>
auto TrafficLightsPublisher<autoware_perception_msgs::msg::TrafficSignalArray>::publish(
auto TrafficLightPublisher<autoware_perception_msgs::msg::TrafficSignalArray>::publish(
const TrafficLightsBase & traffic_lights) const -> void
{
traffic_light_state_array_publisher_->publish(traffic_lights.generateAutowarePerceptionMsg());
}

template <>
auto TrafficLightsPublisher<traffic_simulator_msgs::msg::TrafficLightArrayV1>::publish(
auto TrafficLightPublisher<traffic_simulator_msgs::msg::TrafficLightArrayV1>::publish(
const TrafficLightsBase & traffic_lights) const -> void
{
traffic_light_state_array_publisher_->publish(traffic_lights.generateTrafficSimulatorV1Msg());
Expand Down

0 comments on commit a06f4b4

Please sign in to comment.