19#include <rclcpp/rclcpp.hpp>
20#include <boost/uuid/uuid.hpp>
21#include <boost/uuid/uuid_io.hpp>
22#include <boost/uuid/uuid_generators.hpp>
23#include <lanelet2_core/LaneletMap.h>
24#include <lanelet2_core/primitives/Point.h>
25#include <lanelet2_extension/regulatory_elements/StopRule.h>
26#include <lanelet2_extension/regulatory_elements/CarmaTrafficSignal.h>
27#include <lanelet2_core/primitives/LaneletOrArea.h>
28#include <lanelet2_extension/projection/local_frame_projector.h>
30#include <carma_v2x_msgs/msg/map_data.hpp>
31#include <carma_v2x_msgs/msg/spat.hpp>
32#include <lanelet2_core/Forward.h>
33#include <lanelet2_extension/regulatory_elements/SignalizedIntersection.h>
34#include <lanelet2_core/geometry/LaneletMap.h>
35#include <carma_ros2_utils/carma_lifecycle_node.hpp>
53using namespace lanelet::units::literals;
99 void createIntersectionFromMapMsg(std::vector<lanelet::SignalizedIntersectionPtr>& intersections, std::vector<lanelet::CarmaTrafficSignalPtr>& traffic_signals,
const carma_v2x_msgs::msg::MapData& map_msg,
100 const std::shared_ptr<lanelet::LaneletMap>& map, std::shared_ptr<const lanelet::routing::RoutingGraph> routing_graph);
113 void convertLaneToLaneletId(std::unordered_map<uint8_t, lanelet::Id>& entry, std::unordered_map<uint8_t, lanelet::Id>& exit,
const carma_v2x_msgs::msg::IntersectionGeometry& intersection,
114 const std::shared_ptr<lanelet::LaneletMap>& map, std::shared_ptr<const lanelet::routing::RoutingGraph> current_routing_graph);
143 std::shared_ptr<lanelet::CarmaTrafficSignal>
createTrafficSignalUsingSGID(uint8_t signal_group_id,
const lanelet::Lanelets& entry_lanelets,
const lanelet::Lanelets& exit_lanelets);
152 lanelet::Lanelets
identifyInteriorLanelets(
const lanelet::Lanelets& entry_llts,
const std::shared_ptr<lanelet::LaneletMap>& map);
161 const std::shared_ptr<lanelet::LaneletMap>& semantic_map);
171 std::tuple<std::vector<std::pair<boost::posix_time::ptime, lanelet::CarmaTrafficSignalState>>,
172 std::vector<boost::posix_time::ptime>>
174 const carma_v2x_msgs::msg::IntersectionState& curr_intersection,
175 const carma_v2x_msgs::msg::MovementState& current_movement_state);
186 boost::posix_time::ptime min_end_time,
bool moy_exists,uint32_t moy=0,
187 bool is_simulation =
true,
bool use_real_time_spat_in_sim=
false);
196 const std::shared_ptr<lanelet::LaneletMap>& semantic_map)
const;
This class manages and keeps track of all signalized intersections in the map. All of the SPAT and MA...
lanelet::Lanelets identifyInteriorLanelets(const lanelet::Lanelets &entry_llts, const std::shared_ptr< lanelet::LaneletMap > &map)
Returns carma traffic signal and saves all id relevant id mappings (signal group to lanelet id) inter...
lanelet::Id matchSignalizedIntersection(const lanelet::Lanelets &entry_llts, const lanelet::Lanelets &exit_llts)
Returns existing signalized intersection with same entry and exit llts if exists.
std::optional< rclcpp::Time > simulation_clock_
std::unordered_map< uint16_t, std::vector< lanelet::Point3d > > intersection_nodes_
std::tuple< std::vector< std::pair< boost::posix_time::ptime, lanelet::CarmaTrafficSignalState > >, std::vector< boost::posix_time::ptime > > extract_signal_states_from_movement_state(const carma_v2x_msgs::msg::IntersectionState &curr_intersection, const carma_v2x_msgs::msg::MovementState ¤t_movement_state)
Extract tuple of 1) vector of pair of traffic signal states' min_end_time and their states,...
std::unordered_map< uint16_t, std::pair< double, double > > intersection_coord_correction_
void setTargetFrame(const std::string &target_frame)
Saves the georeference string to be used for converting MAP.msg coordinates.
std::unordered_map< uint8_t, std::unordered_set< lanelet::Id > > signal_group_to_entry_lanelet_ids_
std::optional< rclcpp::Time > ros1_clock_
std::string target_frame_
std::unordered_map< lanelet::Id, uint16_t > regem_id_to_intersection_id_
std::unordered_map< uint16_t, lanelet::Id > intersection_id_to_regem_id_
lanelet::Id getTrafficSignalId(uint16_t intersection_id, uint8_t signal_id)
helper for traffic signal Id
std::shared_ptr< lanelet::CarmaTrafficSignal > createTrafficSignalUsingSGID(uint8_t signal_group_id, const lanelet::Lanelets &entry_lanelets, const lanelet::Lanelets &exit_lanelets)
Returns carma traffic signal and saves all id relevant id mappings (signal group to lanelet id) inter...
SIGNAL_PHASE_PROCESSING spat_processor_state_
lanelet::CarmaTrafficSignalPtr getTrafficSignal(const lanelet::Id &id, const std::shared_ptr< lanelet::LaneletMap > &semantic_map) const
helper for getting traffic signal with given lanelet::Id
bool use_real_time_spat_in_sim_
SignalizedIntersectionManager & operator=(SignalizedIntersectionManager other)
Assignment operator that copies everything except the traffic signal states. This is to keep the stat...
bool operator==(const SignalizedIntersectionManager &rhs)
Equality operator that checks if every mapping are same except the traffic signal states....
std::unordered_map< uint8_t, std::unordered_set< lanelet::Id > > signal_group_to_exit_lanelet_ids_
void processSpatFromMsg(const carma_v2x_msgs::msg::SPAT &spat_msg, const std::shared_ptr< lanelet::LaneletMap > &semantic_map)
processSpatFromMsg update map's traffic light states with SPAT msg NOTE: This is enabled in the indiv...
std::unordered_map< uint8_t, lanelet::Id > signal_group_to_traffic_light_id_
void convertLaneToLaneletId(std::unordered_map< uint8_t, lanelet::Id > &entry, std::unordered_map< uint8_t, lanelet::Id > &exit, const carma_v2x_msgs::msg::IntersectionGeometry &intersection, const std::shared_ptr< lanelet::LaneletMap > &map, std::shared_ptr< const lanelet::routing::RoutingGraph > current_routing_graph)
Returns mapping of MAP lane id to lanelet id for the given map and intersection.msg in the MAP....
boost::posix_time::ptime min_end_time_converter_minute_of_year(boost::posix_time::ptime min_end_time, bool moy_exists, uint32_t moy=0, bool is_simulation=true, bool use_real_time_spat_in_sim=false)
update minimum end time to account for minute of the year
void setMaxLaneWidth(double max_lane_width)
Sets the max lane width in meters. Map msg points are associated to a lanelet if they are within this...
void createIntersectionFromMapMsg(std::vector< lanelet::SignalizedIntersectionPtr > &intersections, std::vector< lanelet::CarmaTrafficSignalPtr > &traffic_signals, const carma_v2x_msgs::msg::MapData &map_msg, const std::shared_ptr< lanelet::LaneletMap > &map, std::shared_ptr< const lanelet::routing::RoutingGraph > routing_graph)
Create relevant signalized intersection and carma traffic signals based on the MAP....
SignalizedIntersectionManager()
static const uint8_t INGRESS
static const uint8_t EGRESS