Skip to content
Snippets Groups Projects
Commit b466ad0b authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Improved the update and clean references functions.

When possible, always use the spline geometry.
parent 84c6d4b6
No related branches found
No related tags found
1 merge request!2Solved a bug when creating a new geometry object: the sale factor is...
...@@ -70,7 +70,7 @@ class COpendriveRoadSegment ...@@ -70,7 +70,7 @@ class COpendriveRoadSegment
bool updated(segment_up_ref_t &segment_refs); bool updated(segment_up_ref_t &segment_refs);
COpendriveRoadSegment *get_original_segment(segment_up_ref_t &segment_refs); COpendriveRoadSegment *get_original_segment(segment_up_ref_t &segment_refs);
void update_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs); void update_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs);
void clean_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs); void clean_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs,link_up_ref_t &new_link_ref);
void add_lanes(lanes::laneSection_type &lane_section); void add_lanes(lanes::laneSection_type &lane_section);
void add_lane(const ::lane &lane_info); void add_lane(const ::lane &lane_info);
void remove_lane(COpendriveLane *lane); void remove_lane(COpendriveLane *lane);
...@@ -86,20 +86,20 @@ class COpendriveRoadSegment ...@@ -86,20 +86,20 @@ class COpendriveRoadSegment
void link_segment(COpendriveRoadSegment *segment,int from,bool from_start, int to,bool to_start); void link_segment(COpendriveRoadSegment *segment,int from,bool from_start, int to,bool to_start);
void set_left_neighbor(COpendriveRoadSegment *segment,bool same_direction); void set_left_neighbor(COpendriveRoadSegment *segment,bool same_direction);
void set_right_neighbor(COpendriveRoadSegment *segment,bool same_direction); void set_right_neighbor(COpendriveRoadSegment *segment,bool same_direction);
bool connects_to(COpendriveRoadSegment *segment); bool connects_to(COpendriveRoadSegment *segment) const;
bool connects_segments(COpendriveRoadSegment *segment1,COpendriveRoadSegment *segment2); bool connects_segments(COpendriveRoadSegment *segment1,COpendriveRoadSegment *segment2) const;
void set_junction(COpendriveJunction *junction); void set_junction(COpendriveJunction *junction);
COpendriveRoadSegment *get_sub_segment(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,link_up_ref_t &new_link_ref,int node_side,TOpendriveWorldPose *start=NULL,TOpendriveWorldPose *end=NULL) const; COpendriveRoadSegment *get_sub_segment(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,link_up_ref_t &new_link_ref,int node_side,TOpendriveWorldPose *start=NULL,TOpendriveWorldPose *end=NULL) const;
COpendriveRoadSegment *clone(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,link_up_ref_t &new_link_ref) const; COpendriveRoadSegment *clone(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,link_up_ref_t &new_link_ref) const;
TOpendriveLocalPose transform_to_local_pose(const TOpendriveTrackPose &track); TOpendriveLocalPose transform_to_local_pose(const TOpendriveTrackPose &track);
TOpendriveWorldPose transform_to_world_pose(const TOpendriveTrackPose &track); TOpendriveWorldPose transform_to_world_pose(const TOpendriveTrackPose &track);
void add_lanes_to_parent(void); void add_lanes_to_parent(void);
void update(void); void update(void);
public: public:
/* functions for manual creation of road segments */ /* functions for manual creation of road segments */
COpendriveRoadSegment(const std::string &name,opendrive_mark_t center_mark=OD_MARK_NONE,unsigned int id=-1,bool junction_segment=false); COpendriveRoadSegment(const std::string &name,opendrive_mark_t center_mark=OD_MARK_NONE,unsigned int id=-1,bool junction_segment=false);
void add_left_lane(COpendriveLane &lane); int add_left_lane(COpendriveLane &lane);
void add_right_lane(COpendriveLane &lane); int add_right_lane(COpendriveLane &lane);
void add_geometry(COpendriveGeometry *geometry); void add_geometry(COpendriveGeometry *geometry);
/** /**
* \brief Returns the Opendrive name * \brief Returns the Opendrive name
...@@ -264,7 +264,7 @@ class COpendriveRoadSegment ...@@ -264,7 +264,7 @@ class COpendriveRoadSegment
* *
* \return length of the road segment in meters. * \return length of the road segment in meters.
*/ */
double get_length(void) const; double get_length(bool opendrive=false) const;
/** /**
* \brief returns the pose of the road segment at a given point * \brief returns the pose of the road segment at a given point
* *
......
#include "osm/osm_map.h" #include "osm/osm_map.h"
#include "opendrive_road.h"
#include "exceptions.h" #include "exceptions.h"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <limits> #include <limits>
const std::string filename="/home/shernand/Downloads/map.osm"; const std::string filename="/home/shernand/Downloads/map.osm";
//const std::string filename="/home/shernand/Downloads/castelldefels.osm";
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
...@@ -12,13 +14,17 @@ int main(int argc, char *argv[]) ...@@ -12,13 +14,17 @@ int main(int argc, char *argv[])
try{ try{
COSMMap map; COSMMap map;
COpendriveRoad road;
map.load(filename); map.load(filename);
map.convert_to_opendrive(road);
road.save("./new_road.xodr");
map.get_paths(x,y,heading,curvature); map.get_paths(x,y,heading,curvature);
for(unsigned int i=0;i<x.size();i++) for(unsigned int i=0;i<x.size();i++)
std::cout << x[i] << "," << y[i] << std::endl; std::cout << x[i] << "," << y[i] << std::endl;
// std::cout << map << std::endl; std::cout << map << std::endl;
} }
catch (std::exception &e) catch (std::exception &e)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment