Add coonection point and if is junction

This commit is contained in:
iFuSiiOnzZ 2018-10-19 16:42:33 +02:00
parent 659de82a6a
commit 9cd7ee8c6f
3 changed files with 25 additions and 3 deletions

View File

@ -9,8 +9,11 @@ namespace opendrive {
#define UNUSED(x) (void) x
struct lane_junction_t {
std::string contact_point = "start";
int connection_road = -1;
int from_lane = 0, to_lane = 0;
int from_lane = 0;
int to_lane = 0;
};
static void fnc_generate_roads_data(
@ -35,6 +38,7 @@ namespace opendrive {
int connectingRoad = openDriveRoad.junctions[i].connections[j].attributes.connecting_road;
junctionData.connection_road = connectingRoad;
junctionData.contact_point = openDriveRoad.junctions[i].connections[j].attributes.contact_point;
if (openDriveRoad.junctions[i].connections[j].links.size()) {
junctionData.from_lane = openDriveRoad.junctions[i].connections[j].links[0].from;
@ -71,6 +75,9 @@ namespace opendrive {
carla::road::RoadSegmentDefinition roadSegment(it->first);
carla::road::element::RoadInfoLane *roadInfoLanes = roadSegment.MakeInfo<carla::road::element::RoadInfoLane>();
carla::road::element::RoadGeneralInfo *roadGeneralInfo = roadSegment.MakeInfo<carla::road::element::RoadGeneralInfo>();
roadGeneralInfo->SetIsJunction(it->second->attributes.junction >= 0);
std::vector<carla::opendrive::types::Lane> &lanesLeft = it->second->lane_sections.left;
for(size_t i = 0; i < lanesLeft.size(); ++i)
{
@ -90,7 +97,7 @@ namespace opendrive {
std::vector<lane_junction_t> &options =
junctionsData[it->second->road_link.successor->id][it->first];
for (size_t i = 0; i < options.size(); ++i) {
roadSegment.AddSuccessorID(options[i].connection_road, is_start);
roadSegment.AddSuccessorID(options[i].connection_road, options[i].contact_point == "start");
}
} else {
roadSegment.AddSuccessorID(it->second->road_link.successor->id, is_start);
@ -104,7 +111,7 @@ namespace opendrive {
std::vector<lane_junction_t> &options =
junctionsData[it->second->road_link.predecessor->id][it->first];
for (size_t i = 0; i < options.size(); ++i) {
roadSegment.AddPredecessorID(options[i].connection_road, is_start);
roadSegment.AddPredecessorID(options[i].connection_road, options[i].contact_point == "start");
}
} else {
roadSegment.AddPredecessorID(it->second->road_link.predecessor->id, is_start);

View File

@ -31,6 +31,19 @@ namespace element {
RoadInfo(double distance = 0) : d(distance) {}
};
class RoadGeneralInfo : public RoadInfo {
private:
bool _is_junction = false;
public:
void AcceptVisitor(RoadInfoVisitor &v) final {
v.Visit(*this);
}
void SetIsJunction(bool isJunction) { _is_junction = isJunction; }
bool GetIsJunction() const { return _is_junction; }
};
class RoadInfoVelocity : public RoadInfo {
public:

View File

@ -17,12 +17,14 @@ namespace element {
class RoadInfo;
class RoadInfoLane;
class RoadGeneralInfo;
class RoadInfoVelocity;
class RoadInfoVisitor {
public:
virtual void Visit(RoadInfoLane &) {}
virtual void Visit(RoadGeneralInfo &) {}
virtual void Visit(RoadInfoVelocity &) {}
};