1#ifndef JAIABOT_UTILS_MISSION_MANAGER_UTILS_H
2#define JAIABOT_UTILS_MISSION_MANAGER_UTILS_H
5#include <goby/util/geodesy.h>
22 const goby::util::UTMGeodesy& geodesy,
24 double distance_meters,
25 double heading_degrees)
31 double math_angle = 90.0 - heading_degrees;
32 if (math_angle < 0) math_angle += 360.0;
33 double angle_radians = math_angle * M_PI / 180.0;
36 double dx = distance_meters * std::cos(angle_radians);
37 double dy = distance_meters * std::sin(angle_radians);
40 auto end_xy = goby::util::UTMGeodesy::XYPoint{
41 start_xy.x + dx * boost::units::si::meters,
42 start_xy.y + dy * boost::units::si::meters
46 auto end_latlon = geodesy.convert(end_xy);
59 double delta_x = end_x - start_x;
60 double delta_y = end_y - start_y;
62 double radius = std::sqrt(delta_x * delta_x + delta_y * delta_y);
67 double math_angle = std::atan2(delta_y, delta_x) * 180.0 / M_PI;
68 double compass_heading = 90.0 - math_angle;
69 if (compass_heading < 0)
71 compass_heading += 360.0;
75 polar_coordinate.
radius = radius;
76 polar_coordinate.
heading = compass_heading;
78 return polar_coordinate;
84 const goby::util::UTMGeodesy& geodesy,
85 double duration_to_acquire_gps,
90 double gps_acquire_distance = duration_to_acquire_gps * drift_speed;
93 double opposite_heading = std::fmod(drift_heading + 180.0, 360.0);
100 float lat2,
float lon2)
104 float dLat = (lat2 - lat1) *
106 float dLon = (lon2 - lon1) *
110 float lat1_rad = (lat1) * M_PI / 180.0;
111 float lat2_rad = (lat2) * M_PI / 180.0;
114 float a = pow(sin(dLat / 2), 2) +
115 pow(sin(dLon / 2), 2) *
116 cos(lat1_rad) * cos(lat2_rad);
118 float c = 2 * asin(sqrt(a));
120 return rad * c * 1000.0;
124 auto dx = ex - sx, dy = ey - sy;
129 double math_angle_rad = std::atan2(dy, dx);
130 double heading_rad = M_PI / 2.0 - math_angle_rad;
133 heading_rad = heading_rad + (2.0 * M_PI);
136 return heading_rad * 180.0 / M_PI;
Quantity lon_with_units() const
void set_lat_with_units(Quantity value_w_units)
void set_lon_with_units(Quantity value_w_units)
Quantity lat_with_units() const
PolarCoordinate convert_cartesian_to_polar(double start_x, double start_y, double end_x, double end_y)
float calculateHeading(double sx, double sy, double ex, double ey)
float haversine(float lat1, float lon1, float lat2, float lon2)
jaiabot::protobuf::GeographicCoordinate find_dive_end_location(const goby::util::UTMGeodesy &geodesy, double duration_to_acquire_gps, const jaiabot::protobuf::GeographicCoordinate &drift_start_location, double drift_speed, double drift_heading)
jaiabot::protobuf::GeographicCoordinate calculate_position_from_offset(const goby::util::UTMGeodesy &geodesy, const jaiabot::protobuf::GeographicCoordinate &start_location, double distance_meters, double heading_degrees)