云台功能
PSDK 云台相关功能的头文件为uav_gimbal.h
,本文档描述了uav_gimbal.h
文件中结构体和函数原型的关键信息和使用方法。
宏定义、枚举与结构体
E_UavGimbalCalibrationStage
云台校准
typedef enum {
UAV_GIMBAL_CALIBRATION_STAGE_COMPLETE = 0, /*!< Calibration have been completed and the result is successful. */
UAV_GIMBAL_CALIBRATION_STAGE_PROCRESSING = 1, /*!< Gimbal is calibrating. */
UAV_GIMBAL_CALIBRATION_STAGE_FAILED = 3, /*!< Calibration have been completed and the result is failure. */
} E_UavGimbalCalibrationStage;
E_UavGimbalAxis
云台轴
typedef enum {
UAV_GIMBAL_AXIS_PITCH = 0, /*!< Pitch axis. */
UAV_GIMBAL_AXIS_ROLL = 1, /*!< Roll axis. */
UAV_GIMBAL_AXIS_YAW = 2, /*!< Yaw axis. */
} E_UavGimbalAxis;
E_UAVGimbalResetMode
云台复位模式
typedef enum {
/*! Only reset yaw axis of gimbal. Reset angle of yaw axis to the sum of yaw axis angle of aircraft and fine tune angle
* of yaw axis of gimbal. */
UAV_GIMBAL_RESET_MODE_YAW = 1,
/*! Reset yaw axis and pitch axis of gimbal. Reset angle of yaw axis to sum of yaw axis angle of aircraft and fine tune
* angle of yaw axis of gimbal, and reset pitch axis angle to the fine tune angle. */
UAV_GIMBAL_RESET_MODE_PITCH_AND_YAW = 3,
/*! Reset yaw axis and pitch axis of gimbal. Reset angle of yaw axis to sum of yaw axis angle of aircraft and fine tune
* angle of yaw axis of gimbal, and reset pitch axis angle to sum of -90 degree and fine tune angle if gimbal
* downward, sum of 90 degree and fine tune angle if upward. */
UAV_GIMBAL_RESET_MODE_PITCH_DOWNWARD_UPWARD_AND_YAW = 11,
/*! Reset pitch axis of gimbal. Reset pitch axis angle to sum of -90 degree and fine tune angle if gimbal downward,
* sum of 90 degree and fine tune angle if upward.
* Note: only support for dragonfish series
*/
UAV_GIMBAL_RESET_MODE_PITCH_DOWNWARD_UPWARD = 12,
} E_UAVGimbalResetMode;
T_UavGimbalControllerSmoothFactor
云台平滑系数
typedef struct {
uint8_t pitch; /*!< Smooth factor of pitch axis, range from 0 to 30. */
uint8_t yaw; /*!< Smooth factor of yaw axis, range from 0 to 30. */
} T_UavGimbalControllerSmoothFactor;
T_UavGimbalControllerMaxSpeedPercentage
云台最大速度百分比
typedef struct {
uint8_t pitch; /*!< Max speed percentage of pitch axis, range from 1 to 100. */
uint8_t yaw; /*!< Max speed percentage of yaw axis, range from 1 to 100. */
} T_UavGimbalControllerMaxSpeedPercentage;
T_UavGimbalSystemState
云台的状态
typedef struct {
bool resettingFlag; /*!< Specifies whether gimbal is resetting now or not. */
bool mountedUpward; /*!< Specifies whether gimbal is upward or not. */
bool blockingFlag; /*!< Specifies whether gimbal is stuck or not. */
bool pitchRangeExtensionEnabledFlag; /*!< Specifies whether extended angle range of gimbal pitch axis is enabled or not. */
E_UAVGimbalMode gimbalMode; /*!< Gimbal mode. */
T_UAVAttitude3d fineTuneAngle; /*!< Fine tune angles, unit: 0.1 degree. */
T_UavGimbalControllerSmoothFactor smoothFactor; /*!< Smooth factor of gimbal controller. */
T_UavGimbalControllerMaxSpeedPercentage maxSpeedPercentage; /*!< Max speed percentage of gimbal controller. */
} T_UavGimbalSystemState;
T_UavGimbalReachLimitFlag
到达限位标志
typedef struct {
bool pitch; /*!< Specifies whether gimbal has reached angle limit of pitch axis, if true, reached the limit. */
bool roll; /*!< Specifies whether gimbal has reached angle limit of roll axis, if true, reached the limit. */
bool yaw; /*!< Specifies whether gimbal has reached angle limit of yaw axis, if true, reached the limit. */
} T_UavGimbalReachLimitFlag;
T_UavGimbalAttitudeInformation
云台角度
typedef struct {
T_UAVAttitude3d attitude; /*!< Gimbal attitude in the ground coordinate, unit: 0.1 degree. */
T_UavGimbalReachLimitFlag reachLimitFlag; /*!< Reach limit flag, being set when the joint angles of gimbal reach limits. */
} T_UavGimbalAttitudeInformation;
T_UavGimbalCalibrationState
云台校准状态
typedef struct {
bool calibratingFlag; /*!< Specifies whether gimbal is calibrating now or not. */
bool lastCalibrationResult; /*!< Result of the last calibration, and true specifies success. */
uint8_t currentCalibrationProgress; /*!< Progress percentage of current calibration. If gimbal is calibrating now and fill in real progress percentage, if not, fill in zero. The item ranges from 0 to 100. */
E_UavGimbalCalibrationStage currentCalibrationStage; /*!< Current calibration stage and result. If gimbal is calibrating now and fill in ::UAV_GIMBAL_CALIBRATION_STAGE_PROCRESSING, if not, fill in result of the last calibration. */
} T_UavGimbalCalibrationState;
T_UavGimbalRotationProperty
云台转动命令的属性
typedef struct {
struct {
bool pitch; /*!< Specifies whether ignore rotation command of pitch axis, and true specifies ignoring. */
bool roll; /*!< Specifies whether ignore rotation command of roll axis, and true specifies ignoring. */
bool yaw; /*!< Specifies whether ignore rotation command of yaw axis, and true specifies ignoring. */
} rotationValueInvalidFlag; /*!< Specifies whether ignore rotation command of some axis, including pitch, roll and yaw. */
union {
struct {
uint16_t actionTime; /*!< Action time during which gimbal move to target angles, unit: 0.01s. */
} relativeAngleRotation; /*!< Property of relative angle rotation command. */
struct {
uint16_t actionTime; /*!< Action time during which gimbal move to target angles, unit: 0.01s. */
/*! Joint angle valid flag, specifying whether
* T_UavGimbalRotationProperty::absoluteAngleRotation::jointAngle is valid when absolute angle control. */
bool jointAngleValid;
/*! Joint angles of gimbal, unit: 0.1 degree. If
* T_UavGimbalRotationProperty::absoluteAngleRotation::jointAngleValid is false, specifying here joint
* angles are invalid, and please ignore the joint angles. If joint angles are valid, users should ensure
* that target joint angles of gimbal is approximately the same as the specified value. */
T_UAVAttitude3d jointAngle;
} absoluteAngleRotation; /*!< Property of absolute angle rotation command. */
};
} T_UavGimbalRotationProperty;
T_UavGimbalCommonHandler
云台控制,请根据本结构体中的函数构造云台控制相关功能的回调函数,其中包括:
- 获取云台当前的状态
- 获取云台当前的角度
- 获取云台校准状态
- 获取云台转动速度
- 获取云台关节角的角度
- 转动云台
- 控制云台开始校准
- 设置云台的平滑度
- 开启或关闭俯仰轴欧拉角扩展角
- 设置云台最大速度百分比
- 恢复云台信息
- 设置云台模式
- 重置云台参数
- 云台角度微调
说明: 为防止该函数阻塞PSDK 的主线程,导致出现程序响应缓慢、相机类负载设备断连及死循环等问题,请勿以阻塞的方式在回调函数中执行该函数。
typedef struct {
/*!
* @brief Prototype of callback function used to report system state of gimbal.
* @param systemState: pointer to memory space used to store gimbal system state.
* @return Execution result.
*/
T_UAVReturnCode (*GetSystemState)(T_UavGimbalSystemState *systemState);
/*!
* @brief Prototype of callback function used to report attitude information of gimbal.
* @param attitudeInformation: pointer to memory space used to store gimbal attitude information.
* @return Execution result.
*/
T_UAVReturnCode (*GetAttitudeInformation)(T_UavGimbalAttitudeInformation *attitudeInformation);
/*!
* @brief Prototype of callback function used to report calibration state of gimbal.
* @param calibrationState: pointer to memory space used to store gimbal calibration state.
* @return Execution result.
*/
T_UAVReturnCode (*GetCalibrationState)(T_UavGimbalCalibrationState *calibrationState);
/*!
* @brief Prototype of callback function used to rotate gimbal. Rotation callback function will be called when
* other modules control gimbal.
* @warning User should control execution time of the callback function to be short, because this callback function
* may be called at very high frequency in some scenarios, just like 200Hz.
* @param rotationMode: mode of rotation command.
* @param rotationProperty: property of rotation command.
* @param rotationValue: value of rotation command, unit: 0.1 degree (if rotation mode is
* ::UAV_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE or ::UAV_GIMBAL_ROTATION_MODE_ABSOLUTE_ANGLE), 0.1 degree/s
* (if rotation mode is ::UAV_GIMBAL_ROTATION_MODE_SPEED).
* @return Execution result.
*/
T_UAVReturnCode (*Rotate)(E_UAVGimbalRotationMode rotationMode, T_UavGimbalRotationProperty rotationProperty,
T_UAVAttitude3d rotationValue);
/*!
* @brief Prototype of callback function used to start calibrating gimbal.
* @note Maximum allowable time of gimbal calibration is 120s.
* @return Execution result.
*/
T_UAVReturnCode (*StartCalibrate)(void);
/**
* @brief Set smooth factor for gimbal controller, using to smooth control.
* @param smoothingFactor: smooth factor. The larger the value, the smaller the acceleration of gimbal. Recommended
* calculation formula is "acc = 10000 * (0.8 ^ (1 + x)) deg/s^2", x is smooth factor. Range from 0 to 30.
* @param axis: axis to be set.
* @return Execution result.
*/
T_UAVReturnCode (*SetControllerSmoothFactor)(uint8_t smoothingFactor, E_UavGimbalAxis axis);
/*!
* @brief Prototype of callback function used to enable or disable extended pitch axis angle range.
* @details Switching the gimbal limit euler angle of pitch axis to the extended limit angle or the default limit
* angle.
* @param enabledFlag: flag specified whether enable or disable extended pitch axis angle range.
* @return Execution result.
*/
T_UAVReturnCode (*SetPitchRangeExtensionEnabled)(bool enabledFlag);
/**
* @brief Set max speed percentage for gimbal controller.
* @param maxSpeedPercentage: max speed value. Recommended calculation formula is "spd = default_max_spd * x / 100",
* x is default max speed value. Range from 1 to 100.
* @param axis: axis to be set.
* @return Execution result.
*/
T_UAVReturnCode (*SetControllerMaxSpeedPercentage)(uint8_t maxSpeedPercentage, E_UavGimbalAxis axis);
/**
* @brief Restore factory settings of gimbal, including fine tune angle, pitch angle extension enable flag and max
* speed etc.
* @return Execution result.
*/
T_UAVReturnCode (*RestoreFactorySettings)(void);
/*!
* @brief Prototype of callback function used to set gimbal work mode.
* @param mode: gimbal work mode.
* @return Execution result.
*/
T_UAVReturnCode (*SetMode)(E_UAVGimbalMode mode);
/*!
* @brief Prototype of callback function used to reset gimbal.
* @note Reset command will interrupt rotation process.
* @param mode: Reset mode.
* @return Execution result.
*/
T_UAVReturnCode (*Reset)(E_UAVGimbalResetMode mode);
/*!
* @brief Prototype of callback function used to fine tune angle of gimbal.
* @param fineTuneAngle: fine tune angle, unit: 0.1 degree. Angle value of greater than 0 specifies rotation
* towards the positive direction of body coordinate.
* @return Execution result.
*/
T_UAVReturnCode (*FineTuneAngle)(T_UAVAttitude3d fineTuneAngle);
/**
* @brief Prototype of callback function used to report rotation speed of gimbal.
* @note The callback function will be called at 50 Hz. Developers should ensure that, the average rotation speed
* of gimbal within 20 ms after the callback function is called is approximately equal to the reported rotation
* speed.
* @param rotationSpeed: pointer to memory space used to store rotation speed, in body coordinate, unit:
* 0.1 degree/s.
* @return Execution result.
*/
T_UAVReturnCode (*GetRotationSpeed)(T_UAVAttitude3d *rotationSpeed);
/**
* @brief Prototype of callback function used to report joint angle of gimbal.
* @param jointAngle: pointer to memory space used to store joint angles, unit: 0.1 degree.
* @return Execution result.
*/
T_UAVReturnCode (*GetJointAngle)(T_UAVAttitude3d *jointAngle);
} T_UavGimbalCommonHandler;
函数原型
UavGimbal_Init
功能:初始化云台模块
在使用云台控制功能前,请先调用本接口初始化云台模块。
T_UAVReturnCode UavGimbal_Init(void);
UavGimbal_DeInit
功能:反初始化云台模块
T_UAVReturnCode UavGimbal_DeInit(void);
UavGimbal_RegCommonHandler
功能:注册云台控制功能
T_UAVReturnCode UavGimbal_RegCommonHandler(const T_UavGimbalCommonHandler *commonHandler);