File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ struct PointStamp {
5050// This takes any angle and makes sure that it is between -PI and +PI
5151double 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// ==================================
Original file line number Diff line number Diff 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+
2944double pointDistance (geometry_msgs::Point& p1, geometry_msgs::Point& p2) {
3045 double xd = p2.x - p1.x ;
3146 double yd = p2.y - p1.y ;
You can’t perform that action at this time.
0 commit comments