[英]How can I import a list of Waypoints to a Drone by using DJI Windows SDK
I created a Polygon in a GIS application.我在 GIS 应用程序中创建了一个多边形。 I can export the Polygon to a KML or any other required format.我可以将多边形导出为 KML 或任何其他所需的格式。
I need to define a mission's Waypoints for my drone based on the Polygon that I have.我需要根据我拥有的多边形为我的无人机定义任务的航点。
Is there a simple way to directly feed the Polygon missions Waypoints to a Drone without a MapView?有没有一种简单的方法可以在没有 MapView 的情况下将多边形任务航路点直接提供给无人机?
I have to use DJI Windows SDK, but I saw this sample that interacts with the user to define a mission's Waypoints in a MapView.我必须使用 DJI Windows SDK,但我看到这个示例与用户交互以在 MapView 中定义任务的航点。 My scenario is different.我的情况不同。 I already have Waypoints, and I just need to import them.我已经有了航点,我只需要导入它们。
Update 1: Please note that DJI SDK for iOS and Android are very mature, feature-rich and proven tested.更新 1:请注意,适用于 iOS 和 Android 的 DJI SDK 非常成熟、功能丰富且经过验证。 However, it is not the same with DJU Windows SDK.但是,它与 DJU Windows SDK 不同。 The SDK target platform is vague, but reading its example, I think it runs only on UWP platform. SDK 目标平台含糊不清,但阅读其示例,我认为它仅在 UWP 平台上运行。 That is why the question mentions DJI Windows SDK explicitly.这就是问题明确提到DJI Windows SDK 的原因。 I know the SDK for Android or iOS provides much higher quality and features.我知道适用于 Android 或 iOS 的 SDK 提供了更高的质量和功能。
You can simply add them to the list using the Latitude and Longitude.您可以简单地使用纬度和经度将它们添加到列表中。 You also need the altitude for each point.您还需要每个点的高度。 Make a for loop for all the points that you need or do this code once, use the config dialog then upload and start the mission.为您需要的所有点创建一个 for 循环或一次执行此代码,使用配置对话框然后上传并开始任务。
// Create a waypoint instance
Waypoint mWaypoint1 = new Waypoint(Latitude, Longitude, altitude);
//check if the mission's builder is null
if (waypointMissionBuilder != null) {
if (waypointList.size() > 2)
configWayPointMission();
waypointList.add(mWaypoint1);
waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
}
else {
waypointMissionBuilder = new WaypointMission.Builder();
waypointList.add(mWaypoint1);
waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
}
So, I haven't used the Windows SDK, but I imagine it is similar to the Mobile SDK.所以,我没有使用 Windows SDK,但我认为它类似于 Mobile SDK。 For mobile, you would just put the waypoints in an array/arraylist and load them into the mission all at once.对于移动设备,您只需将航点放在数组/数组列表中,然后一次性将它们加载到任务中。
I'm not sure if you need to convert the KML into waypoints or if you already have the waypoints.我不确定您是否需要将 KML 转换为航点,或者您是否已经拥有航点。 In the former case, you would need to parse the KML.在前一种情况下,您需要解析 KML。 Assuming you have the waypoints parse, then you need to use WaypointMissionManager and WaypointMissionHandler to load the mission and then start the mission.假设你有航点解析,那么你需要使用WaypointMissionManager和WaypointMissionHandler来加载任务然后开始任务。
You can use the load/upload mission functions.您可以使用加载/上传任务功能。 The paramater of load mission is WaypointMission where you can set the number of waypoints and other related info.加载任务的参数是WaypointMission ,您可以在其中设置航点数量和其他相关信息。
For example in Android, I do the following:例如在 Android 中,我执行以下操作:
ArrayList<Waypoint> waypoints = new ArrayList<>();
for(int i = 0; i < wplist.size(); i++) {
double lat = wplist.get(i).latitude;
double lon = wplist.get(i).longitude;
//each dji waypoint corresponds to the predetermined waypoints
Waypoint djiWaypoint = new Waypoint(lat, lon, altitude);
//Point Gimbal down for each waypoint
djiWaypoint.gimbalPitch = gimbalPitchDown;
//add waypoint to waypoints array
waypoints.add(djiWaypoint);
}
//initiate builder and add waypoints to it- not yet built
waypointMissionBuilder = new WaypointMission.Builder();
waypointMissionBuilder.waypointList(waypoints).waypointCount(waypoints.size());
totalNumberOfWaypointsInMission = waypointMissionBuilder.getWaypointCount();
//Prepare mission by updating configure and instantiate waypointMissionBuilder
configWayPointMission();
//upload Mission
uploadWaypointMission();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.