5.18.1 基本功能介绍
宏观功能上看,航线任务是飞行控制中一种,为OSDK功能。通过预先上传所有的航点坐标,以及航点动作功能,启动执行后,飞行器将会按照上传的航点及动作顺序执行。
与flight_Control(joystick)区别,从功能的实现和执行上看,航点任务并非SDK的控制功能,SDK提供的是上传航点坐标和动作,以及一系列参数的接口。后续的控制过程由飞控执行,SDK端不需要控制权来执行航线任务。所以航线任务的执行过程不是完全由SDK来控制的,仅可通过API来开始/停止航线任务,暂停/恢复航线任务,设置巡航速度等。
5.18.2 主要代码文件
waypoint_v2
├── test_waypoint_v2.c
└── test_waypoint_v2.h
waypoint_v3/
├── test_waypoint_v3.c
├── test_waypoint_v3.h
├── waypoint_file
│ └── waypoint_v3_test_file.kmz
└── waypoint_file_c
└── waypoint_v3_test_file_kmz.h
PSDK lib头文件:
dji_waypoint_v2.h
dji_waypoint_v2_type.h
dji_waypoint_v3.h
5.18.3 waypoint v2 sample代码实现
sample功能入口函数
T_DjiReturnCode DjiTest_WaypointV2RunSample(void)
初始化
static T_DjiReturnCode DjiTest_WaypointV2Init(void)
{
T_DjiReturnCode returnCode;
osalHandler = DjiPlatform_GetOsalHandler();
if (!osalHandler) return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
returnCode = DjiFcSubscription_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Init waypoint V2 data subscription module error, stat:0x%08llX", returnCode);
return returnCode;
}
returnCode = DjiWaypointV2_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Init waypoint V2 module error, stat:0x%08llX", returnCode);
return returnCode;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
初始化部分包含订阅功能初始化,以及waypoint v2初始化部分,订阅功能是此sample中会用到订阅飞机GPS位置信息,来创建航点坐标等。
注册回调
通过基本功能简介了解到,航线任务是飞控执行的,SDK启动后通常需要监控飞机飞行状态,就可以通过注册回调的方式。当飞机航线任务执行状态发生变化时,就会触发注册的回调函数,而应用端就可以通过回调来监控执行状态。非PSDK上传的航线任务执行状态也可以通过此回调接口来监控。waypoint v2提供两个回调,事件回调和状态回调。实际上都是航线的执行航线任务中的状态,具体抛出状态值不一样。
-
事件回调
/**
* @brief Subscribe to waypointV2 event with a callback function.
* @note There will be data when the event is triggered.
* @param callback: see references of WaypointV2EventCbFunc.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_RegisterMissionEventCallback(WaypointV2EventCbFunc callback);
API说明
-
注册event事件回调
参数
-
callback,应用端注册的event回调函数
回调函数原型及事件参数定义
typedef T_DjiReturnCode (*WaypointV2EventCbFunc)(T_DjiWaypointV2MissionEventPush eventData);
/*! Mission's event push ack data
*/
typedef struct {
/*!
* 0x01: mission interrupt event
* 0x02: mission resume event
* 0x03: mission stop event
* 0x10: mission arrival event
* 0x11: route finished event
* 0x12: avoid obstacle event
* 0x30: action switch event
*/
uint8_t event;
uint32_t FCTimestamp;
U_DjiWaypointV2EventData data;
} T_DjiWaypointV2MissionEventPush;// pack(1)
-
状态回调
/**
* @brief Subscribe to waypointV2 mission state with a callback function.
* @note Data is pushed with a frequency of 10Hz.
* @param callback: see references of WaypointV2StateCbFunc.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_RegisterMissionStateCallback(WaypointV2StateCbFunc callback);
API说明
-
注册航线任务状态回调函数
参数说明
-
callback,应用端注册的状态回调函数
回调函数原型以及状态参数定义
typedef T_DjiReturnCode (*WaypointV2StateCbFunc)(T_DjiWaypointV2MissionStatePush stateData);
/*! Mission's state push data
*/
typedef struct {
uint16_t curWaypointIndex;
/*!
* 0x0:ground station not start.
* 0x1:mission prepared.
* 0x2:enter mission.
* 0x3:execute flying route mission.
* 0x4:pause state.
* 0x5:enter mission after ending pause.
* 0x6:exit mission.
*/
uint8_t state;
uint16_t velocity; //uint:0.01m/s
} T_DjiWaypointV2MissionStatePush;
上传航点
上传航点对于SDK与飞控交互来说,只需要通过一个API上传即可。开发者需要关注如何生成需要上传的航点,以及各个航点信息符合飞控接收的标准。sample是通过一个简单算法生成了一个六边形的航线,并上传简单的到点触发拍照动作(action)。
我们可以先通过查阅PSDK lib API了解航点定义,以及需要上传的航点信息,然后基于需要的信息如何来生成航线及动作,也就是后续开发中需要实现的部分。
/**
* @brief Init waypoint v2 mission settings
* @param info: see reference of T_DjiWayPointV2MissionSettings.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_UploadMission(const T_DjiWayPointV2MissionSettings *info);
API简介
-
上传航线信息给飞控端。
参数说明
-
info,需要上传的航点任务信息。
/**
* @brief Waypoint V2 Mission Initialization settings
* @details This is one of the few structs in the OSDK codebase that
* is used in both a sending and a receiving API.
*/
typedef struct {
/**
* The Mission ID. Use to distinguish different mission
*/
uint32_t missionID;
/**
* Mission execution can be repeated more than once. A value of 0 means the mission
* only executes once, and does not repeat. A value of 1 means the mission will
* execute a total of two times.
*/
uint8_t repeatTimes;
/**
* Action the aircraft will take when the waypoint mission is complete.
*/
E_DJIWaypointV2MissionFinishedAction finishedAction;
/**
* While the aircraft is travelling between waypoints, you can offset its speed by
* using the throttle joystick on the remote controller. `maxFlightSpeed` is this
* offset when the joystick is pushed to maximum deflection. For example, If
* maxFlightSpeed is 10 m/s, then pushing the throttle joystick all the way up
* will add 10 m/s to the aircraft speed, while pushing down will subtract 10 m/s
* from the aircraft speed. If the remote controller stick is not at maximum
* deflection, then the offset speed will be interpolated between [0,
* `maxFlightSpeed`] with a resolution of 1000 steps. If the offset speed is
* negative, then the aircraft will fly backwards to previous waypoints. When it
* reaches the first waypoint, it will then hover in place until a positive speed
* is applied. `maxFlightSpeed` has a range of [2,15] m/s.
* unit: m/s
*/
dji_f32_t maxFlightSpeed;
/**
* The base automatic speed of the aircraft as it moves between waypoints with
* range [-15, 15] m/s. The aircraft's actual speed is a combination of the base
* automatic speed, and the speed control given by the throttle joystick on the
* remote controller. If `autoFlightSpeed` >0: Actual speed is `autoFlightSpeed` +
* Joystick Speed (with combined max of `maxFlightSpeed`) If `autoFlightSpeed` =0:
* Actual speed is controlled only by the remote controller joystick. If
* `autoFlightSpeed` <0 and the aircraft is at the first waypoint, the aircraft
* will hover in place until the speed is made positive by the remote controller
* joystick.
* unit: m/s
*/
dji_f32_t autoFlightSpeed;
/**
* Determines action when connection between the aircraft
* and remote controller is lost.
*
*/
E_DJIWaypointV2MissionActionWhenRcLost actionWhenRcLost;
/**
* Defines how the aircraft will go to the first waypoint from its current
* position. Default is ``DJIWaypointV2MissionV2_DJIWaypointV2MissionGotoWaypointMode_Safely``.
*/
E_DJIWaypointV2MissionGotoFirstWaypointMode gotoFirstWaypointMode;
T_DjiWaypointV2 *mission;
/**
* The Mission waypoint total number could not exceed 65535
*/
uint16_t missTotalLen;
T_DJIWaypointV2ActionList actionList;
} T_DjiWayPointV2MissionSettings;参数说明:
-
missionID用于区分不同的航线任务,一般PSDK端设置同一个值就可以,上传时直接覆盖前一条航线。
-
repeatTimes,指定航线任务执行次数。设定为1时,启动航线任务后,该航线会连续执行两次。设置0,执行一次。
-
finishedAction,航线任务结束时动作,比如悬停,返航,直接降落等。
-
maxFlightSpeed,autoFlightSpeed,这两个参数与joystick控制有关,需要注意,飞控执行航线任务是不建议使用SDK joystick控制功能的,此参数可不用关注。
-
actionWhenRcLost,当RC失联时的动作,此参数暂无效。M300失联动作与控制权归属,以及DJI Assistant2设置有关。详见开发注意事项。
-
gotoFirstWaypointMode,设置到达第一个航点的模式。
-
mission,上传的一系列航点坐标的指针。
-
missTotalLen,上传航点任务的总个数。
-
actionList,航点动作的列表。
其中重点是航点参数:T_DjiWaypointV2,以及航点坐标T_DJIWaypointV2ActionList。
T_DjiWaypointV2定义:
typedef struct {
/*! waypoint position relative to WayPointV2InitSettings's reference point
* unit: m
*/
dji_f64_t longitude;
dji_f64_t latitude;
dji_f32_t relativeHeight; /*! relative to takeoff height*/
/**
* Waypoint flight path mode.
*/
E_DJIWaypointV2FlightPathMode waypointType;
/**
* Represents current aircraft's heading mode on current waypoint.
*/
E_DJIWaypointV2HeadingMode headingMode;
/**
* Represents current waypoint's speed config.
*/
T_DjiWaypointV2Config config;
uint16_t dampingDistance;
/**
* The heading to which the aircraft will rotate by the time it reaches the
* waypoint. The aircraft heading will gradually change between two waypoints with
* different headings if the waypoint mission's `headingMode` is set to
* `DJIWaypointV2_DJIWaypointV2HeadingMode_WaypointCustom`. A heading has a range of
* [-180, 180] degrees, where 0 represents True North.
*/
dji_f32_t heading;
/**
* Determines whether the aircraft will turn clockwise or anticlockwise when
* changing its heading.
*/
E_DJIWaypointV2TurnMode turnMode;
/**
* Property is used when ``DJIWaypointV2_headingMode`` is
* ``DJIWaypointV2_DJIWaypointV2HeadingMode_TowardPointOfInterest``.
* Aircraft will always be heading to point while executing mission. Default is
* "kCLLocationCoordinate2DInvalid".
*/
T_DjiWaypointV2RelativePosition pointOfInterest;
/**
* While the aircraft is travelling between waypoints, you can offset its speed by
* using the throttle joystick on the remote controller. "maxFlightSpeed" is this
* offset when the joystick is pushed to maximum deflection. For example, If
* maxFlightSpeed is 10 m/s, then pushing the throttle joystick all the way up will
* add 10 m/s to the aircraft speed, while pushing down will subtract 10 m/s from
* the aircraft speed. If the remote controller stick is not at maximum deflection,
* then the offset speed will be interpolated between "[0, maxFlightSpeed]"" with a
* resolution of 1000 steps. If the offset speed is negative, then the aircraft
* will fly backwards to previous waypoints. When it reaches the first waypoint, it
* will then hover in place until a positive speed is applied. "maxFlightSpeed" has
* a range of [2,15] m/s.
*/
dji_f32_t maxFlightSpeed;
/**
* The base automatic speed of the aircraft as it moves between waypoints with
* range [-15, 15] m/s. The aircraft's actual speed is a combination of the base
* automatic speed, and the speed control given by the throttle joystick on the
* remote controller. If "autoFlightSpeed >0": Actual speed is "autoFlightSpeed" +
* Joystick Speed (with combined max of "maxFlightSpeed") If "autoFlightSpeed =0":
* Actual speed is controlled only by the remote controller joystick. If
* "autoFlightSpeed <0" and the aircraft is at the first waypoint, the aircraft
* will hover in place until the speed is made positive by the remote controller
* joystick. In flight controller firmware 3.2.10.0 or above, different speeds
* between individual waypoints can also be set in waypoint objects which will
* overwrite "autoFlightSpeed".
*/
dji_f32_t autoFlightSpeed;
} T_DjiWaypointV2;航点参数说明:
-
longitude,latitude,relativeHeight,航点的经纬度坐标,以及高度。其中经纬度坐标是弧度值,高度为相对起飞点的高度。
-
waypointType,过该航点的方式,比如直线经停,弧线不停,平滑曲线不停等。参考结构定义:E_DJIWaypointV2FlightPathMode。其中平滑曲线不停需要对应设置参数:dampingDistance。
-
headingMode,过此航点时机头朝向设定。结构定义:E_DJIWaypointV2HeadingMode
-
config,速度设置。使能巡航速度或最大速度。
-
dampingDistance,单位:0.01m。对应平滑曲线模式下,距离该航点dampingDistance距离(m)时,开始进入曲线。设置范围20(0.2m)~ 65535(655.35m)。
-
heading,设置航点运行中的飞机YAW角度。需要将headingMode设置成DJI_WAYPOINT_V2_HEADING_WAYPOINT_CUSTOM
-
turnMode,设置飞机头转向的方向,顺时针/逆时针。
-
pointOfInterest,这是机头朝向兴趣点,需要将headingMode设置成DJI_WAYPOINT_V2_HEADING_TOWARDS_POINT_OD_INTEREST
-
maxFlightSpeed,autoFlightSpeed与前文中T_DjiWayPointV2MissionSettings意义一样,一般不用。
T_DJIWaypointV2ActionList是action动作列表,用于指定达到航点后的action动作。航点动作抽象为触发器和执行器,触发器用于设定该动作如何、何时触发,比如到点触发、关联触发等。执行器用于指定action的具体动作执行,比如拍照,云台转动等。
/**
* This class represents an action for ``DJIWaypointV2Mission``. It
* determines how
* action is performed when a waypoint mission is executed.
*/
typedef struct {
/**
* The ID of Action.
*/
uint16_t actionId;
/**
* The trigger of action.
*/
T_DJIWaypointV2Trigger trigger;
/**
* The actuator of action.
*/
T_DJIWaypointV2Actuator actuator;
} T_DJIWaypointV2Action;
typedef struct {
//see "E_DJIWaypointV2ActionTriggerType"
uint8_t actionTriggerType;
union {
T_DJIWaypointV2SampleReachPointTriggerParam sampleReachPointTriggerParam;
T_DJIWaypointV2AssociateTriggerParam associateTriggerParam;
T_DJIWaypointV2TrajectoryTriggerParam trajectoryTriggerParam;
T_DJIWaypointV2IntervalTriggerParam intervalTriggerParam;
};
} T_DJIWaypointV2Trigger;
/**
* This class defines an actuator for ``DJIWaypointV2Action``. It determines
* how the
* action is performed when a waypoint mission is executed.
*/
typedef struct {
/**
* The type of Actuator.see "E_DJIWaypointV2ActionActuatorType"
*/
uint8_t actuatorType;
/**
* The index of actuator. It is valid when the diagnostics is related
* to camera or gimbal and the connected product has multiple gimbals and
* cameras.
*/
uint8_t actuatorIndex;
union {
/**
* The camera actuator param, It is valid only when the
* ``DJIWaypointV2Action_DJIWaypointV2Actuator_type``
* is ``DJIWaypointV2MissionV2_DJIWaypointV2ActionActuatorType_Camera``.
*/
T_DJIWaypointV2CameraActuatorParam cameraActuatorParam;
/**
* Parameters for gimbal actuator. It is valid only when the
* ``DJIWaypointV2Action_DJIWaypointV2Actuator_type``
* is ``DJIWaypointV2MissionV2_DJIWaypointV2ActionActuatorType_Gimbal``.
*/
T_DJIWaypointV2GimbalActuatorParam gimbalActuatorParam;
/**
* Parameters for aircraft control actuator. It is valid only when the
* ``DJIWaypointV2Action_DJIWaypointV2Actuator_type``
* is
* ``DJIWaypointV2MissionV2_DJIWaypointV2ActionActuatorType_AircraftControl``.
*/
T_DJIWaypointV2AircraftControlParam aircraftControlActuatorParam;
};
} T_DJIWaypointV2Actuator;说明:
-
actionID,ID不能重复。
触发器
-
actionTriggerType,触发器的类型,见定义:E_DJIWaypointV2ActionTriggerType
-
DJI_WAYPOINT_V2_ACTION_TRIGGER_ACTION_ASSOCIATED,关联触发,将此动作关联到指定的动作上,即此动作的触发时间是与指定的动作执行关联的。
-
DJI_WAYPOINT_V2_ACTION_TRIGGER_TYPE_TRAJECTORY,航线触发,从一个点向下一个点飞行时触发
-
DJI_WAYPOINT_V2_ACTION_TRIGGER_TYPE_INTERVAL,间隔触发,通过参数可以设置时间间隔或距离间隔,周期性的触发动作。
-
DJI_WAYPOINT_V2_ACTION_TRIGGER_TYPE_SAMPLE_REACH_POINT,到点触发,达到航点即触发动作。
-
-
不同的触发器类型,对应不同的触发器参数设置,通过union封装。参考对应的参数定义即可,不再一一列举。
执行器:
-
actuatorType,执行器类型。见定义:E_DJIWaypointV2ActionActuatorType
-
DJI_WAYPOINT_V2_ACTION_ACTUATOR_TYPE_CAMERA,相机执行动作,用于控制拍照等
-
DJI_WAYPOINT_V2_ACTION_ACTUATOR_TYPE_GIMBAL,云台执行动作,用于控制云台旋转动作
-
DJI_WAYPOINT_V2_ACTION_ACTUATOR_TYPE_AIRCRAFT_CONTROL,飞机执行动作,用于控制飞行器的飞行、停止、YAW角控制等。
-
-
与触发器类似,不同的执行器类型对应不同的参数设置,通过union封装,也可参考代码结构定义即可。
-
开始/停止执行航点任务
/**
* @brief Start execute waypoint v2 mission
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_Start(void);
/**
* @brief Stop execute waypoint v2 mission
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_Stop(void);
API说明:
-
启动开始执行航线任务,注意要确保航点任务已经成功上传之后再调用此API执行。
-
停止航线任务,停止的是OSDK对应start的航线任务。若需要重新上传航线任务,需先stop航线任务再upload然后再start。
暂停/恢复航点任务
/**
* @brief Pause execute waypoint v2 mission
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_Pause(void);
/**
* @brief Resume execute waypoint v2 mission
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_Resume(void);
API说明:
-
给飞控发送指令暂停/恢复当前执行的航线任务
-
暂停和恢复是对应的,已经启动的航点任务才可暂停,暂停后的任务才可resume。
设置/获取巡航速度
/**
* @brief Get the global cruise speed setting from flight controller
* @param cruiseSpeed: see references of T_DjiWaypointV2GlobalCruiseSpeed.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_GetGlobalCruiseSpeed(T_DjiWaypointV2GlobalCruiseSpeed *cruiseSpeed);
/**
* @brief Set the global cruise speed setting to flight controller
* @param cruiseSpeed: see references of T_DjiWaypointV2GlobalCruiseSpeed.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV2_SetGlobalCruiseSpeed(T_DjiWaypointV2GlobalCruiseSpeed cruiseSpeed);
API说明:
-
巡航速度是全局航点任务的速度,不能在单个航点坐标中设置。但是可以通过set函数来更改巡航速度。
5.18.4 waypoint v3 sample代码实现
与waypoint v2相比,waypoint v3功能上是基本一致的,但是实现方式变化较大。SDK端将不再需要向上述一样通过代码设置或上传航点,直接上传KMZ文件,SDK端API将会更简洁,上传的KMZ文件也较小,可以上传更多的航点。
sample功能入口函数
T_DjiReturnCode DjiTest_WaypointV3RunSample(void);
初始化
/**
* @brief Initialise waypoint v3 module, and user should call this function.
* before using waypoint v3 features.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV3_Init(void);
API说明
-
初始化waypoint v3模块
注册回调
/**
* @brief Register the mission state callback for waypoint mission.
* @note If you want to monitor the state of waypoint mission, this interface should be called before uploading kmz
* file or executing this mission action.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV3_RegMissionStateCallback(WaypointV3StateCallback callback);
API说明
-
注册应用端回调用于监控航线任务的执行状态,在上传KMZ文件前注册。
参数说明
-
callback,应用端实现的状态监控函数。
函数原型:
/**
* Waypoint v3 current aircraft state.
*/
typedef enum {
DJI_WAYPOINT_V3_STATE_IDLE = 0, /*!< Waypoint v3 aircraft in idle state. */
DJI_WAYPOINT_V3_STATE_PREPARE = 16, /*!< Waypoint v3 aircraft in prepare state. */
DJI_WAYPOINT_V3_STATE_TRANS_MISSION = 32, /*!< Waypoint v3 aircraft in trans mission state. */
DJI_WAYPOINT_V3_STATE_MISSION = 48, /*!< Waypoint v3 aircraft in mission state. */
DJI_WAYPOINT_V3_STATE_BREAK = 64, /*!< Waypoint v3 aircraft in break state. */
DJI_WAYPOINT_V3_STATE_RESUME = 80, /*!< Waypoint v3 aircraft in resume state. */
DJI_WAYPOINT_V3_STATE_RETURN_FIRSTPOINT = 98, /*!< Waypoint v3 aircraft in return first point state. */
} E_DjiWaypointV3State;
/**
* Waypoint v3 mission state.
*/
typedef struct {
E_DjiWaypointV3State state; /*!< Waypoint v3 current aircraft state, #E_DjiWaypointV3State. */
uint32_t wayLineId; /*!< Waypoint v3 current way line id. */
uint16_t currentWaypointIndex; /*!< Waypoint v3 current waypoint index. */
} T_DjiWaypointV3MissionState;
/**
* @brief Prototype of callback function used to receive the waypoint v3 mission state.
* @warning User can not execute blocking style operations or functions in callback function, because that will block
* root thread, causing problems such as slow system response, payload disconnection or infinite loop.
* @param missionState: current waypoint v3 mission state.
* @return Execution result.
*/
typedef T_DjiReturnCode (*WaypointV3StateCallback)(T_DjiWaypointV3MissionState missionState);
上传航点
/**
* @brief Upload kmz file by raw data.
* @note The size of kmz file is very small, you can use this interface to upload quickly.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV3_UploadKmzFile(const uint8_t *data, uint32_t dataLen);
API说明
-
将KMZ文件上传至飞控
参数说明
-
data,解读的KMZ文件数据
-
dataLen,上传的数据长度
执行航线任务
/**
* @brief Execute the mission action.
* @note This action should be called after uploading the kmz file.
* @return Execution result.
*/
T_DjiReturnCode DjiWaypointV3_Action(E_DjiWaypointV3Action action);
API说明
-
执行上传的航线任务。包含开始/停止,暂停/恢复
参数说明
-
action,用于指定执行动作,开始/停止,暂停/恢复。
KMZ文件格式
KML(KMZ)文件可以先参考开发者官网上云API相关部分介绍,飞行器的航线格式都是一致的。
与waypoint v2对比
通过上述waypoint v2和waypoint v3 sample实现对比,PSDK端的实现过程或逻辑基本一样,重要的部分或API为上传航点任务。区别在于waypoint v2需要通过代码对航点信息进行编辑上传。然而waypoint v3将所有的航点信息打包成KMZ文件,然后只需要上传文件即可。且开始/停止,暂停/恢复封装到了一个API中。
思考:
如果M300上使用waypoint v2,能否像waypoint v3一样通过文件的方式设置航点?
A:使用waypoint v2与飞控定义的协议就不是文件方式,v2中没有接口上传给飞控。但是从本质上看其实是一样的,为方便用户端使用,可使用文件或其他可读性更强的方式呈现给终端用户,开发过程中对API做一层封装。也就是用API与飞控交互,用文件方式开放给用户,机载端SDK应用做文件的解析和转换。
5.18.5 开发注意事项
-
航线任务是不需要获取控制权,但是控制权归属会影响航线任务结束动作。对于M300来说,OSDK控制权下的RC失联动作,和RC控制权下,RC失联动作设置是不一样的。使用OSDK控制时,通常脱控飞行,仅使用OSDK航线功能是,先获取控制权。不获取控制权下,如果RC断开,会执行RC的失联动作。
-
航线任务执行过程中,飞行最远距离,低电量返航,以及避障逻辑都是由事先通过遥控器设定、或OSDK启动任务前设定好的逻辑。
-
航点动作个数介绍最大是65535个,但实际上传时个数太多会有导致上传失败,如果确实航点比较多,可以考虑将分段执行航线任务。即执行完一个任务后,再上传一个航线任务继续执行。waypoint v3上传给飞控的文件,可以支持上传更多的航点及其航点信息。
-
航点任务执行过程中不可以使用joystick来控制飞行,若需要使用joystick,要先stop航线,获取控制权后再发送joystick指令。
-
航线任务中有航点动作且航点中有多个动作时,不要设置成平滑曲线过航点,这样会导致动作乱序的现象,建议设置成到点悬停,然后再执行动作。
-
评论
0 条评论
请登录写评论。