convertWaypointMissionVectorsToLocationsWithGimbalPitch method
Null safety
Implementation
static FlightElementWaypointMission?
convertWaypointMissionVectorsToLocationsWithGimbalPitch(
{required FlightElementWaypointMission flightElementWaypointMission,
required FlightLocation droneHomeLocation}) {
if (flightElementWaypointMission.pointOfInterest == null) {
developer.log(
'convertWaypointMissionVectorsToLocations - Waypoint Mission Point of Interest does not exist',
name: kLogKindDjiFlutterPlugin,
);
return null;
}
for (FlightWaypoint waypoint in flightElementWaypointMission.waypoints) {
// Compute Location per Vector definition
if (waypoint.vector != null && waypoint.location == null) {
waypoint.location = CoordinatesConvertion.vectorToLocation(
droneLocation: droneHomeLocation,
pointOfInterest: flightElementWaypointMission.pointOfInterest!,
vector: waypoint.vector!);
} else {
// Location already exists - Keeping the existing waypoint
}
// Compute Gimbal Angle, but only if it doesn't exist
if (waypoint.gimbalPitch == null && waypoint.location != null) {
waypoint.gimbalPitch = CoordinatesConvertion.computeGimbalAngle(
flightElementWaypointMission.pointOfInterest!, waypoint.location!);
}
}
developer.log(
'convertWaypointMissionVectorsToLocations - updated waypoints: ${jsonEncode(flightElementWaypointMission.waypoints)}',
name: kLogKindDjiFlutterPlugin,
);
}