123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #pragma once
- #include <AP_Math/AP_Math.h>
- class AP_Terrain;
- #define LOCATION_ALT_MAX_M 83000
- class Location
- {
- public:
- uint8_t relative_alt : 1;
- uint8_t loiter_ccw : 1;
- uint8_t terrain_alt : 1;
- uint8_t origin_alt : 1;
- uint8_t loiter_xtrack : 1;
-
- int32_t alt;
- int32_t lat;
- int32_t lng;
-
- enum class AltFrame {
- ABSOLUTE = 0,
- ABOVE_HOME = 1,
- ABOVE_ORIGIN = 2,
- ABOVE_TERRAIN = 3
- };
-
- Location();
- Location(int32_t latitude, int32_t longitude, int32_t alt_in_cm, AltFrame frame);
- Location(const Vector3f &ekf_offset_neu);
- static void set_terrain(AP_Terrain* terrain) { _terrain = terrain; }
-
- void set_alt_cm(int32_t alt_cm, AltFrame frame);
-
-
-
- bool get_alt_cm(AltFrame desired_frame, int32_t &ret_alt_cm) const WARN_IF_UNUSED;
-
- AltFrame get_alt_frame() const;
-
-
-
- bool change_alt_frame(AltFrame desired_frame);
-
-
-
-
- bool get_vector_xy_from_origin_NE(Vector2f &vec_ne) const WARN_IF_UNUSED;
- bool get_vector_from_origin_NEU(Vector3f &vec_neu) const WARN_IF_UNUSED;
-
- float get_distance(const struct Location &loc2) const;
-
- Vector3f get_distance_NED(const Location &loc2) const;
-
- Vector2f get_distance_NE(const Location &loc2) const;
-
- void offset(float ofs_north, float ofs_east);
-
- void offset_bearing(float bearing, float distance);
-
-
-
-
- float longitude_scale() const;
- bool is_zero(void) const WARN_IF_UNUSED;
- void zero(void);
-
- int32_t get_bearing_to(const struct Location &loc2) const;
-
- bool same_latlon_as(const Location &loc2) const;
-
- bool sanitize(const struct Location &defaultLoc);
-
- bool check_latlng() const;
-
-
-
-
-
- bool past_interval_finish_line(const Location &point1, const Location &point2) const;
-
- float line_path_proportion(const Location &point1, const Location &point2) const;
- bool initialised() const { return (lat !=0 || lng != 0); }
- private:
- static AP_Terrain *_terrain;
-
-
- static constexpr float LOCATION_SCALING_FACTOR = 0.011131884502145034f;
-
- static constexpr float LOCATION_SCALING_FACTOR_INV = 89.83204953368922f;
- };
|