函数贴出来(OSDK4.0.1版本,貌似因为OSDK4.x仅支持M210 v2和M300机型,这些API统一修改了支持的平台,3.x的版本也是支持该API的):
/*! @Brief Control the position and yaw angle of the vehicle.
* The reference frame is the DJI::OSDK::Control::HORIZONTAL_GROUND (NEU).
*
* @platforms M210V2, M300
* @param x position set-point in x axis of ground frame (m)
* @param y position set-point in y axis of ground frame (m)
* @param z position set-point in z axis of ground frame (m), input limit see
* DJI::OSDK::Control::VERTICAL_POSITION
* @param yaw yaw set-point (deg)
*
*/
void positionAndYawCtrl(float32_t x, float32_t y, float32_t z, float32_t yaw);
函数实现:
void Control::positionAndYawCtrl(float32_t x, float32_t y, float32_t z,
float32_t yaw)
{
//! @Note 145 is the flag value of this mode
uint8_t ctrl_flag = (VERTICAL_POSITION | HORIZONTAL_POSITION | YAW_ANGLE |
HORIZONTAL_GROUND | STABLE_ENABLE);
CtrlData data(ctrl_flag, x, y, z, yaw);
结合参数说明,这个代码注解还是比较详细的了。要还是看不懂,那就上飞机直接修改参数飞一飞。
/*! @brief Control the velocity and yaw rate of the vehicle.
* The reference frame is the DJI::OSDK::Control::HORIZONTAL_GROUND (NEU).
*
* @platforms M210V2, M300
* @param Vx velocity set-point in x axis of ground frame (m/s), input limit
* see DJI::OSDK::Control::HORIZONTAL_VELOCITY
* @param Vy velocity set-point in y axis of ground frame (m/s), input limit
* see DJI::OSDK::Control::HORIZONTAL_VELOCITY
* @param Vz velocity set-point in z axis of ground frame (m/s), input limit
* see DJI::OSDK::Control::VERTICAL_VELOCITY
* @param yawRate yawRate set-point (deg/s)
*/
void velocityAndYawRateCtrl(float32_t Vx, float32_t Vy, float32_t Vz, float32_t yawRate);
/*! @brief Control the attitude and vertical position of the vehicle
*
* @platforms M210V2, M300
* @param roll attitude set-point in x axis of body frame (FRU) (deg),
* input limit see DJI::OSDK::Control::HORIZONTAL_ANGLE
* @param pitch attitude set-point in y axis of body frame (FRU) (deg),
* input limit see DJI::OSDK::Control::HORIZONTAL_ANGLE
* @param z z position set-point in z axis of ground frame (NED) (m),
* input limit see DJI::OSDK::Control::VERTICAL_POSITION
* @param yaw attitude set-point in z axis of ground frame (NED) (deg)
*/
void attitudeAndVertPosCtrl(float32_t roll, float32_t pitch, float32_t yaw, float32_t z);
/*! @brief Control the attitude rate and vertical position of the vehicle
*
* @platforms M210V2, M300
* @param rollRate attitude rate set-point in x axis of body frame (FRU)
* (deg/s)
* @param pitchRate attitude rate set-point in y axis of body frame (FRU)
* (deg/s)
* @param yawRate attitude rate set-point in z axis of body frame (FRU)
* (deg/s), input limit see DJI::OSDK::Control::YAW_RATE
* @param z z position set-point in z axis of ground frame (NED)
* (m), input limit see DJI::OSDK::Control::VERTICAL_POSITION
*/
void angularRateAndVertPosCtrl(float32_t rollRate, float32_t pitchRate, float32_t yawRate, float32_t z);