关键词:OSDK waypoint v2,悬停actions实现
可以按照以下顺序设置航点动作,实现悬停:
DJIWaypointV2AircraftControlFlyingParam停止飞行
DJIWaypointV2IntervalTriggerParam 间隔时间
DJIWaypointV2AircraftControlFlyingParam开始飞行
其中DJIWaypointV2IntervalTriggerParam 间隔时间参数单位:0.1s,可设置最大值为uint8:255
设置悬停5s,参考代码:
associateTriggerParam.waitingTime = 50; //5s
(以下代码节选自开发者自己实现代码,非原创。此部分代码实现简洁直观易懂,仅供参考)
std::vector<DJIWaypointV2Action> WaypointV2MissionSample::generateWaypointActions(uint16_t actionNum)
{
std::vector<DJIWaypointV2Action> actionVector;
#if 0
for(uint16_t i = 0; i < actionNum; i++)
{
DJIWaypointV2SampleReachPointTriggerParam sampleReachPointTriggerParam;
sampleReachPointTriggerParam.waypointIndex = i;
sampleReachPointTriggerParam.terminateNum = 0;
auto *trigger = new DJIWaypointV2Trigger(DJIWaypointV2ActionTriggerTypeSampleReachPoint,&sampleReachPointTriggerParam);
auto *cameraActuatorParam = new DJIWaypointV2CameraActuatorParam(DJIWaypointV2ActionActuatorCameraOperationTypeTakePhoto, nullptr);
auto *actuator = new DJIWaypointV2Actuator(DJIWaypointV2ActionActuatorTypeCamera, 0, cameraActuatorParam);
auto *action = new DJIWaypointV2Action(i, *trigger,*actuator);
actionVector.push_back(*action);
}
#endif
// pause when reach waypoint[1]
sampleReachPointTriggerParam.waypointIndex = 1;
sampleReachPointTriggerParam.terminateNum = 0;
trigger = new DJIWaypointV2Trigger(DJIWaypointV2ActionTriggerTypeSampleReachPoint,&sampleReachPointTriggerParam);
flyControlParam.isStartFlying = 0;
aircraftActuatorParam = new DJIWaypointV2AircraftControlParam(DJIWaypointV2ActionActuatorAircraftControlOperationTypeFlyingControl, &flyControlParam);
actuator = new DJIWaypointV2Actuator(DJIWaypointV2ActionActuatorTypeAircraftControl, 0, aircraftActuatorParam);
s = new DJIWaypointV2Action(action_id, *trigger,*actuator);
actionVector.push_back(*s);
action_id++;
delete trigger;
delete aircraftActuatorParam;
delete actuator;
delete s;
// resume after actions at waypoint[1]
associateTriggerParam.actionAssociatedType = DJIWaypointV2TriggerAssociatedTimingTypeAfterFinised;
associateTriggerParam.waitingTime = 50; //5s
associateTriggerParam.actionIdAssociated = action_id - 1;
trigger = new DJIWaypointV2Trigger(DJIWaypointV2ActionTriggerTypeActionAssociated,&associateTriggerParam);
flyControlParam.isStartFlying = 1;
aircraftActuatorParam = new DJIWaypointV2AircraftControlParam(DJIWaypointV2ActionActuatorAircraftControlOperationTypeFlyingControl, &flyControlParam);
actuator = new DJIWaypointV2Actuator(DJIWaypointV2ActionActuatorTypeAircraftControl, 0, aircraftActuatorParam);
s = new DJIWaypointV2Action(action_id, *trigger,*actuator);
actionVector.push_back(*s);
action_id++;
delete trigger;
delete aircraftActuatorParam;
delete actuator;
delete s;
return actionVector;
}
评论
0 条评论
请登录写评论。