Skip to content

Commit 95479b0

Browse files
authored
Merge pull request #78 from AutoModality/AM-729/uam_all_headings
fix: added wrap_2pi
2 parents 87dc0dd + 8689e35 commit 95479b0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/vb_util_lib/am_geometry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ struct PointStamp {
5050
// This takes any angle and makes sure that it is between -PI and +PI
5151
double wrap_pi(double bearing);
5252

53+
// This takes any angle and makes sure that it is between 0 and 2 * PI
54+
double wrap_2pi(double bearing);
55+
5356
//==================================
5457
// Distances and arc lengths
5558
//==================================

src/vb_util_lib/am_geometry.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ double wrap_pi(double bearing)
2626
return bearing;
2727
}
2828

29+
double wrap_2pi(double bearing)
30+
{
31+
while (bearing >= 2 * _PI_R)
32+
{
33+
bearing -= _TWOPI_R;
34+
}
35+
36+
while (bearing <= 0)
37+
{
38+
bearing += _TWOPI_R;
39+
}
40+
41+
return bearing;
42+
}
43+
2944
double pointDistance(geometry_msgs::Point& p1, geometry_msgs::Point& p2) {
3045
double xd = p2.x - p1.x;
3146
double yd = p2.y - p1.y;

0 commit comments

Comments
 (0)