13#include <unordered_set>
19 : _parent(
std::move(parent)),
20 _waypoint(
std::move(waypoint)),
21 _transform(_parent->GetMap().ComputeTransform(_waypoint)),
22 _mark_record(_parent->GetMap().GetMarkRecord(_waypoint)) {}
36 return _parent->GetJunction(*
this);
52 std::vector<SharedPtr<Waypoint>> result;
53 result.reserve(waypoints.size());
54 for (
auto &waypoint : waypoints) {
62 std::vector<SharedPtr<Waypoint>> result;
63 result.reserve(waypoints.size());
64 for (
auto &waypoint : waypoints) {
71 std::vector<SharedPtr<Waypoint>> result;
72 std::vector<SharedPtr<Waypoint>> next =
GetNext(distance);
74 while (next.size() == 1 && next.front()->GetRoadId() ==
GetRoadId()) {
75 result.emplace_back(next.front());
76 next = result.back()->GetNext(distance);
80 current_s = result.back()->GetDistance();
82 double remaining_length;
83 double road_length =
_parent->GetMap().GetLane(
_waypoint).GetRoad()->GetLength();
85 remaining_length = road_length - current_s;
87 remaining_length = current_s;
89 remaining_length -= std::numeric_limits<double>::epsilon();
91 result.emplace_back(result.back()->GetNext(remaining_length).front());
93 result.emplace_back(
GetNext(remaining_length).front());
100 std::vector<SharedPtr<Waypoint>> result;
101 std::vector<SharedPtr<Waypoint>> prev =
GetPrevious(distance);
103 while (prev.size() == 1 && prev.front()->GetRoadId() ==
GetRoadId()) {
104 result.emplace_back(prev.front());
105 prev = result.back()->GetPrevious(distance);
110 current_s = result.back()->GetDistance();
113 double remaining_length;
114 double road_length =
_parent->GetMap().GetLane(
_waypoint).GetRoad()->GetLength();
116 remaining_length = road_length - current_s;
118 remaining_length = current_s;
120 remaining_length -= std::numeric_limits<double>::epsilon();
122 result.emplace_back(result.back()->GetPrevious(remaining_length).front());
124 result.emplace_back(
GetPrevious(remaining_length).front());
131 auto right_lane_waypoint =
133 if (right_lane_waypoint.has_value()) {
140 auto left_lane_waypoint =
142 if (left_lane_waypoint.has_value()) {
152 return boost::optional<road::element::LaneMarking>{};
159 return boost::optional<road::element::LaneMarking>{};
162 template <
typename EnumT>
164 return static_cast<EnumT
>(
165 static_cast<typename std::underlying_type<EnumT>::type
>(lhs) &
166 static_cast<typename std::underlying_type<EnumT>::type
>(rhs));
169 template <
typename EnumT>
171 return static_cast<EnumT
>(
172 static_cast<typename std::underlying_type<EnumT>::type
>(lhs) |
173 static_cast<typename std::underlying_type<EnumT>::type
>(rhs));
180 lane_change_type c_right;
181 if (lane_change_right_info !=
nullptr) {
182 const auto lane_change_right = lane_change_right_info->GetLaneChange();
183 c_right =
static_cast<lane_change_type
>(lane_change_right);
185 c_right = lane_change_type::Both;
189 lane_change_type c_left;
190 if (lane_change_left_info !=
nullptr) {
191 const auto lane_change_left = lane_change_left_info->GetLaneChange();
192 c_left =
static_cast<lane_change_type
>(lane_change_left);
194 c_left = lane_change_type::Both;
199 if (c_right == lane_change_type::Right) {
200 c_right = lane_change_type::Left;
201 }
else if (c_right == lane_change_type::Left) {
202 c_right = lane_change_type::Right;
208 if (c_left == lane_change_type::Right) {
209 c_left = lane_change_type::Left;
210 }
else if (c_left == lane_change_type::Left) {
211 c_left = lane_change_type::Right;
215 return (c_right & lane_change_type::Right) | (c_left & lane_change_type::Left);
219 double distance,
bool stop_at_junction)
const {
220 std::vector<SharedPtr<Landmark>> result;
221 auto signals =
_parent->GetMap().GetSignalsInDistance(
223 std::unordered_set<const road::element::RoadInfoSignal*> added_signals;
224 for(
auto &signal_data : signals){
225 if(added_signals.count(signal_data.signal) > 0) {
228 added_signals.insert(signal_data.signal);
231 new Landmark(waypoint,
_parent, signal_data.signal, signal_data.accumulated_s));
237 double distance, std::string filter_type,
bool stop_at_junction)
const {
238 std::vector<SharedPtr<Landmark>> result;
239 std::unordered_set<const road::element::RoadInfoSignal*> added_signals;
240 auto signals =
_parent->GetMap().GetSignalsInDistance(
242 for(
auto &signal_data : signals){
243 if(signal_data.signal->GetSignal()->GetType() == filter_type) {
244 if(added_signals.count(signal_data.signal) > 0) {
249 new Landmark(waypoint,
_parent, signal_data.signal, signal_data.accumulated_s));
Class containing a reference to RoadInfoSignal
SharedPtr< Waypoint > GetLeft() const
std::vector< SharedPtr< Landmark > > GetLandmarksOfTypeInDistance(double distance, std::string filter_type, bool stop_at_junction=false) const
Returns a list of landmarks from the current position to a certain distance Filters by specified type
road::element::Waypoint _waypoint
SharedPtr< Waypoint > GetRight() const
SharedPtr< const Map > _parent
boost::optional< road::element::LaneMarking > GetLeftLaneMarking() const
boost::optional< road::element::LaneMarking > GetRightLaneMarking() const
road::JuncId GetJunctionId() const
double GetLaneWidth() const
std::vector< SharedPtr< Waypoint > > GetPrevious(double distance) const
Waypoint(SharedPtr< const Map > parent, road::element::Waypoint waypoint)
road::element::LaneMarking::LaneChange GetLaneChange() const
std::vector< SharedPtr< Waypoint > > GetNext(double distance) const
SharedPtr< Junction > GetJunction() const
std::vector< SharedPtr< Waypoint > > GetNextUntilLaneEnd(double distance) const
Returns a list of waypoints separated by distance from the current waypoint to the end of the lane
std::vector< SharedPtr< Landmark > > GetAllLandmarksInDistance(double distance, bool stop_at_junction=false) const
Returns a list of landmarks from the current position to a certain distance
std::vector< SharedPtr< Waypoint > > GetPreviousUntilLaneStart(double distance) const
Returns a list of waypoints separated by distance from the current waypoint to the start of the lane
std::pair< const road::element::RoadInfoMarkRecord *, const road::element::RoadInfoMarkRecord * > _mark_record
road::Lane::LaneType GetType() const
LaneType
Can be used as flags
static EnumT operator&(EnumT lhs, EnumT rhs)
static EnumT operator|(EnumT lhs, EnumT rhs)
This file contains definitions of common data structures used in traffic manager.
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
LaneChange
Can be used as flags.