sensorAtt.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * @Brief     Storage attitude data and provide setter and getter methods
00003  * @Version   0.3.0
00004  * @Author    Chris Liu
00005  * @Created   2015/11/17
00006  * @Modified  2015/12/25
00007  *****************************************************************************/
00008 
00009 #ifndef _DJI2MAV_SENSORATT_H_
00010 #define _DJI2MAV_SENSORATT_H_
00011 
00012 
00013 #include "math.h"
00014 
00015 namespace dji2mav {
00016 
00017     class SensorAtt {
00018         public:
00019             SensorAtt() {
00020             }
00021 
00022 
00023             ~SensorAtt() {
00024             }
00025 
00026 
00027             inline mavlink_attitude_t* getDataPtr() {
00028                 return &m_data;
00029             }
00030 
00031 
00032             inline void setTimeBootMs(const int32_t* ts) {
00033                 m_data.time_boot_ms = *ts;
00034             }
00035 
00036 
00037             inline void setRoll(const float* roll) {
00038                 m_data.roll = *roll;
00039             }
00040 
00041 
00042             inline void setRoll(const float* q0, const float* q1, 
00043                     const float* q2, const float* q3) {
00044 
00045                 m_data.roll = atan2(  2*( (*q0)*(*q1)+(*q2)*(*q3) ), 
00046                         1-2*( (*q1)*(*q1)+(*q2)*(*q2) )  );
00047 
00048             }
00049 
00050 
00051             inline void setPitch(const float* pitch) {
00052                 m_data.pitch = *pitch;
00053             }
00054 
00055 
00056             inline void setPitch(const float* q0, const float* q1, 
00057                     const float* q2, const float* q3) {
00058 
00059                 m_data.pitch = asin(  2*( (*q0)*(*q2)-(*q3)*(*q1) )  );
00060 
00061             }
00062 
00063 
00064             inline void setYaw(const float* yaw) {
00065                 m_data.yaw = *yaw;
00066             }
00067 
00068 
00069             inline void setYaw(const float* q0, const float* q1, 
00070                     const float* q2, const float* q3) {
00071 
00072                 m_data.yaw = atan2(  2*( (*q0)*(*q3)+(*q1)*(*q2) ), 
00073                         1-2*( (*q2)*(*q2)+(*q3)*(*q3) )  );
00074 
00075             }
00076 
00077 
00078             inline void setRollSpeed(const float* wx) {
00079                 m_data.rollspeed = *wx;
00080             }
00081 
00082 
00083             inline void setPitchSpeed(const float* wy) {
00084                 m_data.pitchspeed = *wy;
00085             }
00086 
00087 
00088             inline void setYawSpeed(const float* wz) {
00089                 m_data.yawspeed = *wz;
00090             }
00091 
00092 
00093         private:
00094             mavlink_attitude_t m_data;
00095 
00096 
00097     };
00098 
00099 } //namespace dji2mav
00100 
00101 
00102 #endif


dji_sdk_dji2mav
Author(s):
autogenerated on Thu Jun 6 2019 17:55:35