private void configGroundStationTask() { mGroundStationTask.isLoop = repeatGSTask; mGroundStationTask.finishAction = actionAfterFinishTask; mGroundStationTask.movingMode = heading; for (int i = 0; i < mGroundStationTask.wayPointCount; i++) { mGroundStationTask.getWaypointAtIndex(i).speed = speedGSTask; mGroundStationTask.getWaypointAtIndex(i).altitude = altitude; } }
private void stopGroundStationTask() { DJIDrone.getDjiGroundStation() .pauseGroundStationTask( new DJIGroundStationExecuteCallBack() { @Override public void onResult(DJIGroundStationTypeDef.GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "return code =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); DJIDrone.getDjiGroundStation() .closeGroundStation( new DJIGroundStationExecuteCallBack() { @Override public void onResult(DJIGroundStationTypeDef.GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "return code =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); } }); mGroundStationTask.RemoveAllWaypoint(); }
/** * Called when a view has been clicked. * * @param v The view that was clicked. */ @Override public void onClick(View v) { switch (v.getId()) { case R.id.locate: { updateDroneLocation(); cameraUpdate(); // Locate the drone's place break; } case R.id.add: { enableDisableAdd(); break; } case R.id.clear: { runOnUiThread( new Runnable() { @Override public void run() { aMap.clear(); } }); mGroundStationTask.RemoveAllWaypoint(); // Remove all the waypoints added to the task break; } case R.id.config: { showSettingDialog(); break; } case R.id.upload: { uploadGroundStationTask(); break; } case R.id.start: { startGroundStationTask(); mTimer.schedule(mTask, 0, 1000); break; } case R.id.stop: { stopGroundStationTask(); mTimer.cancel(); break; } case R.id.takeoff: { aircraftTakeOff(); break; } default: break; } }
@Override public void onMapClick(LatLng point) { if (isAdd == true) { markWaypoint(point); DJIGroundStationWaypoint mDJIGroundStationWaypoint = new DJIGroundStationWaypoint(point.latitude, point.longitude); mGroundStationTask.addWaypoint(mDJIGroundStationWaypoint); // Add waypoints to Waypoint arraylist; } else { // Do not add waypoint; } }
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.OpenGsButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .openGroundStation( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.AddWaypointButton: if (!checkGetHomePoint()) return; if (DJIDrone.getDroneType() == DJIDroneType.DJIDrone_Vision) { // north DJIGroundStationWaypoint mWayPoint1 = new DJIGroundStationWaypoint( homeLocationLatitude + 0.0000899322, homeLocationLongitude); mWayPoint1.altitude = 15f; mWayPoint1.speed = 2; // slow 2 mWayPoint1.heading = 0; mWayPoint1.maxReachTime = 999; mWayPoint1.stayTime = 10; mWayPoint1.turnMode = 1; // east DJIGroundStationWaypoint mWayPoint2 = new DJIGroundStationWaypoint( homeLocationLatitude, homeLocationLongitude + 0.0000899322); mWayPoint2.altitude = 5f; mWayPoint2.speed = 2; // slow 2 mWayPoint2.heading = 80; mWayPoint2.maxReachTime = 999; mWayPoint2.stayTime = 20; mWayPoint2.turnMode = 1; mTask.addWaypoint(mWayPoint2); // south DJIGroundStationWaypoint mWayPoint3 = new DJIGroundStationWaypoint( homeLocationLatitude - 0.0000899322, homeLocationLongitude); mWayPoint3.altitude = 30f; mWayPoint3.speed = 2; // slow 2 mWayPoint3.heading = -60; mWayPoint3.maxReachTime = 999; mWayPoint3.stayTime = 25; mWayPoint3.turnMode = 1; mTask.addWaypoint(mWayPoint3); mTask.wayPointCount = mTask.getAllWaypoint().size(); } else { // north DJIGroundStationWaypoint mWayPoint1 = new DJIGroundStationWaypoint( homeLocationLatitude + 0.0000899322, homeLocationLongitude); mWayPoint1.action.actionRepeat = 1; mWayPoint1.altitude = 15f; mWayPoint1.heading = 0; mWayPoint1.actionTimeout = 10; mWayPoint1.turnMode = 1; mWayPoint1.dampingDistance = 1.5f; mWayPoint1.hasAction = true; mWayPoint1.addAction(GroundStationOnWayPointAction.Way_Point_Action_Simple_Shot, 1); mWayPoint1.addAction(GroundStationOnWayPointAction.Way_Point_Action_Video_Start, 0); mWayPoint1.addAction(GroundStationOnWayPointAction.Way_Point_Action_Video_Stop, 0); mTask.addWaypoint(mWayPoint1); // east DJIGroundStationWaypoint mWayPoint2 = new DJIGroundStationWaypoint( homeLocationLatitude, homeLocationLongitude + 0.0000899322); mWayPoint2.action.actionRepeat = 1; mWayPoint2.altitude = 20f; mWayPoint2.heading = 80; mWayPoint2.actionTimeout = 20; mWayPoint2.turnMode = 1; mWayPoint2.dampingDistance = 2.5f; mWayPoint2.hasAction = true; mWayPoint2.addAction(GroundStationOnWayPointAction.Way_Point_Action_Craft_Yaw, -130); mTask.addWaypoint(mWayPoint2); // south DJIGroundStationWaypoint mWayPoint3 = new DJIGroundStationWaypoint( homeLocationLatitude - 0.0000899322, homeLocationLongitude); mWayPoint3.action.actionRepeat = 1; mWayPoint3.altitude = 30f; mWayPoint3.heading = -60; mWayPoint3.actionTimeout = 25; mWayPoint3.turnMode = 1; mWayPoint3.dampingDistance = 1.0f; mWayPoint3.hasAction = true; mWayPoint3.addAction(GroundStationOnWayPointAction.Way_Point_Action_Gimbal_Pitch, -89); mTask.addWaypoint(mWayPoint3); mTask.finishAction = DJIGroundStationFinishAction.Go_Home; mTask.movingMode = DJIGroundStationMovingMode.GSHeadingUsingWaypointHeading; mTask.pathMode = DJIGroundStationPathMode.Point_To_Point; mTask.wayPointCount = mTask.getAllWaypoint().size(); } break; case R.id.UploadWaypointButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .uploadGroundStationTask( mTask, new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.TakeOffButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .startGroundStationTask( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.GohomeButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .goHome( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.CloseGsButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .closeGroundStation( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.PauseButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .pauseGroundStationTask( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.ResumeButton: if (!checkGetHomePoint()) return; DJIDrone.getDjiGroundStation() .continueGroundStationTask( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); } }); break; case R.id.OneKeyFlyButton: if (!checkGetHomePoint()) { // DealErrorWithVibrate(); return; } if (!isFlying) { DJIDrone.getDjiGroundStation() .openGroundStation( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "opengs result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); if (result == GroundStationResult.GS_Result_Success) { // one key fly DJIDrone.getDjiGroundStation() .oneKeyFly( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "one key fly result =" + result.toString(); handler.sendMessage( handler.obtainMessage(SHOWTOAST, ResultsString)); if (result == GroundStationResult.GS_Result_Success) { if (DJIDrone.getDroneType() == DJIDroneType.DJIDrone_Vision) { mCheckModeForPauseTimer = new Timer(); CheckModeForPauseTask mCheckTask = new CheckModeForPauseTask(); mCheckModeForPauseTimer.schedule(mCheckTask, 100, 1000); } else { DealSuccessWithVibrate(); } } else { DealErrorWithVibrate(); } } }); } else { DealErrorWithVibrate(); } } }); } else { DJIDrone.getDjiGroundStation() .openGroundStation( new DJIGroundStationExecuteCallBack() { @Override public void onResult(GroundStationResult result) { // TODO Auto-generated method stub String ResultsString = "opengs result =" + result.toString(); handler.sendMessage(handler.obtainMessage(SHOWTOAST, ResultsString)); if (result == GroundStationResult.GS_Result_Success) { if (DJIDrone.getDroneType() == DJIDroneType.DJIDrone_Vision) { mCheckModeForPauseTimer = new Timer(); CheckModeForPauseTask mCheckTask = new CheckModeForPauseTask(); mCheckModeForPauseTimer.schedule(mCheckTask, 100, 1000); } else { DealSuccessWithVibrate(); } } else { DealErrorWithVibrate(); } } }); } break; default: break; } }