Skip to content

Commit dd49bfb

Browse files
N-EikiMertClk
andauthored
feat(trajectory_modifier): add v2i handling for traffic_light_stop pl… (#3499)
feat(trajectory_modifier): add v2i handling for traffic_light_stop plugin Signed-off-by: Mert Çolak <colak.mrt@outlook.com> Co-authored-by: Mert Çolak <colak.mrt@outlook.com>
1 parent 1a558fb commit dd49bfb

10 files changed

Lines changed: 405 additions & 78 deletions

File tree

‎common/autoware_traffic_light_compliance_checker/include/autoware/traffic_light_compliance_checker/structs.hpp‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@
2525
#include <lanelet2_core/geometry/LineString.h>
2626

2727
#include <cstdint>
28+
#include <optional>
29+
#include <unordered_map>
2830
#include <vector>
2931

3032
namespace autoware::traffic_light_compliance_checker
3133
{
3234

35+
/// @brief route lanelet id per traffic light id, for the traffic lights of the current route
36+
using RouteTrafficLightIndex = std::unordered_map<lanelet::Id, lanelet::Id>;
37+
3338
/// @brief input data for traffic light compliance check
3439
struct Inputs
3540
{
@@ -47,10 +52,11 @@ struct StopLineInfo
4752
{
4853
lanelet::BasicLineString2d line;
4954
int64_t traffic_light_id;
55+
int64_t traffic_light_lanelet_id;
5056
};
5157

5258
/// @brief type of traffic light violation
53-
enum class ViolationType { RED_LIGHT, AMBER_LIGHT };
59+
enum class ViolationType { RED_LIGHT, AMBER_LIGHT, V2I };
5460

5561
/// @brief violation detail
5662
struct Violation
@@ -93,6 +99,15 @@ struct StatusTrackerParameters
9399
double stable_duration_threshold_unknown;
94100
};
95101

102+
/// @brief part of the trajectory to check against stop lines
103+
struct PreparedTrajectory
104+
{
105+
std::vector<autoware_planning_msgs::msg::TrajectoryPoint> points;
106+
lanelet::BasicLineString2d linestring;
107+
std::optional<lanelet::BasicPoint2d> stop_point;
108+
double backward_length{0.0};
109+
};
110+
96111
/// @brief parameters for traffic light compliance check
97112
struct Parameters
98113
{
@@ -117,6 +132,13 @@ struct Parameters
117132
double hysteresis_duration;
118133
bool reject_if_stop_detected;
119134
} amber_rejection;
135+
struct V2IHandling
136+
{
137+
bool get_last_time_allowed_to_pass_from_map;
138+
double last_time_allowed_to_pass;
139+
double velocity_threshold;
140+
double required_time_to_departure;
141+
} v2i_handling;
120142
};
121143

122144
} // namespace autoware::traffic_light_compliance_checker

‎common/autoware_traffic_light_compliance_checker/include/autoware/traffic_light_compliance_checker/traffic_light_compliance_checker.hpp‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
namespace autoware::traffic_light_compliance_checker
3939
{
40-
4140
/// @brief class to check if a trajectory complies with traffic lights
4241
class TrafficLightComplianceChecker
4342
{
@@ -58,7 +57,8 @@ class TrafficLightComplianceChecker
5857
* @return result of compliance check, or error message if check fails
5958
*/
6059
[[nodiscard]] tl::expected<ComplianceResult, std::string> check(
61-
const Inputs & input, const bool check_red_lights = true, const bool check_amber_lights = true);
60+
const Inputs & input, const bool check_red_lights = true, const bool check_amber_lights = true,
61+
const bool use_v2i_remaining_time = false);
6262

6363
/**
6464
* @brief update parameters
@@ -75,6 +75,7 @@ class TrafficLightComplianceChecker
7575
[[nodiscard]] ComplianceResult check_with_filtered_signals(
7676
const Inputs & input,
7777
const autoware_perception_msgs::msg::TrafficLightGroupArray & filtered_signals,
78+
const RouteTrafficLightIndex & route_traffic_light_index,
7879
const std::vector<int64_t> & force_reject_amber_ids, const bool check_red_lights,
7980
const bool check_amber_lights) const;
8081

@@ -94,7 +95,7 @@ class TrafficLightComplianceChecker
9495
/// @brief return the red and amber stop lines related to the given traffic light groups
9596
[[nodiscard]] std::pair<std::vector<StopLineInfo>, std::vector<StopLineInfo>> get_stop_lines(
9697
const lanelet::LaneletMap & lanelet_map,
97-
const autoware_planning_msgs::msg::LaneletRoute & route,
98+
const RouteTrafficLightIndex & route_traffic_light_index,
9899
const autoware_perception_msgs::msg::TrafficLightGroupArray & traffic_lights) const;
99100

100101
/// @brief return true if there is a stop point and it is within margin distance of the stop line
@@ -110,6 +111,14 @@ class TrafficLightComplianceChecker
110111

111112
bool is_allow_if_cannot_stop(const double distance_to_cross_point) const;
112113

114+
/// @brief return the stop lines that will turn red before ego can pass them, based on the V2I
115+
/// signal predictions
116+
[[nodiscard]] ComplianceResult handle_v2i(
117+
const Inputs & input,
118+
const autoware_perception_msgs::msg::TrafficLightGroupArray & filtered_signals,
119+
const RouteTrafficLightIndex & route_traffic_light_index,
120+
const bool use_v2i_remaining_time) const;
121+
113122
Parameters params_;
114123
vehicle_info_utils::VehicleInfo vehicle_info_;
115124
std::unique_ptr<TrafficLightStatusTracker> status_tracker_;

0 commit comments

Comments
 (0)