DJI Onboard SDK  4.0
flight_sample.hpp
Go to the documentation of this file.
1 
32 #ifndef DJIOSDK_FLIGHT_SAMPLE_HPP
33 #define DJIOSDK_FLIGHT_SAMPLE_HPP
34 
35 #include <dji_linux_helpers.hpp>
36 #include <dji_vehicle.hpp>
37 
38 class FlightSample {
39  public:
40  FlightSample(Vehicle *vehicle);
41  ~FlightSample();
42  typedef struct Telemetry::Vector3f Vector3f;
43 
54  bool setUpSubscription(int pkgIndex, int freq,
55  Telemetry::TopicName topicList[], uint8_t topicSize,
56  int timeout = 1);
57 
65  bool teardownSubscription( const int pkgIndex,
66  int timeout = 1);
67 
76  bool getHomeLocation(Telemetry::HomeLocationSetStatus &homeLocationSetStatus,
77  Telemetry::HomeLocationData &homeLocationInfo,
78  int responseTimeout);
79 
86  bool checkActionStarted(uint8_t mode);
87 
95  ErrorCode::ErrorCodeType setGoHomeAltitude(
96  FlightController::GoHomeHeight altitude, int timeout = 1);
97 
104  ErrorCode::ErrorCodeType setNewHomeLocation(int timeout = 1);
105 
112  bool goHomeAndConfirmLanding(int timeout = 1);
113 
122  bool monitoredTakeoff(int timeout = 1);
123 
124  bool moveByPositionOffset(const Vector3f &offsetDesired,
125  float yawDesiredInDeg,
126  float posThresholdInM = 0.5,
127  float yawThresholdInDeg = 1.0);
128 
129  private:
130  Vehicle *vehicle;
131  template <typename Type>
132  static int signOfData(Type type);
133  static float32_t vectorNorm(Vector3f v);
134  static Vector3f vector3FSub(const Vector3f &vectorA, const Vector3f &vectorB);
135  static Vector3f localOffsetFromGpsOffset(const Telemetry::GPSFused &target,
136  const Telemetry::GPSFused &origin);
137  static Vector3f quaternionToEulerAngle(const Telemetry::Quaternion &quat);
138  static void horizCommandLimit(float speedFactor, float& commandX, float& commandY);
139 
140  bool motorStartedCheck();
141  bool takeOffInAirCheck();
142  bool takeoffFinishedCheck();
143 };
144 #endif // DJIOSDK_FLIGHT_SAMPLE_HPP
FlightAssistant::GoHomeAltitude GoHomeHeight
Definition: dji_flight_controller.hpp:53
struct for TOPIC_QUATERNION
Definition: dji_telemetry.hpp:188
int64_t ErrorCodeType
Unified error type.
Definition: dji_error.hpp:144
struct for TOPIC_GPS_FUSED
Definition: dji_telemetry.hpp:287
TopicName
enum TopicName is the interface for user to create packages and access data It is also used as index ...
Definition: dji_telemetry.hpp:59
struct for multiple Topics
Definition: dji_telemetry.hpp:199
struct DJI::OSDK::Telemetry::Vector3f Vector3f
struct for multiple Topics
Vehicle API for DJI onboardSDK library.