Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
geoops Namespace Reference

Namespace containing functions related to operations on global position number systems and other datatypes. More...

Classes

struct  GeoMeasurement
 This struct is used to store the distance, arc length, and relative bearing for a calculated geodesic between two points. Storing these values in a struct allows for easy handling and access to said variables. More...
 
struct  GPSCoordinate
 This struct stores/contains information about a GPS data. More...
 
struct  RoverPose
 This struct is used by the WaypointHandler to provide an easy way to store all pose data about the rover. More...
 
struct  UTMCoordinate
 This struct stores/contains information about a UTM coordinate. More...
 
struct  Waypoint
 This struct is used by the WaypointHandler class to store location, size, and type information about a given location of interest of waypoint. More...
 

Enumerations

enum class  WaypointType {
  eNavigationWaypoint , eTagWaypoint , eMalletWaypoint , eWaterBottleWaypoint ,
  eObjectWaypoint , eObstacleWaypoint , eUNKNOWN
}
 
enum class  PositionFixType {
  eNoFix , eDeadReckoning , eFix2D , eFix3D ,
  eGNSSDeadReckoningCombined , eTimeOnly , eUNKNOWN
}
 

Functions

UTMCoordinate ConvertGPSToUTM (const GPSCoordinate &stGPSCoord)
 Given a GPS coordinate, convert to UTM and create a new UTMCoordinate object.
 
GPSCoordinate ConvertUTMToGPS (const UTMCoordinate &stUTMCoord)
 Given a UTM coordinate, convert to GPS and create a new GPSCoordinate object.
 
GeoMeasurement CalculateGeoMeasurement (const GPSCoordinate &stCoord1, const GPSCoordinate &stCoord2)
 The shortest path between two points on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Given those two points create an ellipsoid with earth's characteristics and find the distance between them.
 
GeoMeasurement CalculateGeoMeasurement (const UTMCoordinate &stCoord1, const UTMCoordinate &stCoord2)
 The shortest path between two points on an ellipsoid at (easting1, northing1) and (easting2, northing2) is called the geodesic. Given those two points create an ellipsoid with earth's characteristics and find the distance between them.
 
GeoMeasurement CalculateGeoMeasurement (const geoops::Waypoint &stWaypoint1, const geoops::Waypoint &stWaypoint2)
 The shortest path between two waypoints on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic.
 

Detailed Description

Namespace containing functions related to operations on global position number systems and other datatypes.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-30

Enumeration Type Documentation

◆ WaypointType

enum class geoops::WaypointType
strong
40 {
41 eNavigationWaypoint,
42 eTagWaypoint,
43 eMalletWaypoint,
44 eWaterBottleWaypoint,
45 eObjectWaypoint, // Used to represent either Mallet or WaterBottle waypoint.
46 eObstacleWaypoint,
47 eUNKNOWN
48 };

◆ PositionFixType

enum class geoops::PositionFixType
strong
52 {
53 eNoFix,
54 eDeadReckoning,
55 eFix2D,
56 eFix3D,
57 eGNSSDeadReckoningCombined,
58 eTimeOnly,
59 eUNKNOWN
60 };

Function Documentation

◆ ConvertGPSToUTM()

UTMCoordinate geoops::ConvertGPSToUTM ( const GPSCoordinate stGPSCoord)
inline

Given a GPS coordinate, convert to UTM and create a new UTMCoordinate object.

Parameters
stGPSCoord- The struct containing the GPS coordinate data.
Returns
UTMCoordinate - The UTM coordinate corresponding to the given GPS coordinate.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-12
303 {
304 // Create instance variables.
305 UTMCoordinate stConvertCoord;
306
307 // Get data out of the GPS coord and repackage it into the UTM struct.
308 stConvertCoord.d2DAccuracy = stGPSCoord.d2DAccuracy;
309 stConvertCoord.d3DAccuracy = stGPSCoord.d3DAccuracy;
310 stConvertCoord.dAltitude = stGPSCoord.dAltitude;
311 stConvertCoord.eCoordinateAccuracyFixType = stGPSCoord.eCoordinateAccuracyFixType;
312 stConvertCoord.bIsDifferential = stGPSCoord.bIsDifferential;
313 stConvertCoord.tmTimestamp = stGPSCoord.tmTimestamp;
314
315 // Catch errors from GeographicLib.
316 try
317 {
318 // Forward solve for the UTM coord.
319 GeographicLib::UTMUPS::Forward(stGPSCoord.dLatitude,
320 stGPSCoord.dLongitude,
321 stConvertCoord.nZone,
322 stConvertCoord.bWithinNorthernHemisphere,
323 stConvertCoord.dEasting,
324 stConvertCoord.dNorthing,
325 stConvertCoord.dMeridianConvergence,
326 stConvertCoord.dScale);
327 }
328 catch (const GeographicLib::GeographicErr::exception& geError)
329 {
330 // Submit logger message.
331 LOG_ERROR(logging::g_qSharedLogger, "Unable to forward solve a GPSCoordinate to UTMCoordinate. GeographicLib error is: {}", geError.what());
332 }
333
334 // Return the converted UTM coordinate.
335 return stConvertCoord;
336 }
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:195
Here is the caller graph for this function:

◆ ConvertUTMToGPS()

GPSCoordinate geoops::ConvertUTMToGPS ( const UTMCoordinate stUTMCoord)
inline

Given a UTM coordinate, convert to GPS and create a new GPSCoordinate object.

Parameters
stUTMCoord- The struct containing the UTM coordinate data.
Returns
GPSCoordinate - The GPS coordinate corresponding to the given UTM coordinate.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-12
348 {
349 // Create instance variables.
350 GPSCoordinate stConvertCoord;
351
352 // Get data out of the UTM coord and repackage it into the GPS struct.
353 stConvertCoord.d2DAccuracy = stUTMCoord.d2DAccuracy;
354 stConvertCoord.d3DAccuracy = stUTMCoord.d3DAccuracy;
355 stConvertCoord.dAltitude = stUTMCoord.dAltitude;
356 stConvertCoord.eCoordinateAccuracyFixType = stUTMCoord.eCoordinateAccuracyFixType;
357 stConvertCoord.bIsDifferential = stUTMCoord.bIsDifferential;
358 stConvertCoord.tmTimestamp = stUTMCoord.tmTimestamp;
359
360 // Catch errors from GeographicLib.
361 try
362 {
363 // Reverse solve for the UTM coord.
364 GeographicLib::UTMUPS::Reverse(stUTMCoord.nZone,
365 stUTMCoord.bWithinNorthernHemisphere,
366 std::fabs(stUTMCoord.dEasting),
367 stUTMCoord.dNorthing,
368 stConvertCoord.dLatitude,
369 stConvertCoord.dLongitude,
370 stConvertCoord.dMeridianConvergence,
371 stConvertCoord.dScale);
372 }
373 catch (const GeographicLib::GeographicErr::exception& geError)
374 {
375 // Submit logger message.
376 LOG_ERROR(logging::g_qSharedLogger, "Unable to reverse solve a UTMCoordinate to GPSCoordinate. GeographicLib error is: {}", geError.what());
377 }
378
379 // Return the converted UTM coordinate.
380 return stConvertCoord;
381 }
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:99
Here is the caller graph for this function:

◆ CalculateGeoMeasurement() [1/3]

GeoMeasurement geoops::CalculateGeoMeasurement ( const GPSCoordinate stCoord1,
const GPSCoordinate stCoord2 
)
inline

The shortest path between two points on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Given those two points create an ellipsoid with earth's characteristics and find the distance between them.

Parameters
stCoord1- The first GPS coordinate.
stCoord2- The second GPS coordinate.
Returns
GeoMeasurement - Struct containing the distance in meters and arc length degrees, plus the bearing relative to the first point and second point.
See also
https://geographiclib.sourceforge.io/C++/doc/classGeographicLib_1_1Geodesic.html#ae66c9cecfcbbcb1da52cb408e69f65de
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-13
523 {
524 // Create instance variables.
525 GeoMeasurement stMeasurements;
526
527 // Construct a geodesic with earth characteristics. (Radius and flattening)
528 // The WGS84 standard is widely used and aligns with Google Maps.
529 GeographicLib::Geodesic geGeodesic = GeographicLib::Geodesic::WGS84();
530
531 // Solve the inverse geodesic for distance and arc length degrees at the center of the globe, and relative bearings.
532 stMeasurements.dArcLengthDegrees = geGeodesic.Inverse(stCoord1.dLatitude,
533 stCoord1.dLongitude,
534 stCoord2.dLatitude,
535 stCoord2.dLongitude,
536 stMeasurements.dDistanceMeters,
537 stMeasurements.dStartRelativeBearing,
538 stMeasurements.dEndRelativeBearing);
539
540 // NOTE: Regarding azi1 vs azi2, azi1 is the direction measured at point 1 (your navigation aid) to point 2. azi2 is the direction measured at point 2 (your
541 // location) away from point 1. (If you want the direction to point 1, add ±180° to azi2.)
542 // Map the -180, 180 range of the azimuths to 0, 360, with both points zeroed at North.
543 stMeasurements.dStartRelativeBearing = std::fmod((stMeasurements.dStartRelativeBearing + 360), 360);
544 stMeasurements.dEndRelativeBearing = std::fmod((stMeasurements.dEndRelativeBearing + 180), 360);
545 // Ensure the result angle is positive.
546 if (stMeasurements.dStartRelativeBearing < 0)
547 {
548 // Add 360 degrees.
549 stMeasurements.dStartRelativeBearing += 360;
550 }
551 // Ensure the result angle is positive.
552 if (stMeasurements.dEndRelativeBearing < 0)
553 {
554 // Add 360 degrees.
555 stMeasurements.dEndRelativeBearing += 360;
556 }
557
558 // Return result distance.
559 return stMeasurements;
560 }
This struct is used to store the distance, arc length, and relative bearing for a calculated geodesic...
Definition GeospatialOperations.hpp:82
Here is the caller graph for this function:

◆ CalculateGeoMeasurement() [2/3]

GeoMeasurement geoops::CalculateGeoMeasurement ( const UTMCoordinate stCoord1,
const UTMCoordinate stCoord2 
)
inline

The shortest path between two points on an ellipsoid at (easting1, northing1) and (easting2, northing2) is called the geodesic. Given those two points create an ellipsoid with earth's characteristics and find the distance between them.

Parameters
stCoord1- The first UTM coordinate.
stCoord2- The second UTM coordinate.
Returns
GeoMeasurement - Struct containing the distance in meters and arc length degrees, plus the bearing relative to the first point and second point.
See also
https://geographiclib.sourceforge.io/C++/doc/classGeographicLib_1_1Geodesic.html#ae66c9cecfcbbcb1da52cb408e69f65de
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-01-14
576 {
577 // Create instance variables.
578 GeoMeasurement stMeasurements;
579
580 // Construct a geodesic with earth characteristics. (Radius and flattening)
581 // The WGS84 standard is widely used and aligns with Google Maps.
582 GeographicLib::Geodesic geGeodesic = GeographicLib::Geodesic::WGS84();
583
584 // Convert the given UTM coords into GPS coords for temporary use.
585 GPSCoordinate stGPSCoord1 = ConvertUTMToGPS(stCoord1);
586 GPSCoordinate stGPSCoord2 = ConvertUTMToGPS(stCoord2);
587
588 // Solve the inverse geodesic.
589 stMeasurements.dArcLengthDegrees = geGeodesic.Inverse(stGPSCoord1.dLatitude,
590 stGPSCoord1.dLongitude,
591 stGPSCoord2.dLatitude,
592 stGPSCoord2.dLongitude,
593 stMeasurements.dDistanceMeters,
594 stMeasurements.dStartRelativeBearing,
595 stMeasurements.dEndRelativeBearing);
596
597 // NOTE: Regarding azi1 vs azi2, azi1 is the direction measured at point 1 (your navigation aid) to point 2. azi2 is the direction measured at point 2 (your
598 // location) away from point 1. (If you want the direction to point 1, add ±180° to azi2.)
599 // Map the -180, 180 range of the azimuths to 0, 360, with both points zeroed at North.
600 stMeasurements.dStartRelativeBearing = std::fmod((stMeasurements.dStartRelativeBearing + 360), 360);
601 stMeasurements.dEndRelativeBearing = std::fmod((stMeasurements.dEndRelativeBearing + 180), 360);
602 // Ensure the result angle is positive.
603 if (stMeasurements.dStartRelativeBearing < 0)
604 {
605 // Add 360 degrees.
606 stMeasurements.dStartRelativeBearing += 360;
607 }
608 // Ensure the result angle is positive.
609 if (stMeasurements.dEndRelativeBearing < 0)
610 {
611 // Add 360 degrees.
612 stMeasurements.dEndRelativeBearing += 360;
613 }
614
615 // Return result distance.
616 return stMeasurements;
617 }
GPSCoordinate ConvertUTMToGPS(const UTMCoordinate &stUTMCoord)
Given a UTM coordinate, convert to GPS and create a new GPSCoordinate object.
Definition GeospatialOperations.hpp:347
Here is the call graph for this function:

◆ CalculateGeoMeasurement() [3/3]

GeoMeasurement geoops::CalculateGeoMeasurement ( const geoops::Waypoint stWaypoint1,
const geoops::Waypoint stWaypoint2 
)
inline

The shortest path between two waypoints on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic.

Parameters
stWaypoint1- The first waypoint.
stWaypoint2- The second waypoint.
Returns
GeoMeasurement - Struct containing the distance in meters and arc length degrees, plus the bearing relative to the first point and second point.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-05-06
630 {
631 // Create instance variables.
632 GeoMeasurement stMeasurements;
633
634 // Construct a geodesic with earth characteristics. (Radius and flattening)
635 // The WGS84 standard is widely used and aligns with Google Maps.
636 GeographicLib::Geodesic geGeodesic = GeographicLib::Geodesic::WGS84();
637
638 // Solve the inverse geodesic.
639 stMeasurements.dArcLengthDegrees = geGeodesic.Inverse(stWaypoint1.GetGPSCoordinate().dLatitude,
640 stWaypoint1.GetGPSCoordinate().dLongitude,
641 stWaypoint2.GetGPSCoordinate().dLatitude,
642 stWaypoint2.GetGPSCoordinate().dLongitude,
643 stMeasurements.dDistanceMeters,
644 stMeasurements.dStartRelativeBearing,
645 stMeasurements.dEndRelativeBearing);
646
647 // NOTE: Regarding azi1 vs azi2, azi1 is the direction measured at point 1 (your navigation aid) to point 2. azi2 is the direction measured at point 2 (your
648 // location) away from point 1. (If you want the direction to point 1, add ±180° to azi2.)
649 // Map the -180, 180 range of the azimuths to 0, 360, with both points zeroed at North.
650 stMeasurements.dStartRelativeBearing = std::fmod((stMeasurements.dStartRelativeBearing + 360), 360);
651 stMeasurements.dEndRelativeBearing = std::fmod((stMeasurements.dEndRelativeBearing + 180), 360);
652 // Ensure the result angle is positive.
653 if (stMeasurements.dStartRelativeBearing < 0)
654 {
655 // Add 360 degrees.
656 stMeasurements.dStartRelativeBearing += 360;
657 }
658 // Ensure the result angle is positive.
659 if (stMeasurements.dEndRelativeBearing < 0)
660 {
661 // Add 360 degrees.
662 stMeasurements.dEndRelativeBearing += 360;
663 }
664
665 // Return result distance.
666 return stMeasurements;
667 }
const geoops::GPSCoordinate & GetGPSCoordinate() const
Accessor for the geoops::GPSCoordinate member variable.
Definition GeospatialOperations.hpp:466
Here is the call graph for this function: