Skip to content

Commit

Permalink
fix: set lanes with id=0 to type none by default and implemented sani…
Browse files Browse the repository at this point in the history
…ty checks for lane widening and lane drops
  • Loading branch information
jannikbusse committed Dec 19, 2023
1 parent 291fec4 commit 0cad813
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/connection/linkSegments.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ int linkSegments(const DOMElement* rootNode, roadNetwork &data)
std::cout << "\t"<< linkcount << " links are defined" << std::endl;
}

//iterate over all links
for (DOMElement *segmentLink = links->getFirstElementChild();segmentLink != NULL; segmentLink = segmentLink->getNextElementSibling())
{
int fromSegment = readIntAttrFromNode(segmentLink, "fromSegment");
Expand Down
4 changes: 0 additions & 4 deletions src/executable/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ int main(int argc, char** argv){
cfg.filename = settings.filename;
cfg.xmlSchemeLocation = &schemaLocation[0];
cfg.outputName = settings.outputName;
//setFileName(settings.filename);
//setXMLSchemaLocation(&schemaLocation[0]);
//setOutputName(settings.outputName);
//setSilentMode(settings.silentMode);
executePipelineCfg(cfg);

return 0;
Expand Down
23 changes: 21 additions & 2 deletions src/generation/addLaneSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

#include <string.h>

/**
* @brief function adds a laneSection with laneWideing to a given lanesection set
*
Expand All @@ -23,10 +25,19 @@
* @param s position of lane widening
* @param ds length of lane widening
* @param addouterLane specifies if additional lane is on the outer side or not
* @param rroad road to which lane widening is applied. This is used only for sanity chekcs
* @return int error code
*/
int addLaneWidening(std::vector<laneSection> &secs, int addLaneId, double s, double ds, bool addOuterLane)
int addLaneWidening(std::vector<laneSection> &secs, int addLaneId, double s, double ds, bool addOuterLane, const road* rroad = nullptr)
{

if(rroad && s + ds >= rroad->length)
{
std::string err = "Lane Widening length exceeds total road length in seg " + std::to_string(rroad->inputSegmentId) + " road " + std::to_string(rroad->inputId);
throwError(err);
return -1;
}

std::vector<laneSection>::iterator it;
int i = 0;

Expand Down Expand Up @@ -159,10 +170,18 @@ int addLaneWidening(std::vector<laneSection> &secs, int addLaneId, double s, dou
* @param dropLaneID determines the lane id of the drop
* @param s position of laneDrop
* @param ds length of laneDrop
* @param rroad road to which the lanedrop is applied to, is only used for sanity checks
* @return int error code
*/
int addLaneDrop(std::vector<laneSection> &secs, int dropLaneID, double s, double ds)
int addLaneDrop(std::vector<laneSection> &secs, int dropLaneID, double s, double ds, const road* rroad = nullptr)
{
if(rroad && s + ds >= rroad->length)
{
std::string err = "Lane Drop length exceeds total road length in seg " + std::to_string(rroad->inputSegmentId) + " road " + std::to_string(rroad->inputId);
throwError(err);
return -1;
}

std::vector<laneSection>::iterator it;
std::vector<lane>::iterator itt;

Expand Down
3 changes: 2 additions & 1 deletion src/generation/buildRoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ int addLanes(DOMElement* roadIn, road &r, int mode)
lane l2;
l2.id = 0;
l2.rm.type = "broken";
l2.type = "none";
l2.w.a = 0;
l2.turnStraight = false;
laneSec.lanes.push_back(l2);
Expand Down Expand Up @@ -554,7 +555,7 @@ int addLaneSectionChanges(DOMElement* roadIn, road &r, DOMElement* automaticWide
if (s > r.length)
continue;

if (addLaneWidening(r.laneSections, side, s, ds, false))
if (addLaneWidening(r.laneSections, side, s, ds, false, &r))
{
std::cerr << "ERR: error in addLaneWidening";
return 1;
Expand Down
1 change: 0 additions & 1 deletion src/libfiles/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ EXPORTED int executePipeline(char* file)
return -1;
}


// --- initialization ------------------------------------------------------

xmlTree inputxml;
Expand Down
2 changes: 0 additions & 2 deletions variation/variation/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def executePipeline(cfg):
"""

libpath = ""
c = 0

if os.name == "posix": # if MacOS
libpath = os.path.join(os.path.dirname(__file__), "resources/libroad-generation.so")
Expand All @@ -205,7 +204,6 @@ def executePipeline(cfg):
rcfg.outname = c_char_p(filenamearg[:-4].encode('utf-8'))
rcfg.xmllocation = argXMLPath
roadgen.executePipelineCfg(rcfg)
c += 1



Expand Down

0 comments on commit 0cad813

Please sign in to comment.