在 DJI Windows SDK 中初始化和执行 WayPoint 任务的阶段是什么?
What are the stages for initialising and executing a WayPoint Mission in DJI Windows SDK?
我正在使用以下代码尝试初始化 Waypoint Mission 并将其加载到飞机(DJI Mavic Air)。
我首先检查航点处理程序的状态,然后初始化一个航点,将其添加到列表中,然后将列表包含在初始化的航点任务中。然后将航点任务加载到飞行器的方法是运行,然后检查状态。调试的输出如下所示:
航点状态=READY_TO_UPLOAD;
新航点位置 - 55.555549621582,0.555555522441864
加载任务return值-INVALID_REQUEST_IN_CURRENT_STATE
航点状态=READY_TO_UPLOAD
READY_TO_UPLOAD的状态,按照WindowsSDK的说明说明是适合上传航点任务的状态,但是很明显上传失败,状态没有变化。
为了使航路点任务成功加载以便飞机可以 运行 需要更改什么?
//Check the initial state of the waypoint handler
var currentState = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetCurrentState();
Debug.WriteLine("Waypoint state = {0}", currentState);
//Initialise new location coordinate
randomLocation.X = 55.55555;
randomLocation.Y = 0.55555555;
Debug.WriteLine("New waypoint location - {0},{1}", randomLocation.X, randomLocation.Y);
LocationCoordinate2D waypointLocation = new LocationCoordinate2D { latitude = randomLocation.X, longitude = randomLocation.Y };
// Create a waypoint instance and add to waypoint list
Waypoint waypoint = new Waypoint { location = waypointLocation };
waypointList.Add(waypoint);
//Create new waypoint mission instance and load in the waypoint list
WaypointMission waypointMission = new WaypointMission
{
waypointCount = 1,
autoFlightSpeed = 2.5,
finishedAction = WaypointMissionFinishedAction.NO_ACTION,
headingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING,
flightPathMode = WaypointMissionFlightPathMode.CURVED,
repeatTimes = 0,
waypoints = waypointList,
missionID = 1
};
//load the waypoint mission to the aircraft and check the current state
var load_retval = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).LoadMission(waypointMission); ;
Debug.WriteLine("Load mission return value - {0}", load_retval);
currentState = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetCurrentState();
Debug.WriteLine("Waypoint state = {0}", currentState);
经过长时间的试错,我弄清楚了开始航点任务所需的步骤:
将SDK设置为地面站模式
首先你要将SDK设置为地面站模式,方法如下:
DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).SetGroundStationModeEnabledAsync(new BoolMsg() { value = true })
正在加载任务
其次,您必须使用以下方法将航点任务加载到 SDK:
DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).
LoadMission(waypointMission)
其中 waypointMission
可能是您问题中的航路点任务。这个航路点任务必须遵循一些限制。例如总距离不能太长(不确定确切的数字是多少)。如果任务有问题,此方法将 return 一个 SDKError。
正在上传航点任务到无人机
任务加载到SDK后还需要上传到无人机。这是通过以下方法完成的:
DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).
上传任务()
(可选)说明模拟器
此时如果您不想让无人机真正起飞,您可以启动模拟模式。这可以通过以下代码完成:
FlightControllerHandler _flightControllerHandler = DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0);
var simSettings = new SimulatorInitializationSettings()
{
latitude = 0,
longitude = 0,
satelliteCount = 12
};
await _flightControllerHandler.StartSimulatorAsync(simSettings);
重要的是 satelliteCount
高于 10。否则 SDK 将给出 GPS 信号强度不够好的错误。
开始任务
最后你可以开始航点任务如下
DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).StartMission()
其他注意事项:
- 这些电话中的大多数是
async
,值得期待。
即使您等待调用,我注意到上传任务不会在方法完成时完成。因此,如果您在 UploadMission()
之后立即调用 StartMission()
,这可能会导致 INVALID_REQUEST_IN_CURRENT_STATE
我通过使用单独的按钮来加载和启动来解决这个问题 mission.This 我可以在开始任务之前等待任务上传。
以上所有方法return一个SDKError
类型。如果一切顺利,这将是一个 NO_ERROR
检查每次调用是否都是这种情况很重要。
我正在使用以下代码尝试初始化 Waypoint Mission 并将其加载到飞机(DJI Mavic Air)。
我首先检查航点处理程序的状态,然后初始化一个航点,将其添加到列表中,然后将列表包含在初始化的航点任务中。然后将航点任务加载到飞行器的方法是运行,然后检查状态。调试的输出如下所示:
航点状态=READY_TO_UPLOAD;
新航点位置 - 55.555549621582,0.555555522441864
加载任务return值-INVALID_REQUEST_IN_CURRENT_STATE
航点状态=READY_TO_UPLOAD
READY_TO_UPLOAD的状态,按照WindowsSDK的说明说明是适合上传航点任务的状态,但是很明显上传失败,状态没有变化。
为了使航路点任务成功加载以便飞机可以 运行 需要更改什么?
//Check the initial state of the waypoint handler
var currentState = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetCurrentState();
Debug.WriteLine("Waypoint state = {0}", currentState);
//Initialise new location coordinate
randomLocation.X = 55.55555;
randomLocation.Y = 0.55555555;
Debug.WriteLine("New waypoint location - {0},{1}", randomLocation.X, randomLocation.Y);
LocationCoordinate2D waypointLocation = new LocationCoordinate2D { latitude = randomLocation.X, longitude = randomLocation.Y };
// Create a waypoint instance and add to waypoint list
Waypoint waypoint = new Waypoint { location = waypointLocation };
waypointList.Add(waypoint);
//Create new waypoint mission instance and load in the waypoint list
WaypointMission waypointMission = new WaypointMission
{
waypointCount = 1,
autoFlightSpeed = 2.5,
finishedAction = WaypointMissionFinishedAction.NO_ACTION,
headingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING,
flightPathMode = WaypointMissionFlightPathMode.CURVED,
repeatTimes = 0,
waypoints = waypointList,
missionID = 1
};
//load the waypoint mission to the aircraft and check the current state
var load_retval = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).LoadMission(waypointMission); ;
Debug.WriteLine("Load mission return value - {0}", load_retval);
currentState = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetCurrentState();
Debug.WriteLine("Waypoint state = {0}", currentState);
经过长时间的试错,我弄清楚了开始航点任务所需的步骤:
将SDK设置为地面站模式
首先你要将SDK设置为地面站模式,方法如下:
DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).SetGroundStationModeEnabledAsync(new BoolMsg() { value = true })
正在加载任务
其次,您必须使用以下方法将航点任务加载到 SDK:
DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).
LoadMission(waypointMission)
其中 waypointMission
可能是您问题中的航路点任务。这个航路点任务必须遵循一些限制。例如总距离不能太长(不确定确切的数字是多少)。如果任务有问题,此方法将 return 一个 SDKError。
正在上传航点任务到无人机
任务加载到SDK后还需要上传到无人机。这是通过以下方法完成的:
DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).
上传任务()
(可选)说明模拟器
此时如果您不想让无人机真正起飞,您可以启动模拟模式。这可以通过以下代码完成:
FlightControllerHandler _flightControllerHandler = DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0);
var simSettings = new SimulatorInitializationSettings()
{
latitude = 0,
longitude = 0,
satelliteCount = 12
};
await _flightControllerHandler.StartSimulatorAsync(simSettings);
重要的是 satelliteCount
高于 10。否则 SDK 将给出 GPS 信号强度不够好的错误。
开始任务 最后你可以开始航点任务如下
DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).StartMission()
其他注意事项:
- 这些电话中的大多数是
async
,值得期待。 即使您等待调用,我注意到上传任务不会在方法完成时完成。因此,如果您在
UploadMission()
之后立即调用StartMission()
,这可能会导致INVALID_REQUEST_IN_CURRENT_STATE
我通过使用单独的按钮来加载和启动来解决这个问题 mission.This 我可以在开始任务之前等待任务上传。
以上所有方法return一个
SDKError
类型。如果一切顺利,这将是一个NO_ERROR
检查每次调用是否都是这种情况很重要。