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>
25#include <autoware_lanelet2_msgs/msg/map_bin.hpp>
27#include <lanelet2_io/io_handlers/Serialize.h>
28#include <lanelet2_core/primitives/Point.h>
29#include <lanelet2_extension/regulatory_elements/DigitalSpeedLimit.h>
30#include <lanelet2_extension/regulatory_elements/StopRule.h>
31#include <lanelet2_extension/regulatory_elements/CarmaTrafficSignal.h>
32#include <lanelet2_extension/regulatory_elements/PassingControlLine.h>
33#include <lanelet2_extension/regulatory_elements/DigitalMinimumGap.h>
35#include <lanelet2_core/primitives/LaneletOrArea.h>
36#include <boost/archive/binary_iarchive.hpp>
37#include <boost/archive/binary_oarchive.hpp>
38#include <autoware_lanelet2_ros2_interface/utility/query.hpp>
40#include <carma_ros2_utils/carma_lifecycle_node.hpp>
47using namespace lanelet::units::literals;
54 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>> update_list,
55 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>> remove_list,
56 std::vector<lanelet::Lanelet> lanelet_addition):
59 boost::uuids::uuid
id_;
62 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>>
update_list_;
63 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>>
remove_list_;
84void toBinMsg(std::shared_ptr<carma_wm::TrafficControl> gf_ptr, autoware_lanelet2_msgs::msg::MapBin* msg);
98void fromBinMsg(
const autoware_lanelet2_msgs::msg::MapBin& msg, std::shared_ptr<carma_wm::TrafficControl> gf_ptr, lanelet::LaneletMapPtr lanelet_map =
nullptr);
105namespace serialization {
107template <
class Archive>
116 ar << lanelet_additions_size;
121 ar << remove_list_size;
126 ar << update_list_size;
131 ar << traffic_light_id_lookup_size;
138template <
class Archive>
142 boost::uuids::string_generator gen;
148 size_t lanelet_additions_size;
149 ar >> lanelet_additions_size;
150 for (
auto i = 0u;
i < lanelet_additions_size; ++
i)
152 lanelet::Lanelet llt;
158 size_t remove_list_size;
159 ar >> remove_list_size;
160 for (
auto i = 0u;
i < remove_list_size; ++
i)
162 std::pair<lanelet::Id, lanelet::RegulatoryElementPtr> remove_item;
168 size_t update_list_size;
169 ar >> update_list_size;
171 for (
auto i = 0u;
i < update_list_size; ++
i)
173 std::pair<lanelet::Id, lanelet::RegulatoryElementPtr> update_item;
179 size_t traffic_light_id_lookup_size;
180 ar >> traffic_light_id_lookup_size;
181 for (
auto i = 0u;
i < traffic_light_id_lookup_size; ++
i)
183 std::pair<uint32_t, lanelet::Id> traffic_light_id_pair;
184 ar >> traffic_light_id_pair;
193template <
class Archive>
199 ar << intersection_id_to_regem_id_size;
207 ar << signal_group_to_traffic_light_id_size;
214 ar << signal_group_to_exit_lanelet_ids_size;
217 size_t set_size = pair.second.size();
220 for (
auto iter = pair.second.begin(); iter != pair.second.end(); iter++)
227 ar << signal_group_to_entry_lanelet_ids_size;
230 size_t set_size = pair.second.size();
233 for (
auto iter = pair.second.begin(); iter != pair.second.end(); iter++)
240template <
class Archive>
245 size_t intersection_id_to_regem_id_size;
246 ar >> intersection_id_to_regem_id_size;
247 for (
size_t i = 0;
i < intersection_id_to_regem_id_size;
i ++)
249 std::pair<uint16_t, lanelet::Id> pair;
255 size_t signal_group_to_traffic_light_id_size;
256 ar >> signal_group_to_traffic_light_id_size;
257 for (
size_t i = 0;
i < signal_group_to_traffic_light_id_size;
i ++)
259 std::pair<uint8_t, lanelet::Id> pair;
264 size_t signal_group_to_exit_lanelet_ids_size;
265 ar >> signal_group_to_exit_lanelet_ids_size;
266 for (
size_t i = 0;
i < signal_group_to_exit_lanelet_ids_size;
i ++)
272 for (
size_t j = 0; j <set_size; j++)
280 size_t signal_group_to_entry_lanelet_ids_size;
281 ar >> signal_group_to_entry_lanelet_ids_size;
282 for (
size_t i = 0;
i < signal_group_to_entry_lanelet_ids_size;
i ++)
288 for (
size_t j = 0; j <set_size; j++)
298template <
typename Archive>
299void serialize(Archive& ar, std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>& p,
unsigned int )
305template <
typename Archive>
306void serialize(Archive& ar, std::pair<uint8_t, lanelet::Id>& p,
unsigned int )
312template <
typename Archive>
313void serialize(Archive& ar, std::pair<uint16_t, lanelet::Id>& p,
unsigned int )
319template <
typename Archive>
320void serialize(Archive& ar, std::pair<uint32_t, lanelet::Id>& p,
unsigned int )
This class manages and keeps track of all signalized intersections in the map. All of the SPAT and MA...
std::unordered_map< uint8_t, std::unordered_set< lanelet::Id > > signal_group_to_entry_lanelet_ids_
std::unordered_map< uint16_t, lanelet::Id > intersection_id_to_regem_id_
std::unordered_map< uint8_t, std::unordered_set< lanelet::Id > > signal_group_to_exit_lanelet_ids_
std::unordered_map< uint8_t, lanelet::Id > signal_group_to_traffic_light_id_
std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > update_list_
carma_wm::SignalizedIntersectionManager sim_
std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > remove_list_
std::vector< lanelet::Lanelet > lanelet_additions_
std::vector< std::pair< uint32_t, lanelet::Id > > traffic_light_id_lookup_
TrafficControl(boost::uuids::uuid id, std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > update_list, std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > remove_list, std::vector< lanelet::Lanelet > lanelet_addition)
void save(Archive &ar, const carma_wm::TrafficControl &gf, unsigned int)
void serialize(Archive &ar, std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > &p, unsigned int)
void load(Archive &ar, carma_wm::TrafficControl &gf, unsigned int)
auto to_string(const UtmZone &zone) -> std::string
void fromBinMsg(const autoware_lanelet2_msgs::msg::MapBin &msg, std::shared_ptr< carma_wm::TrafficControl > gf_ptr, lanelet::LaneletMapPtr lanelet_map=nullptr)
void toBinMsg(std::shared_ptr< carma_wm::TrafficControl > gf_ptr, autoware_lanelet2_msgs::msg::MapBin *msg)