Add information for next and prev lane

This commit is contained in:
iFuSiiOnzZ 2018-11-01 10:17:56 +01:00
parent 46a6ecec1c
commit 6f7e3cfcac
4 changed files with 61 additions and 4 deletions

View File

@ -128,6 +128,12 @@ namespace opendrive {
}
} else {
roadSegment.AddSuccessorID(it->second->road_link.successor->id, is_start);
for(size_t i = 0; i < lanesLeft.size(); ++i) {
if(lanesLeft[i].link != nullptr) {
roadSegment.AddNextLaneInfo(lanesLeft[i].attributes.id, lanesLeft[i].link->successor_id, it->second->road_link.successor->id);
roadSegment.AddPrevLaneInfo(lanesLeft[i].attributes.id, lanesLeft[i].link->predecessor_id, it->second->road_link.predecessor->id);
}
}
}
}
@ -142,6 +148,12 @@ namespace opendrive {
}
} else {
roadSegment.AddPredecessorID(it->second->road_link.predecessor->id, is_start);
for(size_t i = 0; i < lanesRight.size(); ++i) {
if(lanesRight[i].link != nullptr) {
roadSegment.AddNextLaneInfo(lanesRight[i].attributes.id, lanesRight[i].link->successor_id, it->second->road_link.successor->id);
roadSegment.AddPrevLaneInfo(lanesRight[i].attributes.id, lanesRight[i].link->predecessor_id, it->second->road_link.predecessor->id);
}
}
}
}

View File

@ -19,8 +19,7 @@ namespace road {
bool AddRoadSegmentDefinition(element::RoadSegmentDefinition &seg);
void SetJunctionInformation(const std::vector<carla::road::lane_junction_t> &junctionInfo)
{
void SetJunctionInformation(const std::vector<carla::road::lane_junction_t> &junctionInfo) {
_map_data.SetJunctionInformation(junctionInfo);
}

View File

@ -31,7 +31,9 @@ namespace element {
: _id(def.GetId()),
_successors_is_start(std::move(def._successor_is_start)),
_predecessors_is_start(std::move(def._predecessors_is_start)),
_geom(std::move(def._geom)) {
_geom(std::move(def._geom)),
_next_lane(std::move(def._next_lane)),
_prev_lane(std::move(def._prev_lane)) {
for (auto &&a : def._info) {
_info.insert(std::move(a));
}
@ -112,6 +114,36 @@ namespace element {
return _predecessors;
}
// Given the current lane it gives an std::pair of the lane id the and road id
// where you can go.
//
// INPUT:
// int current_lane_id for which lane do you want the next
//
// OUTPUT:
// std::pair<int, int> return a pair with lane id (first int) and the road id (second int),
// if no lane has been found the given pair it will be (0, 0) as lane id
// zero used for the reference line
std::pair<int, int> GetNextLane(int current_lane_id) const {
std::map<int, std::pair<int, int>>::const_iterator it = _next_lane.find(current_lane_id);
return it == _next_lane.end() ? std::pair<int, int>(0, 0) : it->second;
}
// Given the current lane it gives an std::pair with the lane id the and road id
// where you can go.
//
// INPUT:
// int current_lane_id for which lane do you want the next
//
// OUTPUT:
// std::pair<int, int> return a pair with lane id (first int) and the road id (second int),
// if no lane has been found the given pair it will be (0, 0) as lane id
// zero used for the reference line
std::pair<int, int> GetPrevLane(int current_lane_id) const {
std::map<int, std::pair<int, int>>::const_iterator it = _prev_lane.find(current_lane_id);
return it == _next_lane.end() ? std::pair<int, int>(0, 0) : it->second;
}
// Search for the last geometry with less start_offset before 'dist'
DirectedPoint GetDirectedPointIn(double dist) const {
assert(_length > 0.0);
@ -207,6 +239,8 @@ namespace element {
std::vector<std::unique_ptr<Geometry>> _geom;
std::multiset<std::shared_ptr<RoadInfo>, LessComp> _info;
double _length = -1.0;
std::map<int, std::pair<int, int>> _next_lane;
std::map<int, std::pair<int, int>> _prev_lane;
};
} // namespace element

View File

@ -28,7 +28,9 @@ namespace element {
_successor_is_start(std::move(rsd._successor_is_start)),
_predecessors_is_start(std::move(rsd._predecessors_is_start)),
_geom(std::move(rsd._geom)),
_info(std::move(rsd._info)) {}
_info(std::move(rsd._info)),
_next_lane(std::move(rsd._next_lane)),
_prev_lane(std::move(rsd._prev_lane)) {}
RoadSegmentDefinition(id_type id) {
assert(id >= 0);
@ -49,6 +51,14 @@ namespace element {
_predecessors_is_start.emplace_back(is_start);
}
void AddNextLaneInfo(int current_lane_id, int next_lane_id, int next_road_id) {
_next_lane[current_lane_id] = std::pair<int, int>(next_lane_id, next_road_id);
}
void AddPrevLaneInfo(int current_lane_id, int next_lane_id, int next_road_id) {
_prev_lane[current_lane_id] = std::pair<int, int>(next_lane_id, next_road_id);
}
// usage MakeGeometry<GeometryArc>(len, st_pos_offs, head, st_pos, curv)
template <typename T, typename ... Args>
void MakeGeometry(Args && ... args) {
@ -85,6 +95,8 @@ namespace element {
std::vector<bool> _predecessors_is_start;
std::vector<std::unique_ptr<Geometry>> _geom;
std::vector<std::shared_ptr<RoadInfo>> _info;
std::map<int, std::pair<int, int>> _next_lane;
std::map<int, std::pair<int, int>> _prev_lane;
};
} // namespace element