Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TrafficLightGroup in traffic_simulator / simple_sensor_simulator #1357

Merged
merged 24 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3be60cb
feat(traffic_simulator): support TrafficLightGroupArray in TrafficLig…
HansRobo Jun 10, 2024
d423431
feat(traffic_simulator): support TrafficLightGroupArray in SimpleSens…
HansRobo Jun 10, 2024
e53c597
feat(traffic_simulator): support TrafficLightGroup for V2I traffic li…
HansRobo Jun 10, 2024
4851ef4
chore(scenario_test_runner): add new architecture_type in launch file
HansRobo Jun 10, 2024
a42eb25
chore: apply formatter
HansRobo Aug 28, 2024
4b2c29d
fix architecture_type and typos
HansRobo Aug 28, 2024
164ed23
Merge branch 'master' into feature/traffic_light_group
HansRobo Aug 28, 2024
f5f6620
Merge branch 'master' into feature/traffic_light_group
HansRobo Sep 3, 2024
1dbfed5
Merge branch 'master' into feature/traffic_light_group
HansRobo Oct 8, 2024
aac5693
Merge branch 'master' into feature/traffic_light_group
HansRobo Oct 9, 2024
05fbb62
Merge branch 'master' into feature/traffic_light_group
HansRobo Oct 31, 2024
1f1dcb6
docs: add comment about archtecture_type purposes
HansRobo Nov 5, 2024
ed12833
Merge branch 'master' into feature/traffic_light_group
HansRobo Nov 5, 2024
d844a68
Merge remote-tracking branch 'origin/master' into feature/traffic_lig…
HansRobo Nov 11, 2024
ae7104f
refactor: modify TrafficLightPublisher to publish from proto
HansRobo Nov 11, 2024
6841959
refactor: use traffic light publisher from traffic_simulator in simpl…
HansRobo Nov 11, 2024
30cc70f
feat: support awf/universe/20240605 as architecture_type in mock_test…
HansRobo Nov 11, 2024
574b7a6
feat: support awf/universe/20240605 as architecture_type for V2I traf…
HansRobo Nov 11, 2024
c00a060
fix: remove deleted cpp file in CMakeLists.txt
HansRobo Nov 11, 2024
994cf9e
refactor: adjust include
HansRobo Nov 11, 2024
45dc9fe
fix: fix build errors with autoware_perception_msgs/msg/traffic_light…
HansRobo Nov 11, 2024
8cfa945
Merge branch 'master' into feature/traffic_light_group
HansRobo Nov 11, 2024
dd99310
apply linter
HansRobo Nov 11, 2024
7e1b4ad
refactor: delete unused member variable
HansRobo Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mock/cpp_mock_scenarios/launch/mock_test.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def on_stdout_output(event: launch.Event) -> None:
print(Color.GREEN + "Scenario Succeed" + Color.END)

def architecture_types():
return ["awf/universe", "awf/universe/20230906"]
return ["awf/universe", "awf/universe/20230906", "awf/universe/20240605"]


def default_autoware_launch_package_of(architecture_type):
Expand All @@ -81,6 +81,7 @@ def default_autoware_launch_package_of(architecture_type):
return {
"awf/universe": "autoware_launch",
"awf/universe/20230906": "autoware_launch",
"awf/universe/20240605": "autoware_launch",
}[architecture_type]


Expand All @@ -92,6 +93,7 @@ def default_autoware_launch_file_of(architecture_type):
return {
"awf/universe": "planning_simulator.launch.xml",
"awf/universe/20230906": "planning_simulator.launch.xml",
"awf/universe/20240605": "planning_simulator.launch.xml",
}[architecture_type]

def default_rviz_config_file():
Expand Down
1 change: 0 additions & 1 deletion simulation/simple_sensor_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ ament_auto_add_library(simple_sensor_simulator_component SHARED
src/sensor_simulation/primitives/primitive.cpp
src/sensor_simulation/primitives/primitive.cpp
src/sensor_simulation/sensor_simulation.cpp
src/sensor_simulation/traffic_lights/traffic_lights_publisher.cpp
src/simple_sensor_simulator.cpp
src/vehicle_simulation/ego_entity_simulation.cpp
src/vehicle_simulation/vehicle_model/sim_model_delay_steer_acc.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
#include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>
#include <autoware_auto_perception_msgs/msg/traffic_signal_array.hpp>
#include <autoware_perception_msgs/msg/traffic_signal_array.hpp>
#include <iomanip>
#include <memory>
#include <rclcpp/rclcpp.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
#ifndef SIMPLE_SENSOR_SIMULATOR__SENSOR_SIMULATION__TRAFFIC_LIGHTS__TRAFFIC_LIGHTS_DETECTOR_HPP_
#define SIMPLE_SENSOR_SIMULATOR__SENSOR_SIMULATION__TRAFFIC_LIGHTS__TRAFFIC_LIGHTS_DETECTOR_HPP_

#include <autoware_auto_perception_msgs/msg/traffic_signal_array.hpp>
#include <autoware_perception_msgs/msg/traffic_signal_array.hpp>
#include <rclcpp/rclcpp.hpp>
#include <simple_sensor_simulator/sensor_simulation/traffic_lights/traffic_lights_publisher.hpp>
#include <simulation_interface/conversions.hpp>
#include <string>
#include <traffic_simulator/traffic_lights/traffic_light_publisher.hpp>

#if __has_include(<autoware_perception_msgs/msg/traffic_light_group_array.hpp>)
#include <autoware_perception_msgs/msg/traffic_light_group_array.hpp>
#endif

namespace simple_sensor_simulator
{
Expand Down Expand Up @@ -48,32 +54,40 @@ class TrafficLightsDetector
private:
template <typename NodeType>
auto makePublisher(NodeType & node, const std::string & architecture_type)
-> std::unique_ptr<TrafficLightsPublisherBase>
-> std::unique_ptr<traffic_simulator::TrafficLightPublisherBase>
{
/*
TrafficLightsDetector in SimpleSensorSimulator publishes using architecture-dependent topics:
"/perception/traffic_light_recognition/internal/traffic_signals" for >= "awf/universe/20230906"
"/perception/traffic_light_recognition/internal/traffic_signals" for >= "awf/universe/20240605"
"/perception/traffic_light_recognition/internal/traffic_signals" for == "awf/universe/20230906"
"/perception/traffic_light_recognition/traffic_signals" for "awf/universe"

V2ITrafficLights in TrafficSimulator publishes publishes using architecture-independent topics ("awf/universe..."):
"/v2x/traffic_signals" and "/perception/traffic_light_recognition/external/traffic_signals"
*/
if (architecture_type == "awf/universe") {
using Message = autoware_auto_perception_msgs::msg::TrafficSignalArray;
return std::make_unique<TrafficLightsPublisher<Message>>(
return std::make_unique<traffic_simulator::TrafficLightPublisher<Message>>(
&node, "/perception/traffic_light_recognition/traffic_signals");
} else if (architecture_type >= "awf/universe/20230906") {
} else if (architecture_type == "awf/universe/20230906") {
using Message = autoware_perception_msgs::msg::TrafficSignalArray;
return std::make_unique<TrafficLightsPublisher<Message>>(
return std::make_unique<traffic_simulator::TrafficLightPublisher<Message>>(
&node, "/perception/traffic_light_recognition/internal/traffic_signals");
#if __has_include(<autoware_perception_msgs/msg/traffic_light_group_array.hpp>)
} else if (architecture_type >= "awf/universe/20240605") {
using Message = autoware_perception_msgs::msg::TrafficLightGroupArray;
return std::make_unique<traffic_simulator::TrafficLightPublisher<Message>>(
&node, "/perception/traffic_light_recognition/internal/traffic_signals");
#endif
} else {
std::stringstream ss;
ss << "Unexpected architecture_type " << std::quoted(architecture_type) << " given.";
ss << "Unexpected architecture_type " << std::quoted(architecture_type)
<< " given for traffic light.";
throw std::invalid_argument(ss.str());
}
}

const std::unique_ptr<TrafficLightsPublisherBase> publisher_ptr_;
const std::unique_ptr<traffic_simulator::TrafficLightPublisherBase> publisher_ptr_;
};
} // namespace traffic_lights
} // namespace simple_sensor_simulator
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <tf2_ros/static_transform_broadcaster.h>
#include <tf2_ros/transform_broadcaster.h>

#include <autoware_perception_msgs/msg/traffic_signal_array.hpp>
#include <memory>
#include <optional>
#include <rclcpp/node_interfaces/get_node_topics_interface.hpp>
Expand Down Expand Up @@ -48,7 +47,6 @@
#include <traffic_simulator_msgs/msg/behavior_parameter.hpp>
#include <traffic_simulator_msgs/msg/bounding_box.hpp>
#include <traffic_simulator_msgs/msg/entity_status_with_trajectory_array.hpp>
#include <traffic_simulator_msgs/msg/traffic_light_array_v1.hpp>
#include <traffic_simulator_msgs/msg/vehicle_parameters.hpp>
#include <type_traits>
#include <unordered_map>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ namespace traffic_simulator
class TrafficLightPublisherBase
{
public:
virtual auto publish(const TrafficLightsBase & traffic_lights) const -> void = 0;
virtual auto publish(
const rclcpp::Time & current_ros_time,
const simulation_api_schema::UpdateTrafficLightsRequest & request) const -> void = 0;
virtual ~TrafficLightPublisherBase() = default;
};

Expand All @@ -38,22 +40,23 @@ class TrafficLightPublisher : public TrafficLightPublisherBase
template <typename NodeTypePointer>
explicit TrafficLightPublisher(
const NodeTypePointer & node_ptr, const std::string & topic_name,
const std::string & frame = "camera_link")
const std::string & frame = "camera_link") // DIRTY HACK!!!
: 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()))
{
}

~TrafficLightPublisher() override = default;

auto publish(const TrafficLightsBase & traffic_lights) const -> void override;
auto publish(
const rclcpp::Time & current_ros_time,
const simulation_api_schema::UpdateTrafficLightsRequest & request) const -> void override;

private:
const std::string frame_;
const rclcpp::Clock::SharedPtr clock_ptr_;

const typename rclcpp::Publisher<MessageType>::SharedPtr traffic_light_state_array_publisher_;
};
} // namespace traffic_simulator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

#include <autoware_auto_perception_msgs/msg/traffic_signal_array.hpp>
#include <autoware_perception_msgs/msg/traffic_signal_array.hpp>

#if __has_include(<autoware_perception_msgs/msg/traffic_light_group_array.hpp>)
#include <autoware_perception_msgs/msg/traffic_light_group_array.hpp>
#endif

#include <traffic_simulator/traffic_lights/traffic_light_publisher.hpp>
#include <traffic_simulator/traffic_lights/traffic_lights_base.hpp>

Expand All @@ -40,7 +45,8 @@ class ConventionalTrafficLights : public TrafficLightsBase
private:
auto update() const -> void
{
backward_compatible_publisher_ptr_->publish(*this);
backward_compatible_publisher_ptr_->publish(
clock_ptr_->now(), generateUpdateTrafficLightsRequest());
if (isAnyTrafficLightChanged()) {
marker_publisher_ptr_->deleteMarkers();
}
Expand Down Expand Up @@ -70,8 +76,10 @@ class V2ITrafficLights : public TrafficLightsBase
private:
auto update() const -> void override
{
publisher_ptr_->publish(*this);
legacy_topic_publisher_ptr_->publish(*this);
const auto now = clock_ptr_->now();
const auto request = generateUpdateTrafficLightsRequest();
publisher_ptr_->publish(now, request);
legacy_topic_publisher_ptr_->publish(now, request);
if (isAnyTrafficLightChanged()) {
marker_publisher_ptr_->deleteMarkers();
}
Expand All @@ -91,10 +99,16 @@ class V2ITrafficLights : public TrafficLightsBase
"/perception/traffic_light_recognition/internal/traffic_signals" for >= "awf/universe/20230906"
"/perception/traffic_light_recognition/traffic_signals" for "awf/universe"
*/
if (architecture_type.find("awf/universe") != std::string::npos) {
if (architecture_type <= "awf/universe/20230906") {
return std::make_unique<
TrafficLightPublisher<autoware_perception_msgs::msg::TrafficSignalArray>>(
node_ptr, topic_name);
#if __has_include(<autoware_perception_msgs/msg/traffic_light_group_array.hpp>)
} else if (architecture_type >= "awf/universe/20240605") {
return std::make_unique<
TrafficLightPublisher<autoware_perception_msgs::msg::TrafficLightGroupArray>>(
node_ptr, topic_name);
#endif
} else {
throw common::SemanticError(
"Unexpected architecture_type ", std::quoted(architecture_type),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <traffic_simulator/traffic_lights/configurable_rate_updater.hpp>
#include <traffic_simulator/traffic_lights/traffic_light.hpp>
#include <traffic_simulator/traffic_lights/traffic_light_marker_publisher.hpp>
#include <traffic_simulator_msgs/msg/traffic_light_array_v1.hpp>
#include <unordered_map>
#include <vector>

Expand Down Expand Up @@ -75,8 +74,6 @@ class TrafficLightsBase
auto generateUpdateTrafficLightsRequest() const
-> simulation_api_schema::UpdateTrafficLightsRequest;

auto generateTrafficSimulatorV1Msg() const -> traffic_simulator_msgs::msg::TrafficLightArrayV1;

protected:
virtual auto update() const -> void = 0;

Expand Down
Loading
Loading