Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autonomous_driving_tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
autonomous_driving
autonomous_driving_tools
Commits
3927f6a6
Commit
3927f6a6
authored
1 year ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Solved a bug in the computation of the start and ened distances.
parent
b2b62d76
No related branches found
No related tags found
1 merge request
!2
Solved a bug when creating a new geometry object: the sale factor is...
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/osm/osm_road_segment.h
+2
-0
2 additions, 0 deletions
include/osm/osm_road_segment.h
src/examples/osm_import_test.cpp
+8
-1
8 additions, 1 deletion
src/examples/osm_import_test.cpp
src/osm/osm_road_segment.cpp
+27
-26
27 additions, 26 deletions
src/osm/osm_road_segment.cpp
with
37 additions
and
27 deletions
include/osm/osm_road_segment.h
+
2
−
0
View file @
3927f6a6
...
@@ -21,7 +21,9 @@ class COSMRoadSegment
...
@@ -21,7 +21,9 @@ class COSMRoadSegment
COSMJunction
*
start_junction
;
COSMJunction
*
start_junction
;
COSMJunction
*
end_junction
;
COSMJunction
*
end_junction
;
double
start_distance
;
double
start_distance
;
double
original_start_distance
;
double
end_distance
;
double
end_distance
;
double
original_end_distance
;
protected:
protected:
void
set_start_distance
(
double
dist
);
void
set_start_distance
(
double
dist
);
void
set_end_distance
(
double
dist
);
void
set_end_distance
(
double
dist
);
...
...
This diff is collapsed.
Click to expand it.
src/examples/osm_import_test.cpp
+
8
−
1
View file @
3927f6a6
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
//const std::string osm_file="/home/shernand/Downloads/test_osm.osm";
//const std::string osm_file="/home/shernand/Downloads/test_osm.osm";
//const std::string osm_file="/home/shernand/Downloads/test_osm2.osm";
//const std::string osm_file="/home/shernand/Downloads/test_osm2.osm";
const
std
::
string
osm_file
=
"/home/shernand/Downloads/diagonal.osm"
;
const
std
::
string
osm_file
=
"/home/shernand/Downloads/diagonal
2
.osm"
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
...
@@ -17,6 +17,13 @@ int main(int argc, char *argv[])
...
@@ -17,6 +17,13 @@ int main(int argc, char *argv[])
map
.
load_osm
(
osm_file
);
map
.
load_osm
(
osm_file
);
/*
map.get_segment_geometry(x,y,heading);
for(unsigned int i=0;i<x.size();i++)
std::cout << x[i] << "," << y[i] << "," << heading[i] << std::endl;
return 0;
*/
map
.
get_lane_geometry
(
x
,
y
,
heading
);
map
.
get_lane_geometry
(
x
,
y
,
heading
);
for
(
unsigned
int
i
=
0
;
i
<
x
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
x
.
size
();
i
++
)
std
::
cout
<<
x
[
i
]
<<
","
<<
y
[
i
]
<<
","
<<
heading
[
i
]
<<
std
::
endl
;
std
::
cout
<<
x
[
i
]
<<
","
<<
y
[
i
]
<<
","
<<
heading
[
i
]
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
src/osm/osm_road_segment.cpp
+
27
−
26
View file @
3927f6a6
...
@@ -8,7 +8,9 @@ COSMRoadSegment::COSMRoadSegment(COSMWay *way)
...
@@ -8,7 +8,9 @@ COSMRoadSegment::COSMRoadSegment(COSMWay *way)
this
->
start_junction
=
NULL
;
this
->
start_junction
=
NULL
;
this
->
end_junction
=
NULL
;
this
->
end_junction
=
NULL
;
this
->
start_distance
=
0.0
;
this
->
start_distance
=
0.0
;
this
->
original_start_distance
=
0.0
;
this
->
end_distance
=
0.0
;
this
->
end_distance
=
0.0
;
this
->
original_end_distance
=
0.0
;
}
}
void
COSMRoadSegment
::
set_start_distance
(
double
dist
)
void
COSMRoadSegment
::
set_start_distance
(
double
dist
)
...
@@ -16,6 +18,8 @@ void COSMRoadSegment::set_start_distance(double dist)
...
@@ -16,6 +18,8 @@ void COSMRoadSegment::set_start_distance(double dist)
COSMNode
*
node1
,
*
node2
;
COSMNode
*
node1
,
*
node2
;
double
length
,
start_end_distance
;
double
length
,
start_end_distance
;
if
(
dist
>
this
->
original_start_distance
)
this
->
original_start_distance
=
dist
;
if
(
dist
>
this
->
start_distance
)
if
(
dist
>
this
->
start_distance
)
{
{
node1
=&
this
->
parent_way
->
get_segment_start_node
(
FIRST_SEGMENT
);
node1
=&
this
->
parent_way
->
get_segment_start_node
(
FIRST_SEGMENT
);
...
@@ -25,12 +29,12 @@ void COSMRoadSegment::set_start_distance(double dist)
...
@@ -25,12 +29,12 @@ void COSMRoadSegment::set_start_distance(double dist)
{
{
if
((
length
-
this
->
end_distance
-
dist
)
<
MIN_ROAD_LENGTH
)
if
((
length
-
this
->
end_distance
-
dist
)
<
MIN_ROAD_LENGTH
)
{
{
if
(
this
->
end_distance
==
0.0
)
if
(
this
->
original_
end_distance
==
0.0
)
this
->
start_distance
=
length
-
MIN_ROAD_LENGTH
;
this
->
start_distance
=
length
-
MIN_ROAD_LENGTH
;
else
else
{
{
start_end_distance
=
this
->
end_distance
+
dist
;
start_end_distance
=
this
->
original_
end_distance
+
dist
;
this
->
end_distance
*
=
length
/
start_end_distance
;
this
->
end_distance
=
this
->
original_end_distance
*
length
/
start_end_distance
;
this
->
end_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
this
->
end_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
this
->
start_distance
=
dist
*
length
/
start_end_distance
;
this
->
start_distance
=
dist
*
length
/
start_end_distance
;
this
->
start_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
this
->
start_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
...
@@ -54,6 +58,8 @@ void COSMRoadSegment::set_end_distance(double dist)
...
@@ -54,6 +58,8 @@ void COSMRoadSegment::set_end_distance(double dist)
COSMNode
*
node1
,
*
node2
;
COSMNode
*
node1
,
*
node2
;
double
length
,
start_end_distance
;
double
length
,
start_end_distance
;
if
(
dist
>
this
->
original_end_distance
)
this
->
original_end_distance
=
dist
;
if
(
dist
>
this
->
end_distance
)
if
(
dist
>
this
->
end_distance
)
{
{
node1
=&
this
->
parent_way
->
get_segment_start_node
(
LAST_SEGMENT
);
node1
=&
this
->
parent_way
->
get_segment_start_node
(
LAST_SEGMENT
);
...
@@ -63,14 +69,14 @@ void COSMRoadSegment::set_end_distance(double dist)
...
@@ -63,14 +69,14 @@ void COSMRoadSegment::set_end_distance(double dist)
{
{
if
((
length
-
this
->
start_distance
-
dist
)
<
MIN_ROAD_LENGTH
)
if
((
length
-
this
->
start_distance
-
dist
)
<
MIN_ROAD_LENGTH
)
{
{
if
(
this
->
start_distance
==
0.0
)
if
(
this
->
original_
start_distance
==
0.0
)
this
->
end_distance
=
length
-
MIN_ROAD_LENGTH
;
this
->
end_distance
=
length
-
MIN_ROAD_LENGTH
;
else
else
{
{
start_end_distance
=
dist
+
this
->
start_distance
;
start_end_distance
=
dist
+
this
->
original_
start_distance
;
this
->
end_distance
=
dist
*
length
/
start_end_distance
;
this
->
end_distance
=
dist
*
length
/
start_end_distance
;
this
->
end_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
this
->
end_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
this
->
start_distance
*
=
length
/
start_end_distance
;
this
->
start_distance
=
this
->
original_start_distance
*
length
/
start_end_distance
;
this
->
start_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
this
->
start_distance
-=
MIN_ROAD_LENGTH
/
2.0
;
}
}
}
}
...
@@ -112,15 +118,13 @@ bool COSMRoadSegment::generate_fwd_geometry(CRoad *road,double resolution)
...
@@ -112,15 +118,13 @@ bool COSMRoadSegment::generate_fwd_geometry(CRoad *road,double resolution)
start_point
.
heading
=
heading1
;
start_point
.
heading
=
heading1
;
start_point
.
curvature
=
0.0
;
start_point
.
curvature
=
0.0
;
road
->
set_start_point
(
start_point
);
road
->
set_start_point
(
start_point
);
//
prev_heading=heading1;
//
prev_heading=heading1;
}
}
if
((
i
+
1
)
==
(
this
->
parent_way
->
get_num_nodes
()
-
1
))
// straight line
if
((
i
+
1
)
==
(
this
->
parent_way
->
get_num_nodes
()
-
1
))
// straight line
{
{
// angle2=atan2(y_offset,length1-this->end_distance);
// angle2=atan2(y_offset,length1-this->end_distance);
// angle3=diff_angle(heading1,prev_heading)+angle2;
// angle3=diff_angle(heading1,prev_heading)+angle2;
// if(fabs(angle3)<1.5707)
if
((
length1
-
this
->
end_distance
-
prev_dist
)
>
resolution
)
// && fabs(angle3)<1.5707)
// {
if
((
length1
-
this
->
end_distance
-
prev_dist
)
>
0.0
)
{
{
end_point
.
x
=
x
+
(
length1
-
this
->
end_distance
)
*
cos
(
heading1
)
-
y_offset
*
sin
(
heading1
);
end_point
.
x
=
x
+
(
length1
-
this
->
end_distance
)
*
cos
(
heading1
)
-
y_offset
*
sin
(
heading1
);
end_point
.
y
=
y
+
(
length1
-
this
->
end_distance
)
*
sin
(
heading1
)
+
y_offset
*
cos
(
heading1
);
end_point
.
y
=
y
+
(
length1
-
this
->
end_distance
)
*
sin
(
heading1
)
+
y_offset
*
cos
(
heading1
);
...
@@ -128,7 +132,6 @@ bool COSMRoadSegment::generate_fwd_geometry(CRoad *road,double resolution)
...
@@ -128,7 +132,6 @@ bool COSMRoadSegment::generate_fwd_geometry(CRoad *road,double resolution)
end_point
.
curvature
=
0.0
;
end_point
.
curvature
=
0.0
;
road
->
add_segment
(
end_point
);
road
->
add_segment
(
end_point
);
}
}
// }
}
}
else
else
{
{
...
@@ -141,23 +144,23 @@ bool COSMRoadSegment::generate_fwd_geometry(CRoad *road,double resolution)
...
@@ -141,23 +144,23 @@ bool COSMRoadSegment::generate_fwd_geometry(CRoad *road,double resolution)
if
(
i
==
0
)
if
(
i
==
0
)
{
{
node2
->
get_location
(
x
,
y
);
node2
->
get_location
(
x
,
y
);
start_point
.
x
=
x
-
y_offset
*
sin
(
heading
1
);
start_point
.
x
=
x
-
y_offset
*
sin
(
heading
2
);
start_point
.
y
=
y
+
y_offset
*
cos
(
heading
1
);
start_point
.
y
=
y
+
y_offset
*
cos
(
heading
2
);
start_point
.
heading
=
heading2
;
start_point
.
heading
=
heading2
;
start_point
.
curvature
=
0.0
;
start_point
.
curvature
=
0.0
;
road
->
set_start_point
(
start_point
);
road
->
set_start_point
(
start_point
);
prev_dist
=
0.0
;
prev_dist
=
0.0
;
//
prev_heading=heading2;
//
prev_heading=heading2;
}
}
else
if
((
i
+
2
)
==
(
this
->
parent_way
->
get_num_nodes
()
-
1
))
else
if
((
i
+
2
)
==
(
this
->
parent_way
->
get_num_nodes
()
-
1
))
{
{
prev_dist
=
dist
;
prev_dist
=
dist
;
//
prev_heading=heading2;
//
prev_heading=heading2;
}
}
else
else
{
{
prev_dist
=
dist
;
prev_dist
=
dist
;
//
prev_heading=heading1;
//
prev_heading=heading1;
}
}
continue
;
continue
;
}
}
...
@@ -213,15 +216,14 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
...
@@ -213,15 +216,14 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
start_point
.
heading
=
heading1
;
start_point
.
heading
=
heading1
;
start_point
.
curvature
=
0.0
;
start_point
.
curvature
=
0.0
;
road
->
set_start_point
(
start_point
);
road
->
set_start_point
(
start_point
);
//
prev_heading=heading1;
//
prev_heading=heading1;
}
}
if
((
i
-
1
)
==
0
)
// straight line
if
((
i
-
1
)
==
0
)
// straight line
{
{
// angle2=atan2(y_offset,length1-this->end_distance);
// angle2=atan2(y_offset,length1-this->end_distance);
// angle3=diff_angle(heading1,prev_heading)+angle2;
// angle3=diff_angle(heading1,prev_heading)+angle2;
// if(fabs(angle3)<1.5707)
// if(fabs(angle3)<1.5707)
// {
if
((
length1
-
this
->
start_distance
-
prev_dist
)
>
resolution
)
// && fabs(angle3)<1.5707)
if
((
length1
-
this
->
start_distance
-
prev_dist
)
>
0.0
)
{
{
end_point
.
x
=
x
+
(
length1
-
this
->
start_distance
)
*
cos
(
heading1
)
-
y_offset
*
sin
(
heading1
);
end_point
.
x
=
x
+
(
length1
-
this
->
start_distance
)
*
cos
(
heading1
)
-
y_offset
*
sin
(
heading1
);
end_point
.
y
=
y
+
(
length1
-
this
->
start_distance
)
*
sin
(
heading1
)
+
y_offset
*
cos
(
heading1
);
end_point
.
y
=
y
+
(
length1
-
this
->
start_distance
)
*
sin
(
heading1
)
+
y_offset
*
cos
(
heading1
);
...
@@ -229,7 +231,6 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
...
@@ -229,7 +231,6 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
end_point
.
curvature
=
0.0
;
end_point
.
curvature
=
0.0
;
road
->
add_segment
(
end_point
);
road
->
add_segment
(
end_point
);
}
}
// }
}
}
else
else
{
{
...
@@ -242,23 +243,23 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
...
@@ -242,23 +243,23 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
if
(
i
==
(
this
->
parent_way
->
get_num_nodes
()
-
1
))
if
(
i
==
(
this
->
parent_way
->
get_num_nodes
()
-
1
))
{
{
node2
->
get_location
(
x
,
y
);
node2
->
get_location
(
x
,
y
);
start_point
.
x
=
x
-
y_offset
*
sin
(
heading
1
);
start_point
.
x
=
x
-
y_offset
*
sin
(
heading
2
);
start_point
.
y
=
y
+
y_offset
*
cos
(
heading
1
);
start_point
.
y
=
y
+
y_offset
*
cos
(
heading
2
);
start_point
.
heading
=
heading2
;
start_point
.
heading
=
heading2
;
start_point
.
curvature
=
0.0
;
start_point
.
curvature
=
0.0
;
road
->
set_start_point
(
start_point
);
road
->
set_start_point
(
start_point
);
prev_dist
=
0.0
;
prev_dist
=
0.0
;
//
prev_heading=heading2;
//
prev_heading=heading2;
}
}
else
if
((
i
-
2
)
==
0
)
else
if
((
i
-
2
)
==
0
)
{
{
prev_dist
=
dist
;
prev_dist
=
dist
;
//
prev_heading=heading2;
//
prev_heading=heading2;
}
}
else
else
{
{
prev_dist
=
dist
;
prev_dist
=
dist
;
//
prev_heading=heading1;
//
prev_heading=heading1;
}
}
continue
;
continue
;
}
}
...
@@ -280,7 +281,7 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
...
@@ -280,7 +281,7 @@ bool COSMRoadSegment::generate_bwd_geometry(CRoad *road,double resolution)
end_point
.
curvature
=
0.0
;
end_point
.
curvature
=
0.0
;
road
->
add_segment
(
end_point
);
road
->
add_segment
(
end_point
);
prev_dist
=
dist
;
prev_dist
=
dist
;
//
prev_heading=heading1;
//
prev_heading=heading1;
}
}
}
}
if
(
road
->
get_num_segments
()
==
0
)
if
(
road
->
get_num_segments
()
==
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment