Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
Geofence.hpp
Go to the documentation of this file.
1#pragma once
2/*
3 * Copyright (C) 2022 LEIDOS.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#include <lanelet2_core/primitives/Point.h>
18#include "GeofenceSchedule.hpp"
19#include <lanelet2_core/LaneletMap.h>
20#include <lanelet2_core/primitives/BasicRegulatoryElements.h>
21#include <lanelet2_core/primitives/Lanelet.h>
22#include <lanelet2_core/primitives/RegulatoryElement.h>
23#include <lanelet2_core/primitives/LaneletOrArea.h>
24#include <lanelet2_extension/regulatory_elements/DigitalSpeedLimit.h>
25#include <lanelet2_extension/regulatory_elements/DigitalMinimumGap.h>
26#include <lanelet2_extension/regulatory_elements/PassingControlLine.h>
27
28#include <boost/uuid/uuid.hpp>
29#include <boost/uuid/uuid_io.hpp>
30#include <boost/uuid/uuid_generators.hpp>
31#include <carma_v2x_msgs/msg/traffic_control_message.hpp>
32#include <carma_v2x_msgs/msg/map_data.hpp>
33
34
36{
37using namespace lanelet::units::literals;
38
39// Map Update Geofence Common Labels
40const std::string MAP_MSG_INTERSECTION = "MAP_MSG_INTERSECTION";
41const std::string MAP_MSG_TF_SIGNAL = "MAP_MSG_TF_SIGNAL";
42
43
48{
49public:
50 boost::uuids::uuid id_; // Unique id of this geofence
51
52 std::vector<GeofenceSchedule> schedules; // The schedules this geofence operates with
53
54 std::string proj;
55
56 std::string type_;
57
58 lanelet::Points3d gf_pts;
59
60 // lanelets additions needed or broadcasting to the rest of map users
61 std::vector<lanelet::Lanelet> lanelet_additions_;
62
63 // TODO Add rest of the attributes provided by geofences in the future
64/* following regulatory element pointer is a placeholder created with rule name 'basic_regulatory_element' to later point to
65specific type of regulatory element (such as digital speed limit, passing control line)*/
66
67 lanelet::RegulatoryElementPtr regulatory_element_ = lanelet::RegulatoryElementFactory::create("regulatory_element", lanelet::DigitalSpeedLimit::buildData(lanelet::InvalId, 5_mph, {}, {},
68 { lanelet::Participants::VehicleCar }));
69
70 // traffic light id lookup
71 std::vector<std::pair<uint32_t, lanelet::Id>> traffic_light_id_lookup_;
72 // used in workzone geofence creation. it stores SIG_WZ TCM's label.
73 // used for storing intersection and signal group id for trafficlight, for example: "TYPE:SIG_WZ,INT_ID:<intersection id>,SG_ID:<signal group id>""
74 std::string label_;
75
76 // elements needed for broadcasting to the rest of map users
77 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>> update_list_;
78 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>> remove_list_;
79
80 // we need mutable elements saved here as they will be added back through update function which only accepts mutable objects
81 std::vector<std::pair<lanelet::Id, lanelet::RegulatoryElementPtr>> prev_regems_;
82 lanelet::ConstLaneletOrAreas affected_parts_;
83
84 // original traffic control message for this geofence
85 carma_v2x_msgs::msg::TrafficControlMessageV01 msg_;
86
87 // original MAP message for this geofence
88 carma_v2x_msgs::msg::MapData map_msg_;
89
90 // Helper member for PassingControlLine type regulatory geofence
91 bool pcl_affects_left_ = false;
92 bool pcl_affects_right_ = false;
93 // Flag for route invalidation
95};
96} // namespace carma_wm_ctrl
An object representing a geofence use for communications with CARMA Cloud.
Definition: Geofence.hpp:48
lanelet::Points3d gf_pts
Definition: Geofence.hpp:58
carma_v2x_msgs::msg::TrafficControlMessageV01 msg_
Definition: Geofence.hpp:85
boost::uuids::uuid id_
Definition: Geofence.hpp:50
std::vector< GeofenceSchedule > schedules
Definition: Geofence.hpp:52
std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > remove_list_
Definition: Geofence.hpp:78
std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > update_list_
Definition: Geofence.hpp:77
std::vector< lanelet::Lanelet > lanelet_additions_
Definition: Geofence.hpp:61
lanelet::RegulatoryElementPtr regulatory_element_
Definition: Geofence.hpp:67
std::vector< std::pair< uint32_t, lanelet::Id > > traffic_light_id_lookup_
Definition: Geofence.hpp:71
lanelet::ConstLaneletOrAreas affected_parts_
Definition: Geofence.hpp:82
carma_v2x_msgs::msg::MapData map_msg_
Definition: Geofence.hpp:88
std::vector< std::pair< lanelet::Id, lanelet::RegulatoryElementPtr > > prev_regems_
Definition: Geofence.hpp:81
const std::string MAP_MSG_TF_SIGNAL
Definition: Geofence.hpp:41
const std::string MAP_MSG_INTERSECTION
Definition: Geofence.hpp:40