This commit is contained in:
cxf 2026-02-10 20:46:40 +08:00
parent cf1cc1105f
commit 5dba8fa2c5
30 changed files with 2074 additions and 1456 deletions

View File

@ -90,7 +90,8 @@ open class ConnectionActivity : BaseActivity() {
} }
if (TextUtils.isEmpty(PreferenceUtils.getInstance().mqttServerUri)){ if (TextUtils.isEmpty(PreferenceUtils.getInstance().mqttServerUri)){
PreferenceUtils.getInstance().mqttServerUri = PreferenceUtils.getInstance().mqttServerUri =
"tcp://192.168.20.90:2883" // "tcp://192.168.20.90:2883"
"tcp://broker.emqx.io"
} }
if (TextUtils.isEmpty(PreferenceUtils.getInstance().mqttUserName)){ if (TextUtils.isEmpty(PreferenceUtils.getInstance().mqttUserName)){

View File

@ -47,8 +47,10 @@ import com.aros.apron.tools.MqttManager
import com.aros.apron.tools.PreferenceUtils import com.aros.apron.tools.PreferenceUtils
import com.dji.wpmzsdk.manager.WPMZManager import com.dji.wpmzsdk.manager.WPMZManager
import com.google.gson.Gson import com.google.gson.Gson
import dji.sdk.keyvalue.key.CameraKey
import dji.sdk.keyvalue.key.DJIKey import dji.sdk.keyvalue.key.DJIKey
import dji.sdk.keyvalue.key.FlightControllerKey import dji.sdk.keyvalue.key.FlightControllerKey
import dji.sdk.keyvalue.key.GimbalKey
import dji.sdk.keyvalue.key.KeyTools import dji.sdk.keyvalue.key.KeyTools
import dji.sdk.keyvalue.value.common.CameraLensType import dji.sdk.keyvalue.value.common.CameraLensType
import dji.sdk.keyvalue.value.common.ComponentIndexType import dji.sdk.keyvalue.value.common.ComponentIndexType
@ -578,9 +580,12 @@ open class MainActivity : BaseActivity() {
val isFlightControllerConnect = val isFlightControllerConnect =
KeyManager.getInstance().getValue(DJIKey.create(FlightControllerKey.KeyConnection)) KeyManager.getInstance().getValue(DJIKey.create(FlightControllerKey.KeyConnection))
// val isCameraConnect = val isCameraConnect =
// KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.KeyConnection, ComponentIndexType.PORT_1)) KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.KeyConnection, ComponentIndexType.PORT_1))
// LogUtil.log(TAG,isCameraConnect.toString()) val isGimbal =KeyManager.getInstance().getValue(KeyTools.createKey(GimbalKey.KeyConnection, ComponentIndexType.PORT_1))
LogUtil.log(TAG,isCameraConnect.toString())
//全装在初始化
if ((isFlightControllerConnect == null || !isFlightControllerConnect)) { if ((isFlightControllerConnect == null || !isFlightControllerConnect)) {
handler.postDelayed({ handler.postDelayed({
initDJIManager() initDJIManager()
@ -588,17 +593,22 @@ open class MainActivity : BaseActivity() {
} else { } else {
initTimes++ initTimes++
LogUtil.log(TAG, "初始化$initTimes") LogUtil.log(TAG, "初始化$initTimes")
LogUtil.log(TAG,"自定义推流方式:"+PreferenceUtils.getInstance().customStreamType)
Handler().postDelayed(Runnable {
MissionV3Manager.getInstance().initMissionManager() MissionV3Manager.getInstance().initMissionManager()
FlightManager.getInstance().initFlightInfo() FlightManager.getInstance().initFlightInfo()
BatteryManager.getInstance().initBatteryInfo() BatteryManager.getInstance().initBatteryInfo()
StickManager.getInstance().initStickInfo() StickManager.getInstance().initStickInfo()
GimbalManager.getInstance().initGimbalInfo()
AlternateLandingManager.getInstance().initAlterLandingInfo() AlternateLandingManager.getInstance().initAlterLandingInfo()
OSDManager.getInstance().initOsd() OSDManager.getInstance().initOsd()
FlightTaskProgressManager.getInstance().initFlightTaskProgress() FlightTaskProgressManager.getInstance().initFlightTaskProgress()
MediaManager.getInstance().init() MediaManager.getInstance().init()
StreamManager.getInstance().initStreamManager() StreamManager.getInstance().initStreamManager()
GimbalManager.getInstance().initGimbalInfo()
//负载 //负载
PayloadWidgetManager.getInstance().initPayloadInfo() PayloadWidgetManager.getInstance().initPayloadInfo()
//初始化上报 //初始化上报
@ -609,8 +619,8 @@ open class MainActivity : BaseActivity() {
LEDsSettingsManager.getInstance().initLEDsInfo() LEDsSettingsManager.getInstance().initLEDsInfo()
LogUtil.log(TAG,"自定义推流方式:"+PreferenceUtils.getInstance().customStreamType)
Handler().postDelayed(Runnable {
if (PreferenceUtils.getInstance().customStreamType==1){ if (PreferenceUtils.getInstance().customStreamType==1){
StreamManager.getInstance() StreamManager.getInstance()
.startLiveWithRTSP() .startLiveWithRTSP()

View File

@ -8,9 +8,12 @@ import com.aros.apron.tools.LogUtil
import com.aros.apron.xclog.CrashHandler import com.aros.apron.xclog.CrashHandler
import com.aros.apron.xclog.XcFileLog import com.aros.apron.xclog.XcFileLog
import com.aros.apron.xclog.XcLogConfig import com.aros.apron.xclog.XcLogConfig
import com.dji.wpmzsdk.manager.WPMZManager
import com.orhanobut.logger.AndroidLogAdapter import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.Logger import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy import com.orhanobut.logger.PrettyFormatStrategy
import dji.v5.common.utils.GeoidManager
import dji.v5.utils.common.ContextUtil
import org.opencv.android.OpenCVLoader import org.opencv.android.OpenCVLoader
@ -57,13 +60,9 @@ open class ApronApp : Application() {
return true return true
} }
}) })
XcFileLog.init(XcLogConfig()) XcFileLog.init(XcLogConfig())
//打印崩溃日志 //打印崩溃日志
CrashHandler.getInstance().init() CrashHandler.getInstance().init()
// 初始化 OpenCV // 初始化 OpenCV
if (OpenCVLoader.initLocal()) { if (OpenCVLoader.initLocal()) {
LogUtil.log("qwq","opencv" + LogUtil.log("qwq","opencv" +

View File

@ -5,11 +5,13 @@ import static com.aros.apron.tools.Utils.getIDJIErrorMsg;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.aros.apron.constant.AMSConfig; import com.aros.apron.constant.AMSConfig;
import com.aros.apron.constant.Constant; import com.aros.apron.constant.Constant;
import com.aros.apron.entity.CameraPhotoTakeProgress;
import com.aros.apron.entity.CurrentWayline; import com.aros.apron.entity.CurrentWayline;
import com.aros.apron.entity.FlightTaskProgress; import com.aros.apron.entity.FlightTaskProgress;
import com.aros.apron.entity.MediaUpLoad; import com.aros.apron.entity.MediaUpLoad;
@ -17,6 +19,7 @@ import com.aros.apron.entity.MessageDown;
import com.aros.apron.entity.MessageEvent; import com.aros.apron.entity.MessageEvent;
import com.aros.apron.entity.MessageReply; import com.aros.apron.entity.MessageReply;
import com.aros.apron.entity.Movement; import com.aros.apron.entity.Movement;
import com.aros.apron.entity.TakeoffToPointProgress;
import com.aros.apron.entity.TaskFailEvent; import com.aros.apron.entity.TaskFailEvent;
import com.aros.apron.entity.WirelessLink; import com.aros.apron.entity.WirelessLink;
import com.aros.apron.tools.LogUtil; import com.aros.apron.tools.LogUtil;
@ -27,6 +30,7 @@ import com.google.gson.Gson;
import org.eclipse.paho.android.service.MqttAndroidClient; import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import dji.v5.common.callback.CommonCallbacks; import dji.v5.common.callback.CommonCallbacks;
@ -131,7 +135,7 @@ public abstract class BaseManager {
* 发送常规event事件 * 发送常规event事件
*/ */
public void sendEvent2Server(String msg,int level) { public void sendEvent2Server(String msg,int level) {
LogUtil.log(TAG,"发送常规事件:"+"run_log -"+msg); //LogUtil.log(TAG,"发送常规事件:"+"run_log -"+msg);
try { try {
if (MqttManager.getInstance().mqttAndroidClient.isConnected()) { if (MqttManager.getInstance().mqttAndroidClient.isConnected()) {
MessageEvent messageEvent = new MessageEvent(); MessageEvent messageEvent = new MessageEvent();
@ -164,7 +168,7 @@ public abstract class BaseManager {
* 发送媒体文件上传事件 * 发送媒体文件上传事件
*/ */
public void sendMediaUpload2Server(String fileName,int uploaded_file_count,int expected_file_count) { public void sendMediaUpload2Server(String fileName,int uploaded_file_count,int expected_file_count) {
LogUtil.log(TAG,"发送媒体上传完成事件:"+fileName); //LogUtil.log(TAG,"发送媒体上传完成事件:"+fileName);
try { try {
if (MqttManager.getInstance().mqttAndroidClient.isConnected()) { if (MqttManager.getInstance().mqttAndroidClient.isConnected()) {
MediaUpLoad mediaUpLoad = new MediaUpLoad(); MediaUpLoad mediaUpLoad = new MediaUpLoad();
@ -204,17 +208,23 @@ public abstract class BaseManager {
final FlightTaskProgress.Data.Output.Ext ext = new FlightTaskProgress.Data.Output.Ext(); final FlightTaskProgress.Data.Output.Ext ext = new FlightTaskProgress.Data.Output.Ext();
ext.setCurrent_waypoint_index(Movement.getInstance().getTask_current_waypoint_index()); ext.setCurrent_waypoint_index(Movement.getInstance().getTask_current_waypoint_index());
ext.setFlight_id(PreferenceUtils.getInstance().getFlightId()); ext.setFlight_id(PreferenceUtils.getInstance().getFlightId());
//媒体文件数量
ext.setMedia_count(Movement.getInstance().getTask_media_count()); ext.setMedia_count(Movement.getInstance().getTask_media_count());
ext.setTrack_id(Movement.getInstance().getTrack_id()); ext.setTrack_id(Movement.getInstance().getTrack_id());
ext.setWayline_id(Movement.getInstance().getTask_wayline_id()); ext.setWayline_id(Movement.getInstance().getTask_wayline_id());
ext.setWayline_mission_state(Movement.getInstance().getTask_wayline_mission_state()); ext.setWayline_mission_state(Movement.getInstance().getTask_wayline_mission_state());
final FlightTaskProgress.Data.Output.Progress progress = new FlightTaskProgress.Data.Output.Progress(); final FlightTaskProgress.Data.Output.Progress progress = new FlightTaskProgress.Data.Output.Progress();
// LogUtil.log(TAG,"CurrentWayline"+CurrentWayline.getInstance().getWaypoints()+"size"+CurrentWayline.getInstance().getWaypoints().size()
// +"getTask_wayline_mission_state"+Movement.getInstance().getTask_wayline_mission_state());
if (CurrentWayline.getInstance().getWaypoints() != null if (CurrentWayline.getInstance().getWaypoints() != null
&& CurrentWayline.getInstance().getWaypoints().size() > 0 && CurrentWayline.getInstance().getWaypoints().size() > 0
&& Movement.getInstance().getTask_wayline_mission_state() == 6) { && Movement.getInstance().getTask_wayline_mission_state() == 6) {
//这个没执行到
progress.setPercent((100 * (Movement.getInstance().getCurrentWaypointIndex() + 1) progress.setPercent((100 * (Movement.getInstance().getCurrentWaypointIndex() + 1)
/ CurrentWayline.getInstance().getWaypoints().size())); / CurrentWayline.getInstance().getWaypoints().size()));
} }
progress.setCurrent_step(Movement.getInstance().getTask_current_step()); progress.setCurrent_step(Movement.getInstance().getTask_current_step());
@ -264,6 +274,7 @@ public abstract class BaseManager {
breakPoint.setLatitude(breakPointInfo.getLocation().getLatitude()); breakPoint.setLatitude(breakPointInfo.getLocation().getLatitude());
breakPoint.setLongitude(breakPointInfo.getLocation().getLongitude()); breakPoint.setLongitude(breakPointInfo.getLocation().getLongitude());
breakPoint.setProgress(Movement.getInstance().getTask_progress()); breakPoint.setProgress(Movement.getInstance().getTask_progress());
breakPoint.setState(Movement.getInstance().getState()); breakPoint.setState(Movement.getInstance().getState());
breakPoint.setWayline_id(Movement.getInstance().getTask_wayline_id()); breakPoint.setWayline_id(Movement.getInstance().getTask_wayline_id());
@ -353,9 +364,8 @@ public abstract class BaseManager {
MqttMessage mqttMessage = new MqttMessage(new Gson().toJson(flightTaskProgress).getBytes("UTF-8")); MqttMessage mqttMessage = new MqttMessage(new Gson().toJson(flightTaskProgress).getBytes("UTF-8"));
mqttMessage.setQos(0); mqttMessage.setQos(0);
MqttManager.getInstance().mqttAndroidClient.publish(AMSConfig.UP_UAV_EVENT, mqttMessage); MqttManager.getInstance().mqttAndroidClient.publish(AMSConfig.UP_UAV_EVENT, mqttMessage);
LogUtil.log(TAG, "发送任务进度事件(正常状态):" + new Gson().toJson(flightTaskProgress)); //LogUtil.log(TAG, "发送任务进度事件(正常状态):" + new Gson().toJson(flightTaskProgress));
} }
} else { } else {
LogUtil.log(TAG, "发送任务进度event失败mqtt 未连接"); LogUtil.log(TAG, "发送任务进度event失败mqtt 未连接");
} }
@ -380,6 +390,7 @@ public abstract class BaseManager {
Movement.getInstance().setHeight(breakPointInfo.getLocation().getAltitude()); Movement.getInstance().setHeight(breakPointInfo.getLocation().getAltitude());
Movement.getInstance().setTask_latitude(breakPointInfo.getLocation().getLatitude()); Movement.getInstance().setTask_latitude(breakPointInfo.getLocation().getLatitude());
Movement.getInstance().setTask_longitude(breakPointInfo.getLocation().getLongitude()); Movement.getInstance().setTask_longitude(breakPointInfo.getLocation().getLongitude());
Movement.getInstance().setTask_progress(breakPointInfo.getSegmentProgress()); Movement.getInstance().setTask_progress(breakPointInfo.getSegmentProgress());
Movement.getInstance().setTask_state(0); Movement.getInstance().setTask_state(0);
Movement.getInstance().setTask_wayline_id(breakPointInfo.getWaylineID()); Movement.getInstance().setTask_wayline_id(breakPointInfo.getWaylineID());
@ -434,6 +445,109 @@ public abstract class BaseManager {
LogUtil.log(TAG, "发送sdr异常" + e.toString()); LogUtil.log(TAG, "发送sdr异常" + e.toString());
} }
} }
/**
* 上报一键起飞任务进度
*/
public void sendTakeoffToPointProgress2Server() {
try {
if (MqttManager.getInstance().mqttAndroidClient.isConnected()) {
// 构建 data 数据
TakeoffToPointProgress.Data data = new TakeoffToPointProgress.Data();
data.setFlightId(PreferenceUtils.getInstance().getFlightId());
data.setTrackId(PreferenceUtils.getInstance().getFlightId());
data.setStatus(Movement.getInstance().getTakeoff_status());
data.setResult(Movement.getInstance().getTakeoff_result());
data.setWayPointIndex(Movement.getInstance().getCurrentWaypointIndex());
data.setRemainingDistance(Movement.getInstance().getTakeoff_remaining_distance());
data.setRemainingTime(Movement.getInstance().getTakeoff_remaining_time());
data.setPlannedPathPoints(Movement.getInstance().getTakeoff_planned_path_points());
// 构建事件对象
TakeoffToPointProgress progress = new TakeoffToPointProgress();
progress.setBid(UUID.randomUUID().toString());
progress.setTid(UUID.randomUUID().toString());
progress.setTimestamp(System.currentTimeMillis());
progress.setMethod("takeoff_to_point_progress");
progress.setNeedReply(1);
progress.setData(data);
// 发送
MqttMessage mqttMessage = new MqttMessage(new Gson().toJson(progress).getBytes("UTF-8"));
mqttMessage.setQos(0);
MqttManager.getInstance().mqttAndroidClient.publish(AMSConfig.UP_UAV_EVENT, mqttMessage);
LogUtil.log(TAG, "发送一键起飞进度事件:" + new Gson().toJson(progress));
} else {
LogUtil.log(TAG, "发送一键起飞进度event失败mqtt 未连接");
}
} catch (Exception e) {
e.printStackTrace();
LogUtil.log(TAG, "发送一键起飞进度event异常" + e.toString());
}
}
/**
* 上报拍照进度camera_photo_take_progress
* 目前仅支持全景拍照模式
* 数据先存 Movement再组装发送
*/
public void sendCameraPhotoTakeProgress2Server() {
try {
if (MqttManager.getInstance().mqttAndroidClient.isConnected()) {
// 构建 output.progress
CameraPhotoTakeProgress.Data.Output.Progress progress =
new CameraPhotoTakeProgress.Data.Output.Progress();
progress.setCurrent_step(Movement.getInstance().getPhoto_current_step());
progress.setPercent(Movement.getInstance().getPhoto_percent());
// 构建 output.ext
CameraPhotoTakeProgress.Data.Output.Ext ext =
new CameraPhotoTakeProgress.Data.Output.Ext();
ext.setCamera_mode(3);
// 构建 output
CameraPhotoTakeProgress.Data.Output output =
new CameraPhotoTakeProgress.Data.Output();
output.setStatus(Movement.getInstance().getPhoto_status());
output.setProgress(progress);
output.setExt(ext);
// 构建 data
CameraPhotoTakeProgress.Data data = new CameraPhotoTakeProgress.Data();
data.setResult(Movement.getInstance().getPhoto_result());
data.setOutput(output);
// 构建完整消息
CameraPhotoTakeProgress photoProgress = new CameraPhotoTakeProgress();
photoProgress.setBid(UUID.randomUUID().toString());
photoProgress.setTid(UUID.randomUUID().toString());
photoProgress.setTimestamp(System.currentTimeMillis());
photoProgress.setMethod("camera_photo_take_progress");
photoProgress.setData(data);
// 发送
MqttMessage mqttMessage = new MqttMessage(
new Gson().toJson(photoProgress).getBytes("UTF-8")
);
mqttMessage.setQos(0);
MqttManager.getInstance().mqttAndroidClient.publish(
AMSConfig.UP_UAV_EVENT,
mqttMessage
);
LogUtil.log(TAG, "发送拍照进度事件:" + new Gson().toJson(photoProgress));
} else {
LogUtil.log(TAG, "发送拍照进度失败mqtt 未连接");
}
} catch (Exception e) {
e.printStackTrace();
LogUtil.log(TAG, "发送拍照进度异常:" + e.toString());
}
}
public boolean getGimbalAndCameraEnabled() { public boolean getGimbalAndCameraEnabled() {

View File

@ -6,6 +6,7 @@ import android.os.Looper;
import android.util.Log; import android.util.Log;
import com.aros.apron.app.ApronApp; import com.aros.apron.app.ApronApp;
import com.aros.apron.base.BaseManager;
import com.aros.apron.constant.AMSConfig; import com.aros.apron.constant.AMSConfig;
import com.aros.apron.constant.Constant; import com.aros.apron.constant.Constant;
import com.aros.apron.entity.ApronExecutionStatus; import com.aros.apron.entity.ApronExecutionStatus;
@ -31,19 +32,18 @@ import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
public class MqttCallBack implements MqttCallbackExtended { public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
private String TAG = "MqttCallBack"; private String TAG = "MqttCallBack";
@Override @Override
public void connectionLost(Throwable cause) { public void connectionLost(Throwable cause) {
LogUtil.log(TAG, "MQtt connectionLost:" + cause.toString()); LogUtil.log(TAG, "MQtt connectionLost:"+cause.toString());
//短线也要清空这个 //短线也要清空这个
clearVirtualStickHeartbeat(); clearVirtualStickHeartbeat();
} }
//断线重连 //断线重连
public void reConnect() throws Exception { public void reConnect() throws Exception {
if (null != MqttManager.getInstance().mqttAndroidClient) { if (null != MqttManager.getInstance().mqttAndroidClient) {
@ -52,6 +52,7 @@ public class MqttCallBack implements MqttCallbackExtended {
} }
// 心跳检测 // 心跳检测
private volatile long lastDrControlTime = 0; private volatile long lastDrControlTime = 0;
private final Handler vsHandler = new Handler(Looper.getMainLooper()); private final Handler vsHandler = new Handler(Looper.getMainLooper());
@ -59,9 +60,7 @@ public class MqttCallBack implements MqttCallbackExtended {
private static final long TIMEOUT_MS = 500; // 500ms 无数据触发 private static final long TIMEOUT_MS = 500; // 500ms 无数据触发
/** /** 每次收到控制指令都调 */
* 每次收到控制指令都调
*/
private void resetVirtualStickHeartbeat() { private void resetVirtualStickHeartbeat() {
lastDrControlTime = System.currentTimeMillis(); lastDrControlTime = System.currentTimeMillis();
@ -80,9 +79,7 @@ public class MqttCallBack implements MqttCallbackExtended {
vsHandler.postDelayed(vsTimeoutCheck, TIMEOUT_MS); vsHandler.postDelayed(vsTimeoutCheck, TIMEOUT_MS);
} }
/** /** 清理虚拟摇杆心跳(断网/退出/销毁时调) */
* 清理虚拟摇杆心跳断网/退出/销毁时调
*/
private void clearVirtualStickHeartbeat() { private void clearVirtualStickHeartbeat() {
if (vsTimeoutCheck != null) { if (vsTimeoutCheck != null) {
vsHandler.removeCallbacks(vsTimeoutCheck); vsHandler.removeCallbacks(vsTimeoutCheck);
@ -92,17 +89,24 @@ public class MqttCallBack implements MqttCallbackExtended {
} }
@Override @Override
public void messageArrived(String topic, MqttMessage mqttMessage) { public void messageArrived(String topic, MqttMessage mqttMessage) {
String jsonString = null; String jsonString = null;
// Log.e(TAG, "入口打印:" +mqttMessage.toString()); //Log.e(TAG, "入口打印:" +mqttMessage.toString());
try { try {
jsonString = new String(mqttMessage.getPayload(), "UTF-8"); jsonString = new String(mqttMessage.getPayload(), "UTF-8");
} catch (Exception e) { } catch (Exception e) {
LogUtil.log(TAG, "解析异常"); LogUtil.log(TAG, "解析异常");
throw new RuntimeException(e); throw new RuntimeException(e);
} }
MessageDown message = new Gson().fromJson(jsonString, MessageDown.class); MessageDown message = new Gson().fromJson(jsonString, MessageDown.class);
//LogUtil.log(TAG,message.getMethod());
switch (message.getMethod()) { switch (message.getMethod()) {
case Constant.PILOT_ON: case Constant.PILOT_ON:
// LogUtil.log(TAG, "收到:遥控器是否开机" + jsonString); // LogUtil.log(TAG, "收到:遥控器是否开机" + jsonString);
@ -140,7 +144,7 @@ public class MqttCallBack implements MqttCallbackExtended {
LogUtil.log(TAG, "收到:航线" + jsonString); LogUtil.log(TAG, "收到:航线" + jsonString);
//设置modecode //设置modecode
Movement.getInstance().setMode_code(1); Movement.getInstance().setMode_code(1);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
//设置标志为 //设置标志为
Movement.getInstance().setFlightmode(1); Movement.getInstance().setFlightmode(1);
MissionV3Manager.getInstance().taskExecute(message); MissionV3Manager.getInstance().taskExecute(message);
@ -158,6 +162,7 @@ public class MqttCallBack implements MqttCallbackExtended {
LogUtil.log(TAG, "收到:返航" + jsonString); LogUtil.log(TAG, "收到:返航" + jsonString);
//自动返航 (如果调用方法失败了 这个设置就有一个问题但是为了方便看懂我就放这里了没放成功的回调里面) //自动返航 (如果调用方法失败了 这个设置就有一个问题但是为了方便看懂我就放这里了没放成功的回调里面)
Movement.getInstance().setMode_code(9); Movement.getInstance().setMode_code(9);
sendFlightTaskProgress2Server();
FlightManager.getInstance().startGoHome(message); FlightManager.getInstance().startGoHome(message);
break; break;
case Constant.RETURN_HOME_CANCEL: case Constant.RETURN_HOME_CANCEL:
@ -184,7 +189,7 @@ public class MqttCallBack implements MqttCallbackExtended {
LogUtil.log(TAG, "收到:一键起飞" + jsonString); LogUtil.log(TAG, "收到:一键起飞" + jsonString);
//设置modecode //设置modecode
Movement.getInstance().setMode_code(1); Movement.getInstance().setMode_code(1);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
//设置标志为 //设置标志为
Movement.getInstance().setFlightmode(2); Movement.getInstance().setFlightmode(2);
TakeOffToPointManager.getInstance().taskExecute(message); TakeOffToPointManager.getInstance().taskExecute(message);
@ -260,10 +265,6 @@ public class MqttCallBack implements MqttCallbackExtended {
LogUtil.log(TAG, "收到:负载控制—变焦" + jsonString); LogUtil.log(TAG, "收到:负载控制—变焦" + jsonString);
CameraManager.getInstance().setCameraZoomRatios(message); CameraManager.getInstance().setCameraZoomRatios(message);
break; break;
case Constant.CAMERA_FRAME_ZOOM:
LogUtil.log(TAG, "收到:框选变焦" + jsonString);
CameraManager.getInstance().camera_frame_zoom(message);
break;
case Constant.GIMBAL_RESET: case Constant.GIMBAL_RESET:
LogUtil.log(TAG, "收到:负载控制—重置云台" + jsonString); LogUtil.log(TAG, "收到:负载控制—重置云台" + jsonString);
GimbalManager.getInstance().gimbalReset(message); GimbalManager.getInstance().gimbalReset(message);
@ -316,6 +317,11 @@ public class MqttCallBack implements MqttCallbackExtended {
case Constant.POI_CIRCLE_SPEED_SET: case Constant.POI_CIRCLE_SPEED_SET:
LogUtil.log(TAG, "收到飞行控制—POI 环绕速度设置" + jsonString); LogUtil.log(TAG, "收到飞行控制—POI 环绕速度设置" + jsonString);
break; break;
case Constant.CAMERA_FRAME_ZOOM:
LogUtil.log(TAG, "收到:框选变焦" + jsonString);
CameraManager.getInstance().camera_frame_zoom(message);
break;
// //获取控制权 // //获取控制权
// case 60007: // case 60007:
// LogUtil.log(TAG, "收到:获取控制权" + jsonString); // LogUtil.log(TAG, "收到:获取控制权" + jsonString);
@ -667,15 +673,13 @@ public class MqttCallBack implements MqttCallbackExtended {
public void deliveryComplete(IMqttDeliveryToken token) { public void deliveryComplete(IMqttDeliveryToken token) {
} }
String[] topics = new String[] {
String[] topics = new String[]{
AMSConfig.getInstance().DOWN_UAV_EVENT_REPLY, AMSConfig.getInstance().DOWN_UAV_EVENT_REPLY,
AMSConfig.getInstance().DOWN_UAV_SERVICES, AMSConfig.getInstance().DOWN_UAV_SERVICES,
}; };
int[] qos = new int[]{ int[] qos = new int[] {
1, 1 1, 1
}; };
@Override @Override
public void connectComplete(boolean reconnect, String serverURI) { public void connectComplete(boolean reconnect, String serverURI) {
try { try {

View File

@ -277,13 +277,14 @@ public class Constant {
* 遥控器上报sdr和4g状态 * 遥控器上报sdr和4g状态
*/ */
public static final String WIRELESS_LINK="wireless_link"; public static final String WIRELESS_LINK="wireless_link";
/** /**
* 框选变焦 * 框选变焦
*/ */
public static final String CAMERA_FRAME_ZOOM="camera_frame_zoom"; public static final String CAMERA_FRAME_ZOOM="camera_frame_zoom";
/**
* 急停
*/

View File

@ -88,6 +88,10 @@ public class FlightMission {
this.speed = speed; this.speed = speed;
} }
public Float getTakeOffSecurityHeight() { public Float getTakeOffSecurityHeight() {
return takeOffSecurityHeight; return takeOffSecurityHeight;
} }

View File

@ -68,7 +68,7 @@ public class MessageDown {
private int out_of_control_action; private int out_of_control_action;
private boolean takeoffToPointTask; private boolean takeoffToPointTask;
private BreakPoint break_point; private BreakPoint break_point;
private int camera_mode; private int camera_mode=0;//初始化为拍照
private String h; private String h;
private String seq; private String seq;
private String w; private String w;
@ -90,13 +90,13 @@ public class MessageDown {
private int focus_mode; private int focus_mode;
private int focus_value; private int focus_value;
private int commander_flight_height; private double commander_flight_height;
private int commander_mode_lost_action; private int commander_mode_lost_action;
private String max_speed; private String max_speed;
private int rc_lost_action; private int rc_lost_action;
private int rth_altitude; private int rth_altitude;
private String security_takeoff_height; private String security_takeoff_height;
private int target_height; private double target_height;
private double target_latitude; private double target_latitude;
private double target_longitude; private double target_longitude;
private String fly_to_id; private String fly_to_id;
@ -110,6 +110,7 @@ public class MessageDown {
private float width; private float width;
public float getWidth() { public float getWidth() {
return width; return width;
} }
@ -187,7 +188,7 @@ public class MessageDown {
this.longitude = longitude; this.longitude = longitude;
} }
} }
public int getCommander_flight_height() { public double getCommander_flight_height() {
return commander_flight_height; return commander_flight_height;
} }
@ -227,7 +228,7 @@ public class MessageDown {
this.security_takeoff_height = security_takeoff_height; this.security_takeoff_height = security_takeoff_height;
} }
public int getTarget_height() { public double getTarget_height() {
return target_height; return target_height;
} }

View File

@ -0,0 +1,135 @@
package com.aros.apron.entity;
/**
* 服务端下发的整条 JSON 对应实体
*/
public class MissionDataBean {
/** 备降点 */
private LatLngAlt alternate_land_point;
/** 指挥官飞行高度 */
private int commander_flight_height;
/** 指挥官模式丢失动作 */
private int commander_mode_lost_action;
/** 航线唯一编号 */
private String flight_id;
/** 最大飞行速度 (m/s) */
private int max_speed;
/** 遥控丢失动作 */
private int rc_lost_action;
/** 返航高度 (m) */
private int rth_altitude;
/** 安全起飞高度 (m) */
private double security_takeoff_height;
/** 目标高度 (m) */
private double target_height;
/** 目标纬度 (°) */
private double target_latitude;
/** 目标经度 (°) */
private double target_longitude;
/* ---------------- getter / setter ---------------- */
public LatLngAlt getAlternateLandPoint() {
return alternate_land_point;
}
public void setAlternateLandPoint(LatLngAlt alternate_land_point) {
this.alternate_land_point = alternate_land_point;
}
public int getCommanderFlightHeight() {
return commander_flight_height;
}
public void setCommanderFlightHeight(int commander_flight_height) {
this.commander_flight_height = commander_flight_height;
}
public int getCommanderModeLostAction() {
return commander_mode_lost_action;
}
public void setCommanderModeLostAction(int commander_mode_lost_action) {
this.commander_mode_lost_action = commander_mode_lost_action;
}
public String getFlightId() {
return flight_id;
}
public void setFlightId(String flight_id) {
this.flight_id = flight_id;
}
public int getMaxSpeed() {
return max_speed;
}
public void setMaxSpeed(int max_speed) {
this.max_speed = max_speed;
}
public int getRcLostAction() {
return rc_lost_action;
}
public void setRcLostAction(int rc_lost_action) {
this.rc_lost_action = rc_lost_action;
}
public int getRthAltitude() {
return rth_altitude;
}
public void setRthAltitude(int rth_altitude) {
this.rth_altitude = rth_altitude;
}
public double getSecurityTakeoffHeight() {
return security_takeoff_height;
}
public void setSecurityTakeoffHeight(int security_takeoff_height) {
this.security_takeoff_height = security_takeoff_height;
}
public double getTargetHeight() {
return target_height;
}
public void setTargetHeight(double target_height) {
this.target_height = target_height;
}
public double getTargetLatitude() {
return target_latitude;
}
public void setTargetLatitude(double target_latitude) {
this.target_latitude = target_latitude;
}
public double getTargetLongitude() {
return target_longitude;
}
public void setTargetLongitude(double target_longitude) {
this.target_longitude = target_longitude;
}
/* ---------------- 内部嵌套类:备降点 ---------------- */
public static class LatLngAlt {
private double latitude;
private double longitude;
private double safe_land_height;
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getSafeLandHeight() {
return safe_land_height;
}
public void setSafeLandHeight(int safe_land_height) {
this.safe_land_height = safe_land_height;
}
}
}

View File

@ -113,6 +113,8 @@ public class Movement {
private boolean virtualcontrollget=false;//是否已经获得过控制权 private boolean virtualcontrollget=false;//是否已经获得过控制权
private int GPSSatelliteCount; //卫星个数
//适配上云格式参数拿到后再进行组装 //适配上云格式参数拿到后再进行组装
private double measure_target_altitude; private double measure_target_altitude;
@ -274,6 +276,124 @@ public class Movement {
private String sdr_freq_band; private String sdr_freq_band;
private String freq_band_4g; private String freq_band_4g;
// ========== 一键起飞相关字段 ==========
private boolean takeofftopointmission;
private String takeoff_status; // task_ready/wayline_progress/wayline_ok/wayline_failed/wayline_cancel/task_finish
private int takeoff_result; // 0成功非0错误
private float takeoff_remaining_distance; // 剩余距离
private float takeoff_remaining_time; // 剩余时间
private double speed; //全局速度
private List<TakeoffToPointProgress.PlannedPathPoint> takeoff_planned_path_points; // 规划轨迹点
// ========== 上报拍照进度 ==========(全景)
private String photo_status; // in_progress/ok/fail
private int photo_current_step; // 3000/3002/3005
private int photo_percent; // 0-100
private int photo_result; // 0成功非0错误
public int getGPSSatelliteCount() {
return GPSSatelliteCount;
}
public void setGPSSatelliteCount(int GPSSatelliteCount) {
this.GPSSatelliteCount = GPSSatelliteCount;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
public boolean isTakeofftopointmission() {
return takeofftopointmission;
}
public void setTakeofftopointmission(boolean takeofftopointmission) {
this.takeofftopointmission = takeofftopointmission;
}
public int getPhoto_current_step() {
return photo_current_step;
}
public void setPhoto_current_step(int photo_current_step) {
this.photo_current_step = photo_current_step;
}
public int getPhoto_result() {
return photo_result;
}
public void setPhoto_result(int photo_result) {
this.photo_result = photo_result;
}
public String getPhoto_status() {
return photo_status;
}
public void setPhoto_status(String photo_status) {
this.photo_status = photo_status;
}
public int getPhoto_percent() {
return photo_percent;
}
public void setPhoto_percent(int photo_percent) {
this.photo_percent = photo_percent;
}
public String getTakeoff_status() {
return takeoff_status;
}
public void setTakeoff_status(String takeoff_status) {
this.takeoff_status = takeoff_status;
}
public int getTakeoff_result() {
return takeoff_result;
}
public void setTakeoff_result(int takeoff_result) {
this.takeoff_result = takeoff_result;
}
public float getTakeoff_remaining_distance() {
return takeoff_remaining_distance;
}
public void setTakeoff_remaining_distance(float takeoff_remaining_distance) {
this.takeoff_remaining_distance = takeoff_remaining_distance;
}
public float getTakeoff_remaining_time() {
return takeoff_remaining_time;
}
public void setTakeoff_remaining_time(float takeoff_remaining_time) {
this.takeoff_remaining_time = takeoff_remaining_time;
}
public List<TakeoffToPointProgress.PlannedPathPoint> getTakeoff_planned_path_points() {
return takeoff_planned_path_points;
}
public void setTakeoff_planned_path_points(List<TakeoffToPointProgress.PlannedPathPoint> takeoff_planned_path_points) {
this.takeoff_planned_path_points = takeoff_planned_path_points;
}
public boolean isVirtualcontrollget() { public boolean isVirtualcontrollget() {
return virtualcontrollget; return virtualcontrollget;
} }

View File

@ -77,7 +77,7 @@ public class Osd {
public static class Data { public static class Data {
@SerializedName("53-0-0") @SerializedName("53-0-0")
private Data._$5300 _$5300; private _$5300 _$5300;
private int activation_time; private int activation_time;
private double attitude_head; private double attitude_head;
private double attitude_pitch; private double attitude_pitch;

View File

@ -4,6 +4,8 @@ import static com.aros.apron.tools.Utils.getIDJIErrorMsg;
import static dji.sdk.keyvalue.key.KeyTools.createKey; import static dji.sdk.keyvalue.key.KeyTools.createKey;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -28,14 +30,20 @@ import dji.sdk.keyvalue.value.camera.CameraStorageInfo;
import dji.sdk.keyvalue.value.camera.CameraStorageInfos; import dji.sdk.keyvalue.value.camera.CameraStorageInfos;
import dji.sdk.keyvalue.value.camera.CameraStorageLocation; import dji.sdk.keyvalue.value.camera.CameraStorageLocation;
import dji.sdk.keyvalue.value.camera.CameraThermalPalette; import dji.sdk.keyvalue.value.camera.CameraThermalPalette;
import dji.sdk.keyvalue.value.camera.CameraType;
import dji.sdk.keyvalue.value.camera.CameraVideoStreamSourceType; import dji.sdk.keyvalue.value.camera.CameraVideoStreamSourceType;
import dji.sdk.keyvalue.value.camera.LaserMeasureInformation; import dji.sdk.keyvalue.value.camera.LaserMeasureInformation;
import dji.sdk.keyvalue.value.camera.PanoramaExitStatus;
import dji.sdk.keyvalue.value.camera.PhotoPanoStichingState;
import dji.sdk.keyvalue.value.camera.PhotoState; import dji.sdk.keyvalue.value.camera.PhotoState;
import dji.sdk.keyvalue.value.camera.RecordingState; import dji.sdk.keyvalue.value.camera.RecordingState;
import dji.sdk.keyvalue.value.camera.TapZoomMode; import dji.sdk.keyvalue.value.camera.TapZoomMode;
import dji.sdk.keyvalue.value.camera.ThermalDigitalZoomFactor;
import dji.sdk.keyvalue.value.camera.ThermalDisplayMode; import dji.sdk.keyvalue.value.camera.ThermalDisplayMode;
import dji.sdk.keyvalue.value.camera.ThermalGainMode; import dji.sdk.keyvalue.value.camera.ThermalGainMode;
import dji.sdk.keyvalue.value.camera.ThermalTemperatureMeasureMode; import dji.sdk.keyvalue.value.camera.ThermalTemperatureMeasureMode;
import dji.sdk.keyvalue.value.camera.VideoRecordingStatus;
import dji.sdk.keyvalue.value.camera.VisionPhotoPanoramaMissionState;
import dji.sdk.keyvalue.value.camera.ZoomTargetPointInfo; import dji.sdk.keyvalue.value.camera.ZoomTargetPointInfo;
import dji.sdk.keyvalue.value.common.CameraLensType; import dji.sdk.keyvalue.value.common.CameraLensType;
import dji.sdk.keyvalue.value.common.ComponentIndexType; import dji.sdk.keyvalue.value.common.ComponentIndexType;
@ -47,20 +55,53 @@ import dji.v5.common.error.IDJIError;
import dji.v5.manager.KeyManager; import dji.v5.manager.KeyManager;
public class CameraManager extends BaseManager { public class CameraManager extends BaseManager {
private Handler panoHandler = new Handler(Looper.getMainLooper());
private Runnable panoRunnable;
private boolean isPanoRunning = false;
private static final long INTERVAL = 1000; // 1秒
private void startReport() {
if (isPanoRunning) return; // 已开启则忽略
isPanoRunning = true;
panoRunnable = new Runnable() {
@Override
public void run() {
if (!isPanoRunning) return;
sendCameraPhotoTakeProgress2Server(); // 你的方法
panoHandler.postDelayed(this, INTERVAL); // 1秒后循环
}
};
panoHandler.post(panoRunnable); // 立即执行
}
private void stopReport() {
if (!isPanoRunning) return;
isPanoRunning = false;
panoHandler.removeCallbacks(panoRunnable);
sendCameraPhotoTakeProgress2Server(); // 最后报一次
}
private CameraManager() { private CameraManager() {
} }
private static class CameraHolder { private static class CameraHolder {
private static final CameraManager INSTANCE = new CameraManager(); private static final CameraManager INSTANCE = new CameraManager();
} }
public static CameraManager getInstance() { public static CameraManager getInstance() {
return CameraHolder.INSTANCE; return CameraHolder.INSTANCE;
} }
public void initCameraInfo() { public void initCameraInfo() {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.KeyConnection, ComponentIndexType.PORT_1)); Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
//全局画面中测量的最高温度 //全局画面中测量的最高温度
@ -73,6 +114,84 @@ public class CameraManager extends BaseManager {
} }
} }
}); });
//全景任务状态
KeyManager.getInstance().listen(createKey(CameraKey.KeyVisionPhotoPanoramaMissionState, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<VisionPhotoPanoramaMissionState>() {
@Override
public void onValueChange(@Nullable VisionPhotoPanoramaMissionState visionPhotoPanoramaMissionState, @Nullable VisionPhotoPanoramaMissionState t1) {
if (t1 != null) {
if (t1 == VisionPhotoPanoramaMissionState.IDLE) {
Movement.getInstance().setPhoto_current_step(3000);
} else if (t1 == VisionPhotoPanoramaMissionState.RELEASE) {
// Movement.getInstance().setPhoto_result(0);
// Movement.getInstance().setPhoto_status("ok");
// Movement.getInstance().setCameraMode(3);
// stopReport();
} else if (t1 == VisionPhotoPanoramaMissionState.RUNNING) {
Movement.getInstance().setPhoto_status("in_progress");
Movement.getInstance().setPhoto_current_step(3002);
} else if (t1 == VisionPhotoPanoramaMissionState.UNKNOWN) {
// Movement.getInstance().setPhoto_result(1);
// Movement.getInstance().setPhoto_current_step(3000);
// Movement.getInstance().setPhoto_status("fail");
} else if (t1 == VisionPhotoPanoramaMissionState.PROCESSING) {
Movement.getInstance().setPhoto_current_step(3005);
} else if (t1 == VisionPhotoPanoramaMissionState.FORBIDDEN) {
Movement.getInstance().setPhoto_result(1);
Movement.getInstance().setPhoto_current_step(3000);
Movement.getInstance().setPhoto_status("fail");
}
}
}
});
//全景退出
KeyManager.getInstance().listen(createKey(CameraKey.KeyPanoramaExitStatus, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<PanoramaExitStatus>() {
@Override
public void onValueChange(@Nullable PanoramaExitStatus panoramaExitStatus, @Nullable PanoramaExitStatus t1) {
if(t1!=null){
LogUtil.log(TAG,t1.toString());
if(t1==PanoramaExitStatus.SUCCESSFUL){
Movement.getInstance().setPhoto_current_step(3000);
Movement.getInstance().setPhoto_result(0);
Movement.getInstance().setPhoto_status("ok");
Movement.getInstance().setCameraMode(3);
Movement.getInstance().setMode_code(3);
stopReport();
}
}
}
});
KeyManager.getInstance().listen(createKey(CameraKey.KeyPanoramaProgressInPercent, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Integer>() {
@Override
public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) {
if (t1 != null) {
Movement.getInstance().setPhoto_percent(t1);
if(t1==100){
Movement.getInstance().setPhoto_current_step(3000);
Movement.getInstance().setPhoto_result(0);
Movement.getInstance().setPhoto_status("ok");
Movement.getInstance().setCameraMode(3);
Movement.getInstance().setMode_code(3);
stopReport();
}
}
}
});
//是否正在拍全景
KeyManager.getInstance().listen(createKey(CameraKey.KeyIsShootingPhotoPanorama, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Boolean>() {
@Override
public void onValueChange(@Nullable Boolean aBoolean, @Nullable Boolean t1) {
if (t1 != null) {
if (t1 == true) {
startReport();
} else {
stopReport();
}
}
}
});
//激光测距信息 //激光测距信息
KeyManager.getInstance().listen(createKey(CameraKey.KeyLaserMeasureInformation, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<LaserMeasureInformation>() { KeyManager.getInstance().listen(createKey(CameraKey.KeyLaserMeasureInformation, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<LaserMeasureInformation>() {
@Override @Override
@ -160,8 +279,8 @@ public class CameraManager extends BaseManager {
@Override @Override
public void onValueChange(@Nullable CameraMode oldValue, @Nullable CameraMode newValue) { public void onValueChange(@Nullable CameraMode oldValue, @Nullable CameraMode newValue) {
if (newValue != null) { if (newValue != null) {
Movement.getInstance().setCamera_mode(newValue.value()); //Movement.getInstance().setCamera_mode(newValue.value());
LogUtil.log(TAG, "相机模式:" + newValue + "old" + oldValue); // LogUtil.log(TAG, "相机模式:" + newValue + "old" + oldValue);
} }
} }
}); });
@ -222,7 +341,6 @@ public class CameraManager extends BaseManager {
} }
}); });
//视频录制时长 //视频录制时长
KeyManager.getInstance().listen(KeyTools.createKey(CameraKey. KeyManager.getInstance().listen(KeyTools.createKey(CameraKey.
KeyRecordingTime, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Integer>() { KeyRecordingTime, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Integer>() {
@ -233,8 +351,6 @@ public class CameraManager extends BaseManager {
} }
} }
}); });
//视频录制状态 //视频录制状态
KeyManager.getInstance().listen(KeyTools.createKey(CameraKey. KeyManager.getInstance().listen(KeyTools.createKey(CameraKey.
KeyRecordingState, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<RecordingState>() { KeyRecordingState, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<RecordingState>() {
@ -252,39 +368,53 @@ public class CameraManager extends BaseManager {
@Override @Override
public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) { public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) {
if (t1 != null) { if (t1 != null) {
LogUtil.log(TAG, "剩余拍照数setRemain_photo_num" + t1 + "old" + integer); //LogUtil.log(TAG, "剩余拍照数setRemain_photo_num" + t1 + "old" + integer);
if (t1 != 0) {
Movement.getInstance().setRemain_photo_num(t1); Movement.getInstance().setRemain_photo_num(t1);
} }
}
} }
}); });
//剩余录像时间 //剩余录像时间
KeyManager.getInstance().listen(KeyTools.createKey(CameraKey. KeyManager.getInstance().listen(KeyTools.createKey(CameraKey.
KeySSDAvailableRecordingTimeInSeconds, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Integer>() { KeyIsRecording, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Boolean>() {
@Override @Override
public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) { public void onValueChange(@Nullable Boolean aBoolean, @Nullable Boolean t1) {
if (t1 != null) { if(t1!=null){
// if(t1==true){
LogUtil.log(TAG, "剩余录像时间KeySSDAvailableRecordingTimeInSeconds" + t1 + "old" + integer); Integer recordingTime = KeyManager.getInstance().getValue(
Movement.getInstance().setRemain_record_duration(t1); KeyTools.createKey(CameraKey.KeySSDAvailableRecordingTimeInSeconds, ComponentIndexType.PORT_1)
);
LogUtil.log(TAG,"录像时间"+recordingTime);
}
} }
} }
}); });
//视频录制时长 //视频录制时长
KeyManager.getInstance().listen(KeyTools.createKey(CameraKey. KeyManager.getInstance().listen(KeyTools.createKey(CameraKey.KeyRecordingTime, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Integer>() {
KeySSDAvailableRecordingTimeInSeconds, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<Integer>() {
@Override @Override
public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) { public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) {
if (t1 != null) { if (t1 != null) {
Movement.getInstance().setRemain_record_duration(t1); Movement.getInstance().setRecord_time(t1);
}
}
});
//是否在录像
KeyManager.getInstance().listen(KeyTools.createKey(CameraKey.KeyVideoRecordingStatus, ComponentIndexType.PORT_1), this, new CommonCallbacks.KeyListener<VideoRecordingStatus>() {
@Override
public void onValueChange(@Nullable VideoRecordingStatus videoRecordingStatus, @Nullable VideoRecordingStatus t1) {
if (t1 != null) {
Boolean recording = t1.getIsRecording();
if (recording != null && recording) {
Movement.getInstance().setRecording_state(1); // 正在录
} else {
Movement.getInstance().setRecording_state(0); // 未录或未知
}
} }
} }
}); });
//分屏是否使能 //分屏是否使能
KeyManager.getInstance().listen(KeyTools.createCameraKey(CameraKey.KeyThermalDisplayMode, KeyManager.getInstance().listen(KeyTools.createCameraKey(CameraKey.KeyThermalDisplayMode,
ComponentIndexType.PORT_1, CameraLensType.CAMERA_LENS_THERMAL), this, new CommonCallbacks.KeyListener<ThermalDisplayMode>() { ComponentIndexType.PORT_1, CameraLensType.CAMERA_LENS_THERMAL), this, new CommonCallbacks.KeyListener<ThermalDisplayMode>() {
@ -302,7 +432,7 @@ public class CameraManager extends BaseManager {
@Override @Override
public void onValueChange(@Nullable CameraExposureMode cameraExposureMode, @Nullable CameraExposureMode t1) { public void onValueChange(@Nullable CameraExposureMode cameraExposureMode, @Nullable CameraExposureMode t1) {
if (t1 != null) { if (t1 != null) {
LogUtil.log(TAG, "监听曝光模式:" + t1.name()); //LogUtil.log(TAG, "监听曝光模式:" + t1.name());
Movement.getInstance().setWide_exposure_mode(t1.value()); Movement.getInstance().setWide_exposure_mode(t1.value());
} }
} }
@ -395,7 +525,15 @@ public class CameraManager extends BaseManager {
} }
} }
}); });
KeyManager.getInstance().listen(KeyTools.createCameraKey(CameraKey.KeyThermalZoomRatios,
ComponentIndexType.PORT_1, CameraLensType.CAMERA_LENS_ZOOM), this, new CommonCallbacks.KeyListener<Double>() {
@Override
public void onValueChange(@Nullable Double aDouble, @Nullable Double t1) {
if (t1 != null) {
Movement.getInstance().setZoom_factor(t1);
}
}
});
//变焦倍数 //变焦倍数
KeyManager.getInstance().listen(KeyTools.createCameraKey(CameraKey.KeyCameraZoomRatios, KeyManager.getInstance().listen(KeyTools.createCameraKey(CameraKey.KeyCameraZoomRatios,
ComponentIndexType.PORT_1, CameraLensType.CAMERA_LENS_ZOOM), this, new CommonCallbacks.KeyListener<Double>() { ComponentIndexType.PORT_1, CameraLensType.CAMERA_LENS_ZOOM), this, new CommonCallbacks.KeyListener<Double>() {
@ -506,16 +644,24 @@ public class CameraManager extends BaseManager {
} }
}); });
} }
} }
//切换相机拍照录像模式 //切换相机拍照录像模式
public void setCameraMode(MessageDown message) { public void setCameraMode(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) {
if (message != null) { if (message != null) {
int cameraMode = message.getData().getCamera_mode(); int cameraMode = message.getData().getCamera_mode();
// 新增如果当前已经是该模式直接返回成功
if (cameraMode == Movement.getInstance().getCamera_mode()) {
LogUtil.log(TAG, "相机模式已是" + cameraMode + ",无需切换");
sendMsg2Server(message);
return;
}
ProductType productType = KeyManager.getInstance().getValue(KeyTools.createKey(ProductKey.KeyProductType)); ProductType productType = KeyManager.getInstance().getValue(KeyTools.createKey(ProductKey.KeyProductType));
if (productType != null) { if (productType != null) {
int cameraModevalue = 0; int cameraModevalue = 0;
@ -526,14 +672,16 @@ public class CameraManager extends BaseManager {
} else if (cameraMode == 3) { } else if (cameraMode == 3) {
cameraModevalue = 12; cameraModevalue = 12;
} }
//设置相机模式
Movement.getInstance().setCamera_mode(cameraMode);
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraMode, ComponentIndexType.PORT_1),
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraMode, ComponentIndexType.PORT_1),
CameraMode.find(cameraModevalue), CameraMode.find(cameraModevalue),
new CommonCallbacks.CompletionCallback() { new CommonCallbacks.CompletionCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
//设置相机模式
Movement.getInstance().setCamera_mode(cameraMode);
LogUtil.log(TAG, "切换成功" + Movement.getInstance().getCamera_mode());
OSDManager.getInstance().pushFlightAttitude();
sendMsg2Server(message); sendMsg2Server(message);
} }
@ -550,10 +698,10 @@ public class CameraManager extends BaseManager {
} else { } else {
sendFailMsg2Server(message, "当前状态相机禁止操作"); sendFailMsg2Server(message, "当前状态相机禁止操作");
} }
} }
//框选变焦 //框选变焦
public void camera_frame_zoom(MessageDown message) { public void camera_frame_zoom(MessageDown message) {
//这个locked参数没有处理 //这个locked参数没有处理
//使用aim转过去 //使用aim转过去
@ -591,9 +739,9 @@ public class CameraManager extends BaseManager {
sendFailMsg2Server(message, "设置使能指点失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "设置使能指点失败:" + getIDJIErrorMsg(error));
} }
}); });
} }
private CameraLensType parseLensType1(String cameraType) { private CameraLensType parseLensType1(String cameraType) {
if (cameraType == null) return null; if (cameraType == null) return null;
if ("ir".equals(cameraType)) { if ("ir".equals(cameraType)) {
return CameraLensType.CAMERA_LENS_THERMAL; return CameraLensType.CAMERA_LENS_THERMAL;
@ -603,10 +751,10 @@ public class CameraManager extends BaseManager {
return CameraLensType.CAMERA_LENS_ZOOM; return CameraLensType.CAMERA_LENS_ZOOM;
} }
return null; return null;
} }
private void camera_frame_zoom_and_bianjiao(MessageDown message, CameraLensType type) { private void camera_frame_zoom_and_bianjiao(MessageDown message, CameraLensType type) {
ZoomTargetPointInfo info = new ZoomTargetPointInfo(); ZoomTargetPointInfo info = new ZoomTargetPointInfo();
info.setX(Double.valueOf(message.getData().getX())); info.setX(Double.valueOf(message.getData().getX()));
info.setY(Double.valueOf(message.getData().getY())); info.setY(Double.valueOf(message.getData().getY()));
@ -633,6 +781,7 @@ public class CameraManager extends BaseManager {
Double.valueOf(zoomRatio), new CommonCallbacks.CompletionCallback() { Double.valueOf(zoomRatio), new CommonCallbacks.CompletionCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
LogUtil.log(TAG, "变焦成功");
sendMsg2Server(message); sendMsg2Server(message);
} }
@ -642,14 +791,16 @@ public class CameraManager extends BaseManager {
} }
}); });
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server(message, "aim操作失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "aim操作失败:" + getIDJIErrorMsg(error));
} }
}); });
} }
//设置变焦倍率
public static double calculateZoomRatio(double width, double height) { //设置变焦倍率
public static double calculateZoomRatio(double width, double height) {
// 防呆如果传入 0 或负数返回 1 zoom // 防呆如果传入 0 或负数返回 1 zoom
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
return 1.0; return 1.0;
@ -667,9 +818,10 @@ public class CameraManager extends BaseManager {
// 限制在你的相机范围内 1x ~ 200x // 限制在你的相机范围内 1x ~ 200x
return Math.max(1.0, Math.min(200.0, zoom)); return Math.max(1.0, Math.min(200.0, zoom));
} }
//开始拍照
public void startShootPhoto(MessageDown message) { //开始拍照
public void startShootPhoto(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) {
@ -678,6 +830,7 @@ public class CameraManager extends BaseManager {
new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() { new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
LogUtil.log(TAG,"拍照成功");
sendMsg2Server(message); sendMsg2Server(message);
} }
@ -690,11 +843,11 @@ public class CameraManager extends BaseManager {
} else { } else {
sendFailMsg2Server(message, "当前状态相机禁止操作"); sendFailMsg2Server(message, "当前状态相机禁止操作");
} }
} }
//结束拍照 //结束拍照
public void stopShootPhoto(MessageDown message) { public void stopShootPhoto(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) {
@ -714,10 +867,11 @@ public class CameraManager extends BaseManager {
} else { } else {
sendFailMsg2Server(message, "当前状态相机禁止操作"); sendFailMsg2Server(message, "当前状态相机禁止操作");
} }
} }
//开始录像
public void startRecordVideo(MessageDown message) { //开始录像
public void startRecordVideo(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) {
@ -736,10 +890,10 @@ public class CameraManager extends BaseManager {
} else { } else {
sendFailMsg2Server(message, "当前状态相机禁止操作"); sendFailMsg2Server(message, "当前状态相机禁止操作");
} }
} }
//停止录像 //停止录像
public void stopRecordVideo(MessageDown message) { public void stopRecordVideo(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
@ -758,46 +912,126 @@ public class CameraManager extends BaseManager {
} else { } else {
sendFailMsg2Server(message, "当前状态相机禁止操作"); sendFailMsg2Server(message, "当前状态相机禁止操作");
} }
} }
//设置变焦倍率 // 设置变焦倍率
public void setCameraZoomRatios(MessageDown message) { public void setCameraZoomRatios(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect == null || !isConnect || !getGimbalAndCameraEnabled()) {
if (message != null) { sendFailMsg2Server(message, "当前状态相机禁止操作");
int type = 1; return;
switch (message.getData().getCamera_type()) { }
if (message == null) return;
String cameraType = message.getData().getCamera_type();
double zoomFactor = message.getData().getZoom_factor();
// 检查是否有红外H30T
CameraType cameraTypeEnum = KeyManager.getInstance().getValue(
KeyTools.createKey(CameraKey.KeyCameraType, ComponentIndexType.PORT_1));
boolean hasThermal = (cameraTypeEnum == CameraType.ZENMUSE_H30T);
// 1. 映射视频流类型和镜头类型
CameraVideoStreamSourceType streamSource;
CameraLensType lensType;
double minZoom, maxZoom;
final boolean isWide;
final boolean isIr;
switch (cameraType) {
case "ir": case "ir":
type = 3; if (!hasThermal) {
break; sendFailMsg2Server(message, "当前负载无红外功能仅H30T支持");
case "normal": return;
type = 0; }
streamSource = CameraVideoStreamSourceType.INFRARED_CAMERA;
lensType = CameraLensType.CAMERA_LENS_THERMAL;
minZoom = 2;
maxZoom = 20; // 红外 2-20倍
isWide = false;
isIr = true;
break; break;
case "wide": case "wide":
type = 1; streamSource = CameraVideoStreamSourceType.WIDE_CAMERA;
lensType = CameraLensType.CAMERA_LENS_WIDE;
minZoom = 1;
maxZoom = 1;
isWide = true;
isIr = false;
break; break;
case "zoom": case "zoom":
type = 2; streamSource = CameraVideoStreamSourceType.ZOOM_CAMERA;
lensType = CameraLensType.CAMERA_LENS_ZOOM;
minZoom = 2;
maxZoom = 200;
isWide = false;
isIr = false;
break;
default:
streamSource = CameraVideoStreamSourceType.DEFAULT_CAMERA;
lensType = CameraLensType.CAMERA_LENS_ZOOM;
minZoom = 2;
maxZoom = 200;
isWide = false;
isIr = false;
break; break;
} }
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraVideoStreamSource,
ComponentIndexType.PORT_1) // 2. 切换视频流
, CameraVideoStreamSourceType.find(type), final double finalMinZoom = minZoom;
final double finalMaxZoom = maxZoom;
KeyManager.getInstance().setValue(
KeyTools.createKey(CameraKey.KeyCameraVideoStreamSource, ComponentIndexType.PORT_1),
streamSource,
new CommonCallbacks.CompletionCallback() { new CommonCallbacks.CompletionCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
new Handler().postDelayed(new Runnable() { // 广角不设置变焦
@Override if (isWide) {
public void run() { LogUtil.log(TAG, "广角切换成功,无需设置变焦");
int cameraZoomRatios = message.getData().getZoom_factor(); Movement.getInstance().setZoom_factor(1);
KeyManager.getInstance().setValue(KeyTools.createCameraKey(CameraKey.KeyCameraZoomRatios, sendMsg2Server(message);
ComponentIndexType.PORT_1, CameraLensType.CAMERA_LENS_ZOOM), return;
Double.valueOf(cameraZoomRatios), new CommonCallbacks.CompletionCallback() { }
// 强制截断变焦范围
final double validZoom = Math.max(finalMinZoom, Math.min(finalMaxZoom, zoomFactor));
new Handler(Looper.getMainLooper()).postDelayed(() -> {
if (isIr) {
KeyManager.getInstance().setValue(
KeyTools.createCameraKey(CameraKey.KeyThermalZoomRatios,
ComponentIndexType.PORT_1, lensType),
validZoom,
new CommonCallbacks.CompletionCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
Movement.getInstance().setZoom_factor(cameraZoomRatios); LogUtil.log(TAG, "红外变焦成功: " + validZoom);
Movement.getInstance().setZoom_factor((int) validZoom);
sendMsg2Server(message);
}
@Override
public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server(message, "红外变焦失败:" + getIDJIErrorMsg(error));
}
}
);
} else {
// 可见光变焦
KeyManager.getInstance().setValue(
KeyTools.createCameraKey(CameraKey.KeyCameraZoomRatios,
ComponentIndexType.PORT_1, lensType),
validZoom,
new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
LogUtil.log(TAG, "变焦成功: " + cameraType + "=" + validZoom);
Movement.getInstance().setZoom_factor((int) validZoom);
sendMsg2Server(message); sendMsg2Server(message);
} }
@ -805,7 +1039,8 @@ public class CameraManager extends BaseManager {
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server(message, "设置变焦倍率失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "设置变焦倍率失败:" + getIDJIErrorMsg(error));
} }
}); }
);
} }
}, 200); }, 200);
} }
@ -814,13 +1049,30 @@ public class CameraManager extends BaseManager {
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server(message, "切换相机视频流失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "切换相机视频流失败:" + getIDJIErrorMsg(error));
} }
});
} else {
sendFailMsg2Server(message, "当前状态相机禁止操作");
}
}
} }
);
}
// private void setstepThermalZoomRatios(){
// KeyManager.getInstance().setValue(
// KeyTools.createKey(CameraKey.KeyThermalDigitalZoomFactor, ComponentIndexType.PORT_1),
// ThermalDigitalZoomFactor.FACTOR_X2,
// new CommonCallbacks.CompletionCallback() {
// @Override
// public void onSuccess() {
// //
// LogUtil.log(TAG,"设置红外步长为2x");
// }
// //
// @Override
// public void onFailure(@NonNull IDJIError idjiError) {
// LogUtil.log(TAG,"设置红外步长为1x失败"+idjiError);
//
// }
// }
// );
// }
// //设置红外变焦倍率(支持1x2x4x8x变焦倍率) // //设置红外变焦倍率(支持1x2x4x8x变焦倍率)
// public void setThermalZoomRatios(MQMessage message) { // public void setThermalZoomRatios(MQMessage message) {
// Boolean isConnect =KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. // Boolean isConnect =KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
@ -848,8 +1100,8 @@ public class CameraManager extends BaseManager {
// } // }
// } // }
//切换广角变焦红外 //切换广角变焦红外
public void setCameraVideoStreamSource(MessageDown message) { public void setCameraVideoStreamSource(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) {
@ -906,7 +1158,7 @@ public class CameraManager extends BaseManager {
sendFailMsg2Server(message, "当前状态相机禁止操作"); sendFailMsg2Server(message, "当前状态相机禁止操作");
} }
} }
// //设置红外镜头的显示模式 // //设置红外镜头的显示模式
// public void setThermalDisplayMode(MQMessage message) { // public void setThermalDisplayMode(MQMessage message) {
@ -961,7 +1213,7 @@ public class CameraManager extends BaseManager {
// //
// //
/// /设置对焦模式 /// /设置对焦模式
//public void setCameraFocusMode(MQMessage message) { //public void setCameraFocusMode(MQMessage message) {
// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. // Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
// KeyConnection,ComponentIndexType.PORT_1)); // KeyConnection,ComponentIndexType.PORT_1));
@ -989,8 +1241,8 @@ public class CameraManager extends BaseManager {
// } // }
//} //}
// //
//格式化SD卡 //格式化SD卡
public void formatStorage(MessageDown message) { public void formatStorage(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) { if (isConnect != null && isConnect && getGimbalAndCameraEnabled()) {
@ -1095,10 +1347,10 @@ public class CameraManager extends BaseManager {
// } // }
//} //}
// //
} }
//指点对焦 //指点对焦
public void tapZoomAtTarget(MessageDown message) { public void tapZoomAtTarget(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey( Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(
CameraKey.KeyConnection, ComponentIndexType.PORT_1)); CameraKey.KeyConnection, ComponentIndexType.PORT_1));
// //
@ -1131,9 +1383,9 @@ public class CameraManager extends BaseManager {
sendFailMsg2Server(message, "设置使能指点失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "设置使能指点失败:" + getIDJIErrorMsg(error));
} }
}); });
} }
private void performTapZoom(MessageDown message, CameraLensType type) { private void performTapZoom(MessageDown message, CameraLensType type) {
ZoomTargetPointInfo info = new ZoomTargetPointInfo(); ZoomTargetPointInfo info = new ZoomTargetPointInfo();
info.setX(Double.valueOf(message.getData().getX())); info.setX(Double.valueOf(message.getData().getX()));
info.setY(Double.valueOf(message.getData().getY())); info.setY(Double.valueOf(message.getData().getY()));
@ -1156,9 +1408,9 @@ public class CameraManager extends BaseManager {
sendFailMsg2Server(message, "指点变焦失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "指点变焦失败:" + getIDJIErrorMsg(error));
} }
}); });
} }
private CameraLensType parseLensType(String cameraType) { private CameraLensType parseLensType(String cameraType) {
if (cameraType == null) return null; if (cameraType == null) return null;
if ("ir".equals(cameraType)) { if ("ir".equals(cameraType)) {
return CameraLensType.CAMERA_LENS_THERMAL; return CameraLensType.CAMERA_LENS_THERMAL;
@ -1168,11 +1420,11 @@ public class CameraManager extends BaseManager {
return CameraLensType.CAMERA_LENS_ZOOM; return CameraLensType.CAMERA_LENS_ZOOM;
} }
return null; return null;
} }
//切换为广角镜头降低曝光率 //切换为广角镜头降低曝光率
public void resumeLensToWideISOManual() { public void resumeLensToWideISOManual() {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(CameraKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
@ -1193,7 +1445,7 @@ public class CameraManager extends BaseManager {
} else { } else {
LogUtil.log(TAG, "降落切换广角失败:当前状态相机禁止操作"); LogUtil.log(TAG, "降落切换广角失败:当前状态相机禁止操作");
} }
} }
// //设置自定义文件后缀 // //设置自定义文件后缀
// public void setCustomExpandNameSetting() { // public void setCustomExpandNameSetting() {

View File

@ -7,8 +7,10 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.aros.apron.base.BaseManager; import com.aros.apron.base.BaseManager;
import com.aros.apron.constant.AMSConfig; import com.aros.apron.constant.AMSConfig;
import com.aros.apron.entity.ApronExecutionStatus; import com.aros.apron.entity.ApronExecutionStatus;
@ -22,8 +24,11 @@ import com.aros.apron.tools.LogUtil;
import com.aros.apron.tools.MqttManager; import com.aros.apron.tools.MqttManager;
import com.aros.apron.tools.PreferenceUtils; import com.aros.apron.tools.PreferenceUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import java.util.List; import java.util.List;
import dji.sdk.keyvalue.key.AirLinkKey; import dji.sdk.keyvalue.key.AirLinkKey;
import dji.sdk.keyvalue.key.FlightControllerKey; import dji.sdk.keyvalue.key.FlightControllerKey;
import dji.sdk.keyvalue.key.KeyTools; import dji.sdk.keyvalue.key.KeyTools;
@ -93,7 +98,7 @@ public class FlightManager extends BaseManager {
if (newValue != null) { if (newValue != null) {
if (!newValue) { if (!newValue) {
LogUtil.log(TAG,"遥控器断开连接"); LogUtil.log(TAG, "遥控器断开连接");
// 飞机未连接时设置未连接状态 // 飞机未连接时设置未连接状态
Movement.getInstance().setMode_code(14); Movement.getInstance().setMode_code(14);
OSDManager.getInstance().pushFlightAttitude(); OSDManager.getInstance().pushFlightAttitude();
@ -101,10 +106,9 @@ public class FlightManager extends BaseManager {
Movement.getInstance().setMissionFinish(true); Movement.getInstance().setMissionFinish(true);
}else{ } else {
LogUtil.log(TAG, "setMode_code1(0)");
LogUtil.log(TAG,"setMode_code1(0)");
//连上就待机 //连上就待机
Movement.getInstance().setMissionFinish(false); Movement.getInstance().setMissionFinish(false);
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
@ -114,14 +118,13 @@ public class FlightManager extends BaseManager {
} }
}); });
//重新复制一下如果一直断开这个回调会不执行 //重新复制一下如果一直断开这个回调会不执行
if(isConnect){ if (isConnect) {
LogUtil.log(TAG,"setMode_code2(0)"); LogUtil.log(TAG, "setMode_code2(0)");
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
}else{ } else {
Movement.getInstance().setMode_code(14); Movement.getInstance().setMode_code(14);
} }
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
if (!TextUtils.isEmpty(PreferenceUtils.getInstance().getAlternatePointLon()) if (!TextUtils.isEmpty(PreferenceUtils.getInstance().getAlternatePointLon())
@ -131,10 +134,12 @@ public class FlightManager extends BaseManager {
} }
iDeviceStatusManager = dji.v5.manager.diagnostic.DeviceStatusManager.getInstance(); iDeviceStatusManager = dji.v5.manager.diagnostic.DeviceStatusManager.getInstance();
LogUtil.log(TAG,"iDeviceStatusManager"+"设置成功");
iDeviceStatusManager.addDJIDeviceStatusChangeListener(new DJIDeviceStatusChangeListener() { iDeviceStatusManager.addDJIDeviceStatusChangeListener(new DJIDeviceStatusChangeListener() {
@Override @Override
public void onDeviceStatusUpdate(DJIDeviceStatus from, DJIDeviceStatus to) { public void onDeviceStatusUpdate(DJIDeviceStatus from, DJIDeviceStatus to) {
if (to != null && !TextUtils.isEmpty(to.description())) { if (to != null && !TextUtils.isEmpty(to.description())) {
LogUtil.log(TAG,"setPlaneMessage"+to.description());
Movement.getInstance().setPlaneMessage(to.description()); Movement.getInstance().setPlaneMessage(to.description());
pushFlightAttitude(); pushFlightAttitude();
} }
@ -147,11 +152,11 @@ public class FlightManager extends BaseManager {
@Override @Override
public void onUpdate(@NonNull PerceptionInfo information) { public void onUpdate(@NonNull PerceptionInfo information) {
if (information != null) { if (information != null) {
if (information.getDownwardObstacleAvoidanceWorking()!=null){ if (information.getDownwardObstacleAvoidanceWorking() != null) {
Movement.getInstance().setDownside(information.getDownwardObstacleAvoidanceWorking() ? 1 : 0); Movement.getInstance().setDownside(information.getDownwardObstacleAvoidanceWorking() ? 1 : 0);
} }
Movement.getInstance().setHorizon(information.isHorizontalObstacleAvoidanceEnabled() ? 1 : 0); Movement.getInstance().setHorizon(information.isHorizontalObstacleAvoidanceEnabled() ? 1 : 0);
if (information.getUpwardObstacleAvoidanceWorking()!=null){ if (information.getUpwardObstacleAvoidanceWorking() != null) {
Movement.getInstance().setUpside(information.getUpwardObstacleAvoidanceWorking() ? 1 : 0); Movement.getInstance().setUpside(information.getUpwardObstacleAvoidanceWorking() ? 1 : 0);
} }
pushFlightAttitude(); pushFlightAttitude();
@ -187,13 +192,13 @@ public class FlightManager extends BaseManager {
ApronExecutionStatus.getInstance().setAircraftWaitShutDown(false); ApronExecutionStatus.getInstance().setAircraftWaitShutDown(false);
//起飞了这个状态就看这里 //起飞了这个状态就看这里
if(Movement.getInstance().getFlightmode()==1){ if (Movement.getInstance().getFlightmode() == 1) {
Movement.getInstance().setMode_code(5); Movement.getInstance().setMode_code(5);
}else if(Movement.getInstance().getFlightmode()==2){ } else if (Movement.getInstance().getFlightmode() == 2) {
Movement.getInstance().setMode_code(17); Movement.getInstance().setMode_code(17);
} }
}else{ } else {
LogUtil.log(TAG,"setMode_code3(0)"); LogUtil.log(TAG, "setMode_code3(0)");
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); OSDManager.getInstance().pushFlightAttitude();
@ -204,7 +209,6 @@ public class FlightManager extends BaseManager {
pushFlightAttitude(); pushFlightAttitude();
} }
} }
}); });
@ -214,7 +218,7 @@ public class FlightManager extends BaseManager {
public void onValueChange(@Nullable Boolean oldValue, @Nullable Boolean newValue) { public void onValueChange(@Nullable Boolean oldValue, @Nullable Boolean newValue) {
if (newValue != null) { if (newValue != null) {
if(newValue==false){ if (newValue == false) {
//电机不转待机 //电机不转待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); OSDManager.getInstance().pushFlightAttitude();
@ -227,7 +231,6 @@ public class FlightManager extends BaseManager {
} }
}); });
//挡位 //挡位
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyRemoteControllerFlightMode), this, new CommonCallbacks.KeyListener<RemoteControllerFlightMode>() { KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyRemoteControllerFlightMode), this, new CommonCallbacks.KeyListener<RemoteControllerFlightMode>() {
@Override @Override
@ -238,7 +241,6 @@ public class FlightManager extends BaseManager {
} }
} }
}); });
KeyManager.getInstance().listen(KeyTools.createKey(ProductKey.KeyProductType), this, new CommonCallbacks.KeyListener<ProductType>() { KeyManager.getInstance().listen(KeyTools.createKey(ProductKey.KeyProductType), this, new CommonCallbacks.KeyListener<ProductType>() {
@Override @Override
public void onValueChange(@Nullable ProductType productType, @Nullable ProductType t1) { public void onValueChange(@Nullable ProductType productType, @Nullable ProductType t1) {
@ -248,7 +250,6 @@ public class FlightManager extends BaseManager {
} }
} }
}); });
//飞机SN号 //飞机SN号
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeySerialNumber), this, new CommonCallbacks.KeyListener<String>() { KeyManager.getInstance().listen(createKey(FlightControllerKey.KeySerialNumber), this, new CommonCallbacks.KeyListener<String>() {
@Override @Override
@ -259,7 +260,6 @@ public class FlightManager extends BaseManager {
} }
} }
}); });
//RID状态 //RID状态
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyRidWorkingStatusPush), this, new CommonCallbacks.KeyListener<RidWorkingStatusPushMsg>() { KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyRidWorkingStatusPush), this, new CommonCallbacks.KeyListener<RidWorkingStatusPushMsg>() {
@Override @Override
@ -271,7 +271,6 @@ public class FlightManager extends BaseManager {
} }
} }
}); });
//rtk起飞高度(计算海拔高度使用) //rtk起飞高度(计算海拔高度使用)
KeyManager.getInstance().listen(createKey(RtkMobileStationKey.KeyRTKTakeoffAltitudeInfo), this, new CommonCallbacks.KeyListener<RTKTakeoffAltitudeInfo>() { KeyManager.getInstance().listen(createKey(RtkMobileStationKey.KeyRTKTakeoffAltitudeInfo), this, new CommonCallbacks.KeyListener<RTKTakeoffAltitudeInfo>() {
@Override @Override
@ -305,10 +304,20 @@ public class FlightManager extends BaseManager {
Movement.getInstance().setLatitude(newValue.getLatitude()); Movement.getInstance().setLatitude(newValue.getLatitude());
Movement.getInstance().setLongitude(newValue.getLongitude()); Movement.getInstance().setLongitude(newValue.getLongitude());
pushFlightAttitude(); pushFlightAttitude();
} }
} }
}); });
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyAircraftVelocity), this, new CommonCallbacks.KeyListener<Velocity3D>() {
@Override
public void onValueChange(@Nullable Velocity3D velocity3D, @Nullable Velocity3D t1) {
}
});
//水平&垂直速度 //水平&垂直速度
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyAircraftVelocity), this, new CommonCallbacks.KeyListener<Velocity3D>() { KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyAircraftVelocity), this, new CommonCallbacks.KeyListener<Velocity3D>() {
@Override @Override
@ -338,6 +347,17 @@ public class FlightManager extends BaseManager {
} }
}); });
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyGPSSatelliteCount), this, new CommonCallbacks.KeyListener<Integer>() {
@Override
public void onValueChange(@Nullable Integer integer, @Nullable Integer t1) {
if(t1!=null){
Movement.getInstance().setGPSSatelliteCount(t1);
}
}
});
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyGPSSignalLevel), this, new CommonCallbacks.KeyListener<GPSSignalLevel>() { KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyGPSSignalLevel), this, new CommonCallbacks.KeyListener<GPSSignalLevel>() {
@Override @Override
public void onValueChange(@Nullable GPSSignalLevel gpsSignalLevel, @Nullable GPSSignalLevel t1) { public void onValueChange(@Nullable GPSSignalLevel gpsSignalLevel, @Nullable GPSSignalLevel t1) {
@ -385,7 +405,7 @@ public class FlightManager extends BaseManager {
KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyWindDirection), this, new CommonCallbacks.KeyListener<WindDirection>() { KeyManager.getInstance().listen(createKey(FlightControllerKey.KeyWindDirection), this, new CommonCallbacks.KeyListener<WindDirection>() {
@Override @Override
public void onValueChange(@Nullable WindDirection windDirection, @Nullable WindDirection t1) { public void onValueChange(@Nullable WindDirection windDirection, @Nullable WindDirection t1) {
if (t1!=null){ if (t1 != null) {
Movement.getInstance().setWind_direction(t1.value()); Movement.getInstance().setWind_direction(t1.value());
pushFlightAttitude(); pushFlightAttitude();
} }
@ -429,7 +449,7 @@ public class FlightManager extends BaseManager {
Movement.getInstance().setPlaneMode(newValue.name()); Movement.getInstance().setPlaneMode(newValue.name());
pushFlightAttitude(); pushFlightAttitude();
switch (newValue){ switch (newValue) {
case TAKE_OFF_READY: case TAKE_OFF_READY:
//Movement.getInstance().setMode_code(2); //Movement.getInstance().setMode_code(2);
break; break;
@ -732,7 +752,7 @@ public class FlightManager extends BaseManager {
//开舱门 //开舱门
openCabinDoor(); openCabinDoor();
//降落时将云台朝下 //降落时将云台朝下
//gimbalDownwards(); gimbalDownwards();
//返航时将云台归中,曝光ISO降低 //返航时将云台归中,曝光ISO降低
//gimbalAndCameraReset(); //gimbalAndCameraReset();
//开始视觉识别降落 //开始视觉识别降落
@ -744,8 +764,9 @@ public class FlightManager extends BaseManager {
//(决定飞机触发电量低的返航) //(决定飞机触发电量低的返航)
public boolean isTriggerRoomBattrryLanding; public boolean isTriggerRoomBattrryLanding;
private void batteryLowLanding() { private void batteryLowLanding() {
if (isTriggerRoomBattrryLanding){ if (isTriggerRoomBattrryLanding) {
return; return;
} }
int forcedBattery = Integer.valueOf(PreferenceUtils.getInstance().getForcedBattery()); int forcedBattery = Integer.valueOf(PreferenceUtils.getInstance().getForcedBattery());
@ -754,23 +775,23 @@ public class FlightManager extends BaseManager {
String missionState = Movement.getInstance().getWaypointMissionExecuteState(); String missionState = Movement.getInstance().getWaypointMissionExecuteState();
boolean isMissionExecuting = (!TextUtils.isEmpty(missionState) && boolean isMissionExecuting = (!TextUtils.isEmpty(missionState) &&
(missionState.equals("EXECUTING") || missionState.equals("ENTER_WAYLINE")) (missionState.equals("EXECUTING") || missionState.equals("ENTER_WAYLINE"))
||(!TextUtils.isEmpty(Movement.getInstance().getPlaneMode()) || (!TextUtils.isEmpty(Movement.getInstance().getPlaneMode())
&&Movement.getInstance().getPlaneMode().equals("WAYPOINT"))); && Movement.getInstance().getPlaneMode().equals("WAYPOINT")));
// 获取飞行状态和航线状态 // 获取飞行状态和航线状态
boolean isFlyingAndBatteryOk = isFlying &&value!=null&&value< forcedBattery&&isMissionExecuting; boolean isFlyingAndBatteryOk = isFlying && value != null && value < forcedBattery && isMissionExecuting;
boolean isAlterLandStatus=(PreferenceUtils.getInstance().getNeedTriggerAlterArucoLand()||PreferenceUtils.getInstance().getTriggerToAlternatePoint()); boolean isAlterLandStatus = (PreferenceUtils.getInstance().getNeedTriggerAlterArucoLand() || PreferenceUtils.getInstance().getTriggerToAlternatePoint());
if (isFlyingAndBatteryOk&& !isTriggerRoomBattrryLanding&&!isAlterLandStatus) { if (isFlyingAndBatteryOk && !isTriggerRoomBattrryLanding && !isAlterLandStatus) {
isTriggerRoomBattrryLanding = true; isTriggerRoomBattrryLanding = true;
KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStartGoHome), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() { KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStartGoHome), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
sendEvent2Server("电量低于阈值,强制返航",2); sendEvent2Server("电量低于阈值,强制返航", 2);
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendEvent2Server("电量低于阈值,返航失败",2); sendEvent2Server("电量低于阈值,返航失败", 2);
} }
}); });
@ -820,16 +841,15 @@ public class FlightManager extends BaseManager {
//降落时将云台朝下 //降落时将云台朝下
private void gimbalDownwards() { private void gimbalDownwards() {
if (goHomeExecutionState == GoHomeState.LANDING.value() if (goHomeExecutionState == GoHomeState.LANDING.value()
&& Movement.getInstance().getElevation() > 11 && Movement.getInstance().getElevation() > 11) {
&& !isGimbalDownwards) { // DroneHelper.getInstance().setGimbalPitchDegree();
DroneHelper.getInstance().setGimbalPitchDegree(); // //将镜头设置为自动对焦
//将镜头设置为自动对焦 // DroneHelper.getInstance().setCameraFocusMode();
DroneHelper.getInstance().setCameraFocusMode(); // isGimbalDownwards = true;
isGimbalDownwards = true;
PerceptionManager.getInstance().setPerceptionEnable(false); PerceptionManager.getInstance().setPerceptionEnable(false);
if (Movement.getInstance().getIsRecording()==1){ // if (Movement.getInstance().getIsRecording() == 1) {
CameraManager.getInstance().stopRecordVideo(null); // CameraManager.getInstance().stopRecordVideo(null);
} // }
} }
} }
@ -860,9 +880,7 @@ public class FlightManager extends BaseManager {
} }
private static final double FLYING_HEIGHT_THRESHOLD_MAX = 5.5;
private static final double FLYING_HEIGHT_THRESHOLD_MAX = 5;
private static final double FLYING_HEIGHT_THRESHOLD_MAX_ALTERNATE = 10; private static final double FLYING_HEIGHT_THRESHOLD_MAX_ALTERNATE = 10;
private static final double FLYING_HEIGHT_THRESHOLD_MIN = -2; private static final double FLYING_HEIGHT_THRESHOLD_MIN = -2;
private static final double FLYING_HEIGHT_THRESHOLD_MIN_ALTERNATE = 2.0; private static final double FLYING_HEIGHT_THRESHOLD_MIN_ALTERNATE = 2.0;
@ -907,17 +925,17 @@ public class FlightManager extends BaseManager {
PreferenceUtils.getInstance().setNeedTriggerAlterArucoLand(true); PreferenceUtils.getInstance().setNeedTriggerAlterArucoLand(true);
PreferenceUtils.getInstance().setNeedTriggerApronArucoLand(false); PreferenceUtils.getInstance().setNeedTriggerApronArucoLand(false);
LogUtil.log(TAG, "开始识别备降点二维码,椭球高度:" + Movement.getInstance().getElevation() + "" + "--超声波高度:" + Movement.getInstance().getUltrasonicHeight() + "分米"); LogUtil.log(TAG, "开始识别备降点二维码,椭球高度:" + Movement.getInstance().getElevation() + "" + "--超声波高度:" + Movement.getInstance().getUltrasonicHeight() + "分米");
sendEvent2Server("开始备降点视觉降落",1); sendEvent2Server("开始备降点视觉降落", 1);
} else { } else {
LogUtil.log(TAG, "识别ApronTag:" + PreferenceUtils.getInstance().getNeedTriggerApronArucoLand()); LogUtil.log(TAG, "识别ApronTag:" + PreferenceUtils.getInstance().getNeedTriggerApronArucoLand());
EventBus.getDefault().post(FLAG_START_DETECT_ARUCO_APRON); EventBus.getDefault().post(FLAG_START_DETECT_ARUCO_APRON);
PreferenceUtils.getInstance().setNeedTriggerAlterArucoLand(false); PreferenceUtils.getInstance().setNeedTriggerAlterArucoLand(false);
PreferenceUtils.getInstance().setNeedTriggerApronArucoLand(true); PreferenceUtils.getInstance().setNeedTriggerApronArucoLand(true);
LogUtil.log(TAG, "开始识别机库二维码,椭球高度:" + Movement.getInstance().getElevation() + "" + "--超声波高度:" + Movement.getInstance().getUltrasonicHeight() + "分米"); LogUtil.log(TAG, "开始识别机库二维码,椭球高度:" + Movement.getInstance().getElevation() + "" + "--超声波高度:" + Movement.getInstance().getUltrasonicHeight() + "分米");
sendEvent2Server("开始视觉降落",1); sendEvent2Server("开始视觉降落", 1);
} }
isSendDetect = true; isSendDetect = true;
PerceptionManager.getInstance().setPerceptionEnable(false); //PerceptionManager.getInstance().setPerceptionEnable(false);
} }
@ -966,7 +984,7 @@ public class FlightManager extends BaseManager {
return !isTriggerLanding && (isFlying || isMotorsOn) && AlternateArucoDetect.getInstance().isCanLanding(); return !isTriggerLanding && (isFlying || isMotorsOn) && AlternateArucoDetect.getInstance().isCanLanding();
} else { } else {
return !isTriggerLanding && (isFlying || isMotorsOn) && ( return !isTriggerLanding && (isFlying || isMotorsOn) && (
ApronArucoDetect.getInstance().isCanLanding()|| (ApronArucoDetect.getInstance().isStartFastStick() ApronArucoDetect.getInstance().isCanLanding() || (ApronArucoDetect.getInstance().isStartFastStick()
&& ApronArucoDetect.getInstance().getCheckThrowingErrorsTimes() > 100)); && ApronArucoDetect.getInstance().getCheckThrowingErrorsTimes() > 100));
} }
} }
@ -996,7 +1014,7 @@ public class FlightManager extends BaseManager {
if (!PreferenceUtils.getInstance().getNeedTriggerAlterArucoLand()) { if (!PreferenceUtils.getInstance().getNeedTriggerAlterArucoLand()) {
// 发送无人机入库消息到服务器********************待修改************************ // 发送无人机入库消息到服务器********************待修改************************
ApronExecutionStatus.getInstance().setAircraftWaitShutDown(false); ApronExecutionStatus.getInstance().setAircraftWaitShutDown(false);
DockStorageManager.getInstance().sendDockStorageMsg2Server( ); DockStorageManager.getInstance().sendDockStorageMsg2Server();
} }
// 上传媒体文件 // 上传媒体文件
SystemManager.getInstance().upLoadMedia(MqttManager.getInstance().mqttAndroidClient); SystemManager.getInstance().upLoadMedia(MqttManager.getInstance().mqttAndroidClient);
@ -1015,7 +1033,7 @@ public class FlightManager extends BaseManager {
Movement.getInstance().setMissionFinish1(true); Movement.getInstance().setMissionFinish1(true);
Movement.getInstance().setTask_current_step(25); Movement.getInstance().setTask_current_step(25);
sendOpenCabinDoorMsg=false; sendOpenCabinDoorMsg = false;
} }
} }
@ -1035,15 +1053,16 @@ public class FlightManager extends BaseManager {
KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStartGoHome), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() { KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStartGoHome), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
sendMsg2Server( message); sendMsg2Server(message);
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server( message, "返航执行失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "返航执行失败:" + getIDJIErrorMsg(error));
} }
}); });
} else { } else {
sendFailMsg2Server( message, "返航执行失败:飞控未连接"); sendFailMsg2Server(message, "返航执行失败:飞控未连接");
} }
} }
@ -1058,22 +1077,21 @@ public class FlightManager extends BaseManager {
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
//只有在取消返航时才能显示取消返航失败 //只有在取消返航时才能显示取消返航失败
Movement.getInstance().setMode_code(3); Movement.getInstance().setMode_code(3);
sendMsg2Server( message); sendMsg2Server(message);
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
LogUtil.log(TAG,"取消返航执行失败"+error); LogUtil.log(TAG, "取消返航执行失败" + error);
sendFailMsg2Server( message, "取消返航执行失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "取消返航执行失败:" + getIDJIErrorMsg(error));
} }
}); });
} else { } else {
sendFailMsg2Server( message, "飞控未连接"); sendFailMsg2Server(message, "飞控未连接");
} }
} }
private void resetAircrftLandingStatus() { private void resetAircrftLandingStatus() {
// 避免在下次起飞时触发视觉识别 // 避免在下次起飞时触发视觉识别
PreferenceUtils.getInstance().setNeedTriggerApronArucoLand(false); PreferenceUtils.getInstance().setNeedTriggerApronArucoLand(false);
@ -1133,21 +1151,21 @@ public class FlightManager extends BaseManager {
KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStartAutoLanding), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() { KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStartAutoLanding), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
if (message!=null){ if (message != null) {
sendMsg2Server( message); sendMsg2Server(message);
} }
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
LogUtil.log(TAG, "降落失败:" + new Gson().toJson(error)); LogUtil.log(TAG, "降落失败:" + new Gson().toJson(error));
if (message!=null){ if (message != null) {
sendFailMsg2Server( message, "降落失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "降落失败:" + getIDJIErrorMsg(error));
} }
} }
}); });
} else { } else {
sendFailMsg2Server( message, "飞控未连接"); sendFailMsg2Server(message, "飞控未连接");
} }
} }
@ -1155,6 +1173,7 @@ public class FlightManager extends BaseManager {
* 紧急悬停 * 紧急悬停
*/ */
public void emergencyHover(MessageDown message) { public void emergencyHover(MessageDown message) {
FlightMode flightMode = KeyManager.getInstance().getValue(createKey(FlightControllerKey.KeyFlightMode)); FlightMode flightMode = KeyManager.getInstance().getValue(createKey(FlightControllerKey.KeyFlightMode));
if (flightMode != null) { if (flightMode != null) {
switch (flightMode) { switch (flightMode) {
@ -1163,14 +1182,13 @@ public class FlightManager extends BaseManager {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
LogUtil.log(TAG, "紧急悬停,取消返航成功"); LogUtil.log(TAG, "紧急悬停,取消返航成功");
sendMsg2Server( message); sendMsg2Server(message);
resetAircrftLandingStatus(); resetAircrftLandingStatus();
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server( message, "紧急悬停,取消返航失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "紧急悬停,取消返航失败:" + getIDJIErrorMsg(error));
} }
}); });
break; break;
@ -1181,14 +1199,14 @@ public class FlightManager extends BaseManager {
@Override @Override
public void onSuccess() { public void onSuccess() {
LogUtil.log(TAG, "紧急悬停,终止任务成功"); LogUtil.log(TAG, "紧急悬停,终止任务成功");
sendMsg2Server( message); sendMsg2Server(message);
resetAircrftLandingStatus(); resetAircrftLandingStatus();
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server( message, "紧急悬停,终止任务失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "紧急悬停,终止任务失败:" + getIDJIErrorMsg(error));
} }
}); });
break; break;
@ -1196,7 +1214,7 @@ public class FlightManager extends BaseManager {
KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStopAutoLanding), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() { KeyManager.getInstance().performAction(createKey(FlightControllerKey.KeyStopAutoLanding), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
sendMsg2Server( message); sendMsg2Server(message);
resetAircrftLandingStatus(); resetAircrftLandingStatus();
} }
@ -1204,7 +1222,7 @@ public class FlightManager extends BaseManager {
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
LogUtil.log(TAG, "紧急悬停,取消降落失败:" + new Gson().toJson(error)); LogUtil.log(TAG, "紧急悬停,取消降落失败:" + new Gson().toJson(error));
sendFailMsg2Server( message, "紧急悬停,取消降落失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "紧急悬停,取消降落失败:" + getIDJIErrorMsg(error));
} }
}); });
break; break;
@ -1213,19 +1231,52 @@ public class FlightManager extends BaseManager {
@Override @Override
public void onSuccess() { public void onSuccess() {
LogUtil.log(TAG, "紧急悬停,控制权释放成功"); LogUtil.log(TAG, "紧急悬停,控制权释放成功");
sendMsg2Server( message); sendMsg2Server(message);
resetAircrftLandingStatus(); resetAircrftLandingStatus();
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server( message, "紧急悬停,控制权失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "紧急悬停,控制权失败:" + getIDJIErrorMsg(error));
} }
}); });
break; break;
} }
} }
if (Movement.getInstance().isOpendrc() == true) {
//直接关闭虚拟摇杆
VirtualStickManager.getInstance().disableVirtualStick(new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
LogUtil.log(TAG, "紧急悬停,控制权释放成功");
sendMsg2Server(message);
resetAircrftLandingStatus();
Movement.getInstance().setOpendrc(false);
} }
@Override
public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server(message, "紧急悬停,控制权失败:" + getIDJIErrorMsg(error));
}
});
}
VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true);
VirtualStickManager.getInstance().enableVirtualStick(new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
LogUtil.log(TAG, "紧急悬停获得控制权成功");
sendMsg2Server(message);
resetAircrftLandingStatus();
Movement.getInstance().setOpendrc(true);
Movement.getInstance().setMode_code(3);
OSDManager.getInstance().pushFlightAttitude();
}
@Override
public void onFailure(@NonNull IDJIError error) {
sendFailMsg2Server(message, "紧急悬停获得控制权失败" + getIDJIErrorMsg(error));
}
});
}
} }

View File

@ -38,20 +38,15 @@ public class FlightTaskProgressManager extends BaseManager {
// sendFlightTaskProgress2Server(); // sendFlightTaskProgress2Server();
// //
// } // }
//只要一个满足就上报 //只要一个满足就上报
if (Movement.getInstance().isPlaneWing() || Movement.getInstance().isMotorsOn()) { if (Movement.getInstance().isPlaneWing() || Movement.getInstance().isMotorsOn()) {
sendFlightTaskProgress2Server(); sendFlightTaskProgress2Server();
} }
if (Movement.getInstance().isMissionFinish1()) { if (Movement.getInstance().isMissionFinish1()) {
sendFlightTaskProgress2Server(); sendFlightTaskProgress2Server();
handler.removeCallbacks(this); handler.removeCallbacks(this);
return; return;
} }
// 始终基于实际执行时间来调度 // 始终基于实际执行时间来调度
handler.postDelayed(this, INTERVAL); handler.postDelayed(this, INTERVAL);
} }

View File

@ -149,7 +149,7 @@ public class FlyToPointManager extends BaseManager {
KeyConnection)); KeyConnection));
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
WaypointMissionManager.getInstance().pushKMZFileToAircraft(Environment.getExternalStorageDirectory().getPath() + "/" + "FlyTo.kmz", new CommonCallbacks.CompletionCallbackWithProgress<Double>() { WaypointMissionManager.getInstance().pushKMZFileToAircraft(getExternalStoragePublicDirectory("KMZ").getAbsolutePath() + "/" + "FlyTo.kmz", new CommonCallbacks.CompletionCallbackWithProgress<Double>() {
@Override @Override
public void onProgressUpdate(Double progress) { public void onProgressUpdate(Double progress) {
sendEvent2Server("指点航线上传进度:" + progress, 1); sendEvent2Server("指点航线上传进度:" + progress, 1);
@ -176,7 +176,7 @@ public class FlyToPointManager extends BaseManager {
sendFailMsg2Server(message,"指点航线上传失败:"+ Utils.getIDJIErrorMsg(error)); sendFailMsg2Server(message,"指点航线上传失败:"+ Utils.getIDJIErrorMsg(error));
//待机 //待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
} }
}); });
} }
@ -204,6 +204,7 @@ public class FlyToPointManager extends BaseManager {
//指令飞行( 指点前置不需要起飞准备这些因为没有指点起飞的航线) //指令飞行( 指点前置不需要起飞准备这些因为没有指点起飞的航线)
Movement.getInstance().setMode_code(17); Movement.getInstance().setMode_code(17);
sendFlightTaskProgress2Server();
} }
@Override @Override
@ -211,10 +212,11 @@ public class FlyToPointManager extends BaseManager {
sendFailMsg2Server(message,"指点航线执行失败:" + new Gson().toJson(error)); sendFailMsg2Server(message,"指点航线执行失败:" + new Gson().toJson(error));
//待机 //待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
} }
}; };
WaypointMissionManager.getInstance().startMission("ToPoint", callback); WaypointMissionManager.getInstance().startMission("FlyTo", callback);
} else { } else {
sendEvent2Server("指点任务开始失败,设备未连接", 2); sendEvent2Server("指点任务开始失败,设备未连接", 2);
} }
@ -225,7 +227,7 @@ public class FlyToPointManager extends BaseManager {
KeyConnection)); KeyConnection));
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
IWaypointMissionManager missionManager = WaypointMissionManager.getInstance(); IWaypointMissionManager missionManager = WaypointMissionManager.getInstance();
missionManager.stopMission("ToPoint", new CommonCallbacks.CompletionCallback() { missionManager.stopMission("FlyTo", new CommonCallbacks.CompletionCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
sendMsg2Server(message); sendMsg2Server(message);

View File

@ -260,6 +260,7 @@ public class GimbalManager extends BaseManager {
public void gimbalLookAt(MessageDown message) { public void gimbalLookAt(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(GimbalKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(GimbalKey.
KeyConnection, ComponentIndexType.PORT_1)); KeyConnection, ComponentIndexType.PORT_1));
// LogUtil.log(TAG,"isConnect"+isConnect);
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
LookAtInfo lookAtInfo = new LookAtInfo(); LookAtInfo lookAtInfo = new LookAtInfo();
lookAtInfo.setMode(message.getData().isLocked() ? lookAtInfo.setMode(message.getData().isLocked() ?
@ -272,11 +273,13 @@ public class GimbalManager extends BaseManager {
KeyManager.getInstance().performAction(KeyTools.createKey(FlightControllerKey.KeyLookAt), lookAtInfo, new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() { KeyManager.getInstance().performAction(KeyTools.createKey(FlightControllerKey.KeyLookAt), lookAtInfo, new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override @Override
public void onSuccess(EmptyMsg emptyMsg) { public void onSuccess(EmptyMsg emptyMsg) {
LogUtil.log(TAG,"看向目标点成功");
sendMsg2Server(message); sendMsg2Server(message);
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
LogUtil.log(TAG,"看向目标点失败");
sendFailMsg2Server(message, "看向目标点失败:" + getIDJIErrorMsg(error)); sendFailMsg2Server(message, "看向目标点失败:" + getIDJIErrorMsg(error));
} }
} }

View File

@ -19,6 +19,7 @@ import com.amazonaws.services.s3.model.ProgressListener;
import com.amazonaws.services.s3.model.PutObjectRequest; import com.amazonaws.services.s3.model.PutObjectRequest;
import com.aros.apron.base.BaseManager; import com.aros.apron.base.BaseManager;
import com.aros.apron.entity.ApronExecutionStatus; import com.aros.apron.entity.ApronExecutionStatus;
import com.aros.apron.entity.Movement;
import com.aros.apron.tools.LogUtil; import com.aros.apron.tools.LogUtil;
import com.aros.apron.tools.PreferenceUtils; import com.aros.apron.tools.PreferenceUtils;
import com.autonavi.base.amap.mapcore.FileUtil; import com.autonavi.base.amap.mapcore.FileUtil;
@ -140,6 +141,9 @@ public class MediaManager extends BaseManager {
if (mState == MediaFileListState.UP_TO_DATE) { if (mState == MediaFileListState.UP_TO_DATE) {
mediaFiles = mediaFiles =
MediaDataCenter.getInstance().getMediaManager().getMediaFileListData().getData(); MediaDataCenter.getInstance().getMediaManager().getMediaFileListData().getData();
//倒是看会不会上传
Movement.getInstance().setTask_media_count(mediaFiles.size());
if (mediaFiles != null&&mediaFiles.size()>0) { if (mediaFiles != null&&mediaFiles.size()>0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
pullOriginalMediaFileFromCamera(); pullOriginalMediaFileFromCamera();

View File

@ -324,42 +324,6 @@ public class MissionV3Manager extends BaseManager {
//4.信号收敛(等待GPS搜星) //4.信号收敛(等待GPS搜星)
if (statusOk) { if (statusOk) {
verifyGpsAndMissionState(message); verifyGpsAndMissionState(message);
// String planeMessage = Movement.getInstance().getPlaneMessage();
// int quality = Movement.getInstance().getQuality();
//
// boolean isPlaneMessageValid = !TextUtils.isEmpty(planeMessage) && !planeMessage.equals("无法起飞");
// boolean isGpsQualityValid = (quality == 4 || quality == 5 || quality == 10);
//
//
//
// int tryCount = 99;
// while(--tryCount > 0){
// //下方航线
// if(isPlaneMessageValid && isGpsQualityValid){
// //下发航线
// downLoadKMZFile(message);
// //等待航线状态为
// int awaitTime =30;
// while(--awaitTime>0){
// int modeCode= Movement.getInstance().getMode_code();
// if( modeCode == 4){
// break;
// }else {
// sleep(1s)
// }
// }
// if(awaitTime>0){
// breeak;
// }
// }
//
//
//
// }
} }
}); });
} }
@ -432,14 +396,18 @@ public class MissionV3Manager extends BaseManager {
int missionStateCode = Movement.getInstance().getMissionStateCode(); int missionStateCode = Movement.getInstance().getMissionStateCode();
String planeMessage = Movement.getInstance().getPlaneMessage(); String planeMessage = Movement.getInstance().getPlaneMessage();
int quality = Movement.getInstance().getQuality(); int quality = Movement.getInstance().getQuality();
int GPSSatelliteCount=Movement.getInstance().getGPSSatelliteCount();
boolean isMissionStateValid = (missionStateCode == 2 || missionStateCode == 0 || missionStateCode == 7); boolean isMissionStateValid = (missionStateCode == 2 || missionStateCode == 0 || missionStateCode == 7);
boolean isPlaneMessageValid = !TextUtils.isEmpty(planeMessage) && !planeMessage.equals("无法起飞"); boolean isPlaneMessageValid = !TextUtils.isEmpty(planeMessage) && !planeMessage.equals("无法起飞");
boolean isGpsQualityValid = (quality == 4 || quality == 5 || quality == 10); boolean isGpsQualityValid = (quality == 4 || quality == 5 || quality == 10);
boolean GPSSatelliteCountValid=GPSSatelliteCount>15;
LogUtil.log(TAG,"isMissionStateValid"+isMissionStateValid+"isPlaneMessageValid"+isPlaneMessageValid+"isGpsQualityValid"+isGpsQualityValid); LogUtil.log(TAG,"isMissionStateValid"+isMissionStateValid+"isPlaneMessageValid"+isPlaneMessageValid+"isGpsQualityValid"+isGpsQualityValid);
// if (isMissionStateValid && isPlaneMessageValid && isGpsQualityValid) { // if (isMissionStateValid && isPlaneMessageValid && isGpsQualityValid) {
if (isPlaneMessageValid && isGpsQualityValid) {
//sendEvent2Server("卫星数量"+GPSSatelliteCount,1);
if (isGpsQualityValid||GPSSatelliteCountValid) {
//5.下载航线 //5.下载航线
downLoadKMZFile(message); downLoadKMZFile(message);
verifyGpsAndMissionStateSuccess = true; verifyGpsAndMissionStateSuccess = true;
@ -601,7 +569,7 @@ public class MissionV3Manager extends BaseManager {
//自主起飞 //自主起飞
Movement.getInstance().setMode_code(4); Movement.getInstance().setMode_code(4);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
Movement.getInstance().setTask_current_step(22); Movement.getInstance().setTask_current_step(22);
startMission(message); startMission(message);
@ -630,7 +598,7 @@ public class MissionV3Manager extends BaseManager {
} else { } else {
//待机 //待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
sendEvent2Server("航线第" + pushKMZFileTimes + "次上传失败,直接关机", 2); sendEvent2Server("航线第" + pushKMZFileTimes + "次上传失败,直接关机", 2);
TaskFailManager.getInstance().sendTaskFailMsg2Server(-1); TaskFailManager.getInstance().sendTaskFailMsg2Server(-1);
@ -702,7 +670,7 @@ public class MissionV3Manager extends BaseManager {
//待机 //待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
sendEvent2Server("航线第" + startMissionFailTimes + "次开始失败,直接关机:" + "---" + new Gson().toJson(error) + "--" + Movement.getInstance().getQuality(), 2); sendEvent2Server("航线第" + startMissionFailTimes + "次开始失败,直接关机:" + "---" + new Gson().toJson(error) + "--" + Movement.getInstance().getQuality(), 2);
TaskFailManager.getInstance().sendTaskFailMsg2Server(-1); TaskFailManager.getInstance().sendTaskFailMsg2Server(-1);

View File

@ -68,10 +68,14 @@ public class OSDManager extends BaseManager {
} }
lastExecuteTime = now; lastExecuteTime = now;
Boolean isConnect = KeyManager.getInstance().getValue(createKey(FlightControllerKey.KeyConnection)); Boolean isConnect = KeyManager.getInstance().getValue(createKey(FlightControllerKey.KeyConnection));
if (isConnect != null && isConnect && !Movement.getInstance().isMissionFinish()) { if (!Movement.getInstance().isMissionFinish()) {
if (isConnect != null && isConnect) {
pushFlightAttitude(); pushFlightAttitude();
}else{ } else {
LogUtil.log(TAG,"osd stop:flight controller is null"); LogUtil.log(TAG, "osd stop:flight controller is null");
}
} else {
LogUtil.log(TAG, "osd stop:flight controller is null");
} }
// 始终基于实际执行时间来调度 // 始终基于实际执行时间来调度
handler.postDelayed(this, INTERVAL); handler.postDelayed(this, INTERVAL);
@ -96,8 +100,6 @@ public class OSDManager extends BaseManager {
public void pushFlightAttitude() { public void pushFlightAttitude() {
try { try {
if (batteries != null && batteries.size() > 0) { if (batteries != null && batteries.size() > 0) {
batteries.clear(); batteries.clear();
} }

View File

@ -39,6 +39,7 @@ public class PerceptionManager extends BaseManager {
private boolean closePerceptionSuccess; private boolean closePerceptionSuccess;
public void setPerceptionEnable(boolean perceptionEnable) { public void setPerceptionEnable(boolean perceptionEnable) {
if (PreferenceUtils.getInstance().getCloseObsEnable() && perceptionEnable) { if (PreferenceUtils.getInstance().getCloseObsEnable() && perceptionEnable) {
LogUtil.log(TAG, "全局避障关闭,不开启避障"); LogUtil.log(TAG, "全局避障关闭,不开启避障");
return; return;
@ -53,7 +54,7 @@ public class PerceptionManager extends BaseManager {
LogUtil.log(TAG, "避障开启"); LogUtil.log(TAG, "避障开启");
} else { } else {
closePerceptionSuccess = true; closePerceptionSuccess = true;
LogUtil.log(TAG, "避障关闭"); //LogUtil.log(TAG, "避障关闭");
} }
} }

View File

@ -0,0 +1,78 @@
package com.aros.apron.manager;
import androidx.annotation.NonNull;
import com.aros.apron.entity.PayloadInfo;
import com.aros.apron.tools.LogUtil;
import java.util.Map;
import dji.sdk.keyvalue.key.FlightControllerKey;
import dji.sdk.keyvalue.key.KeyTools;
import dji.v5.common.callback.CommonCallbacks;
import dji.v5.common.error.IDJIError;
import dji.v5.manager.KeyManager;
import dji.v5.manager.aircraft.payload.PayloadCenter;
import dji.v5.manager.aircraft.payload.PayloadIndexType;
import dji.v5.manager.aircraft.payload.data.PayloadWidgetInfo;
import dji.v5.manager.aircraft.payload.listener.PayloadBasicInfoListener;
import dji.v5.manager.aircraft.payload.listener.PayloadDataListener;
import dji.v5.manager.aircraft.payload.listener.PayloadWidgetInfoListener;
import dji.v5.manager.interfaces.IPayloadManager;
public class PlayLoadManager {
private String TAG = this.getClass().getSimpleName();
private PlayLoadManager() {
}
public static PlayLoadManager getInstance() {
return PlayLoadManagerHolder.INSTANCE;
}
private static class PlayLoadManagerHolder {
private static final PlayLoadManager INSTANCE = new PlayLoadManager();
}
public void init() {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
if (isConnect != null && isConnect) {
Map<PayloadIndexType, IPayloadManager> payloadManager = PayloadCenter.getInstance().getPayloadManager();
if (payloadManager != null) {
IPayloadManager iPayloadManager = payloadManager.get(PayloadIndexType.PORT_1);
if (iPayloadManager != null) {
iPayloadManager.addPayloadWidgetInfoListener(new PayloadWidgetInfoListener() {
@Override
public void onPayloadWidgetInfoUpdate(PayloadWidgetInfo info) {
LogUtil.log(TAG,"负载信息"+info.toString());
}
});
iPayloadManager.pullWidgetInfoFromPayload(new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
LogUtil.log(TAG,"拉取成功");
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
LogUtil.log(TAG,"拉取成功");
}
});
} else {
LogUtil.log(TAG, "监听EXTERNAL PSDK数据失败:设备未连接");
}
}
}
}
}

View File

@ -4,6 +4,7 @@ import static com.aros.apron.tools.Utils.getIDJIErrorMsg;
import static dji.sdk.keyvalue.key.KeyTools.createKey; import static dji.sdk.keyvalue.key.KeyTools.createKey;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -58,6 +59,8 @@ public class StickManager extends BaseManager {
public void onSuccess() { public void onSuccess() {
LogUtil.log(TAG, "控制权获取成功"); LogUtil.log(TAG, "控制权获取成功");
VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true); VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true);
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
@ -83,15 +86,19 @@ public class StickManager extends BaseManager {
} }
//获得拟摇杆控制权 //取消虚拟摇杆控制权
public void enableVirtualStick(MessageDown message) { public void enableVirtualStick(MessageDown message) {
//吐过开启了drc或者使用过摇杆
if(Movement.getInstance().isOpendrc()==false){
VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true); VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true);
VirtualStickManager.getInstance().enableVirtualStick(new CommonCallbacks.CompletionCallback() { VirtualStickManager.getInstance().enableVirtualStick(new CommonCallbacks.CompletionCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
Movement.getInstance().setOpendrc(true);
if (message != null) { if (message != null) {
sendMsg2Server(message); sendMsg2Server(message);
} }
LogUtil.log(TAG, "控制权获取成功"); LogUtil.log(TAG, "控制权获取成功");
VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true); VirtualStickManager.getInstance().setVirtualStickAdvancedModeEnabled(true);
//获得过控制权 //获得过控制权
@ -106,6 +113,8 @@ public class StickManager extends BaseManager {
} }
} }
}); });
}
} }
//取消虚拟摇杆控制权 //取消虚拟摇杆控制权
@ -115,7 +124,6 @@ public class StickManager extends BaseManager {
public void onSuccess() { public void onSuccess() {
if (message != null) { if (message != null) {
sendMsg2Server(message); sendMsg2Server(message);
if(Movement.getInstance().getFlightmode()==1){ if(Movement.getInstance().getFlightmode()==1){
Movement.getInstance().setMode_code(5); Movement.getInstance().setMode_code(5);
}else if(Movement.getInstance().getFlightmode()==2){ }else if(Movement.getInstance().getFlightmode()==2){
@ -138,15 +146,17 @@ public class StickManager extends BaseManager {
}); });
} }
//飞行控制权抢夺 //飞行控制权抢夺
public void setVirtualStickModeEnabled(MessageDown message) { public void setVirtualStickModeEnabled(MessageDown message) {
//Movement.getInstance().setMode_code(3); //Movement.getInstance().setMode_code(3);
//设置标志为 //设置标志为
Movement.getInstance().setOpendrc(true); new Handler(Looper.getMainLooper()).postDelayed(() -> {
// 这里放你要延迟执行的代码
StickManager.getInstance().enableVirtualStick(message); StickManager.getInstance().enableVirtualStick(message);
sendMsg2Server(message); }, 2000);
//sendMsg2Server(message);
////// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection)); ////// Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
////// if (isConnect != null && isConnect) { ////// if (isConnect != null && isConnect) {
@ -238,7 +248,6 @@ public class StickManager extends BaseManager {
LogUtil.log(TAG,"飞机未起飞:禁止手控"); LogUtil.log(TAG,"飞机未起飞:禁止手控");
return; return;
} }
VirtualStickFlightControlParam param = new VirtualStickFlightControlParam(); VirtualStickFlightControlParam param = new VirtualStickFlightControlParam();
param.setRollPitchControlMode(RollPitchControlMode.VELOCITY);// param.setRollPitchControlMode(RollPitchControlMode.VELOCITY);//
param.setYawControlMode(YawControlMode.ANGULAR_VELOCITY); param.setYawControlMode(YawControlMode.ANGULAR_VELOCITY);
@ -260,7 +269,6 @@ public class StickManager extends BaseManager {
param.setVerticalThrottle(Double.valueOf(message.getData().getH()));//上下(速度模式-4m/s-4m/s) param.setVerticalThrottle(Double.valueOf(message.getData().getH()));//上下(速度模式-4m/s-4m/s)
} }
//手动飞行 //手动飞行
Movement.getInstance().setMode_code(16); Movement.getInstance().setMode_code(16);
VirtualStickManager.getInstance().sendVirtualStickAdvancedParam(param); VirtualStickManager.getInstance().sendVirtualStickAdvancedParam(param);

View File

@ -7,6 +7,7 @@ import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -17,10 +18,12 @@ import com.aros.apron.entity.ApronExecutionStatus;
import com.aros.apron.entity.CurrentWayline; import com.aros.apron.entity.CurrentWayline;
import com.aros.apron.entity.FlightMission; import com.aros.apron.entity.FlightMission;
import com.aros.apron.entity.MessageDown; import com.aros.apron.entity.MessageDown;
import com.aros.apron.entity.MissionDataBean;
import com.aros.apron.entity.MissionPoint; import com.aros.apron.entity.MissionPoint;
import com.aros.apron.entity.Movement; import com.aros.apron.entity.Movement;
import com.aros.apron.tools.DomParserKML; import com.aros.apron.tools.DomParserKML;
import com.aros.apron.tools.DomParserWPML; import com.aros.apron.tools.DomParserWPML;
import com.aros.apron.tools.Generakmztools;
import com.aros.apron.tools.LogUtil; import com.aros.apron.tools.LogUtil;
import com.aros.apron.tools.PreferenceUtils; import com.aros.apron.tools.PreferenceUtils;
import com.aros.apron.tools.RestartAPPTool; import com.aros.apron.tools.RestartAPPTool;
@ -39,6 +42,8 @@ import dji.sdk.keyvalue.key.KeyTools;
import dji.sdk.keyvalue.value.flightcontroller.RemoteControllerFlightMode; import dji.sdk.keyvalue.value.flightcontroller.RemoteControllerFlightMode;
import dji.sdk.wpmz.value.mission.Wayline; import dji.sdk.wpmz.value.mission.Wayline;
import dji.sdk.wpmz.value.mission.WaylineExecuteWaypoint; import dji.sdk.wpmz.value.mission.WaylineExecuteWaypoint;
import dji.sdk.wpmz.value.mission.WaylineMissionConfig;
import dji.sdk.wpmz.value.mission.WaylineMissionConfigParseInfo;
import dji.sdk.wpmz.value.mission.WaylineWaylinesParseInfo; import dji.sdk.wpmz.value.mission.WaylineWaylinesParseInfo;
import dji.v5.common.callback.CommonCallbacks; import dji.v5.common.callback.CommonCallbacks;
import dji.v5.common.error.IDJIError; import dji.v5.common.error.IDJIError;
@ -67,6 +72,7 @@ public class TakeOffToPointManager extends BaseManager {
//收到一键起飞航线 //收到一键起飞航线
public void taskExecute(MessageDown message) { public void taskExecute(MessageDown message) {
PreferenceUtils.getInstance().setMissionType(1); PreferenceUtils.getInstance().setMissionType(1);
PreferenceUtils.getInstance().setFlightId(message.getData().getFlight_id()); PreferenceUtils.getInstance().setFlightId(message.getData().getFlight_id());
PreferenceUtils.getInstance().setAlternatePointLon(message.getData().getAlternate_land_point().getLongitude() + ""); PreferenceUtils.getInstance().setAlternatePointLon(message.getData().getAlternate_land_point().getLongitude() + "");
@ -75,7 +81,7 @@ public class TakeOffToPointManager extends BaseManager {
message.getData().getAlternate_land_point().getSafe_land_height() + ""); message.getData().getAlternate_land_point().getSafe_land_height() + "");
Movement.getInstance().setTask_current_step(5); Movement.getInstance().setTask_current_step(5);
LogUtil.log(TAG,"生成");
//1.检查图传是否连接 //1.检查图传是否连接
checkVtxWithDelay(() -> { checkVtxWithDelay(() -> {
//避免重复执行 //避免重复执行
@ -88,8 +94,10 @@ public class TakeOffToPointManager extends BaseManager {
boolean statusOk = verifyAircraftStatus(message); boolean statusOk = verifyAircraftStatus(message);
//4.信号收敛(等待GPS搜星) //4.信号收敛(等待GPS搜星)
if (statusOk) { if (statusOk) {
LogUtil.log(TAG,"verifyGpsAndMissionState(message)执行了");
verifyGpsAndMissionState(message); verifyGpsAndMissionState(message);
} }
}); });
} }
@ -120,12 +128,12 @@ public class TakeOffToPointManager extends BaseManager {
TaskFailManager.getInstance().sendTaskFailMsg2Server(-1); TaskFailManager.getInstance().sendTaskFailMsg2Server(-1);
return false; return false;
} }
//6.检查航线参数 // //6.检查航线参数
if (message.getData().getFile() == null) { // if (message.getData().getFile() == null) {
sendEvent2Server("航线参数异常",2); // sendEvent2Server("航线参数异常",2);
TaskFailManager.getInstance().sendTaskFailMsg2Server(-1); // TaskFailManager.getInstance().sendTaskFailMsg2Server(-1);
return false; // return false;
} // }
//7.检查电池电量 //7.检查电池电量
Integer value = KeyManager.getInstance().getValue(createKey(FlightControllerKey. Integer value = KeyManager.getInstance().getValue(createKey(FlightControllerKey.
KeyBatteryPowerPercent, 0)); KeyBatteryPowerPercent, 0));
@ -171,6 +179,7 @@ public class TakeOffToPointManager extends BaseManager {
// if (isMissionStateValid && isPlaneMessageValid && isGpsQualityValid) { // if (isMissionStateValid && isPlaneMessageValid && isGpsQualityValid) {
if (isPlaneMessageValid && isGpsQualityValid) { if (isPlaneMessageValid && isGpsQualityValid) {
//5.生成航线 //5.生成航线
LogUtil.log(TAG,"执行toGenerateKMZFile");
toGenerateKMZFile(message); toGenerateKMZFile(message);
verifyGpsAndMissionStateSuccess = true; verifyGpsAndMissionStateSuccess = true;
} else { } else {
@ -217,68 +226,14 @@ public class TakeOffToPointManager extends BaseManager {
*/ */
public void toGenerateKMZFile(MessageDown message) { public void toGenerateKMZFile(MessageDown message) {
Movement.getInstance().setTask_current_step(16); Movement.getInstance().setTask_current_step(16);
// 创建第一个 MissionPoint 对象 MissionDataBean data = new Gson().fromJson(new Gson().toJson(message.getData()), MissionDataBean.class);
MissionPoint missionPoint = new MissionPoint(); Boolean generateKmz=Generakmztools.getInstance().generateKmz(data);
missionPoint.setLat(String.valueOf(Movement.getInstance().getLatitude())); LogUtil.log(TAG,"生成的boole"+generateKmz);
missionPoint.setLng(String.valueOf(Movement.getInstance().getLongitude())); if(generateKmz==true){
missionPoint.setSpeed(Double.parseDouble(message.getData().getMax_speed()));
missionPoint.setExecuteHeight(message.getData().getTarget_height() - 1);
// 创建第二个 MissionPoint 对象
MissionPoint missionPoint1 = new MissionPoint();
missionPoint1.setLat(message.getData().getTarget_latitude() + "");
missionPoint1.setLng(message.getData().getTarget_longitude() + "");
missionPoint1.setSpeed(Double.parseDouble(message.getData().getMax_speed()));
missionPoint1.setExecuteHeight(message.getData().getTarget_height());
// 创建一个 MissionPoint 列表
List<MissionPoint> missionPoints = new ArrayList<>();
missionPoints.add(missionPoint);
missionPoints.add(missionPoint1);
// 创建 FlightMission 对象并设置其属性
FlightMission flightMission = new FlightMission();
flightMission.setPoints(missionPoints);
flightMission.setMissionId(2);
flightMission.setFinishAction("noAction");
flightMission.setTakeOffSecurityHeight(
Float.parseFloat(message.getData().getSecurity_takeoff_height()));
flightMission.setSpeed(Double.parseDouble(message.getData().getMax_speed()));
LogUtil.log(TAG, "当前高度:" + Movement.getInstance().getElevation()
+ "-一键起飞安全起飞高度:" + message.getData().getSecurity_takeoff_height());
sendEvent2Server("开始生成一键起飞航线", 1);
// 生成xml文件
File file1 = new File(
getExternalStoragePublicDirectory("KMZ").getAbsolutePath() + File.separator + "wpmz");
if (!file1.exists()) {
if (file1.mkdirs()) {
sendEvent2Server("一键起飞航线文件生成成功", 1);
} else {
sendEvent2Server("一键起飞航线文件生成失败", 2);
}
}
DomParserKML domParserKML = new DomParserKML(getExternalStoragePublicDirectory("KMZ").getAbsolutePath() + File.separator + "wpmz",
"/template.kml");
domParserKML.createKml(flightMission);
DomParserWPML domParserWPML = new DomParserWPML(getExternalStoragePublicDirectory("KMZ").getAbsolutePath() + File.separator + "wpmz",
"/waylines.wpml");
domParserWPML.createWpml(flightMission);
File kmzFile = new File(getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + "ToPoint.kmz");
kmzFile.getParentFile().mkdirs();
try {
ZipUtil.zip(getExternalStoragePublicDirectory("KMZ").getAbsolutePath() + "/wpmz",
getExternalStoragePublicDirectory("KMZ").getAbsolutePath() + File.separator + "ToPoint.kmz");
} catch (IOException e) {
sendEvent2Server("一键起飞任务生成异常", 2);
throw new RuntimeException(e);
}
pushKMZFileToAircraft(message); pushKMZFileToAircraft(message);
}else{
sendEvent2Server("航线生成失败", 1);
}
} }
private int pushKMZFileTimes = 0; private int pushKMZFileTimes = 0;
@ -298,22 +253,23 @@ public class TakeOffToPointManager extends BaseManager {
* 6.上传指点航线 * 6.上传指点航线
* @param message * @param message
*/ */
private void pushKMZFileToAircraft(MessageDown message) { public void pushKMZFileToAircraft(MessageDown message) {
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey. Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.
KeyConnection)); KeyConnection));
if (isConnect != null && isConnect) { if (isConnect != null && isConnect) {
String kmzAbsPath = "/storage/self/primary/DJIDemo/cache/kmz/takeofftopoint.kmz";
KMZInfo kmzInfo = WPMZManager.getInstance().getKMZInfo( KMZInfo kmzInfo = WPMZManager.getInstance().getKMZInfo(kmzAbsPath);
Environment.getExternalStorageDirectory().getPath() + "/" + "ToPoint.kmz");
if (kmzInfo != null) { if (kmzInfo != null) {
// Utils.printJson(TAG,"航点详情:"+new Gson().toJson(kmzInfo)); // Utils.printJson(TAG,"航点详情:"+new Gson().toJson(kmzInfo));
WaylineWaylinesParseInfo waylineWaylinesParseInfo = kmzInfo.getWaylineWaylinesParseInfo(); WaylineWaylinesParseInfo waylineWaylinesParseInfo = kmzInfo.getWaylineWaylinesParseInfo();
WaylineMissionConfig configParseInfo= kmzInfo.getWaylineMissionConfigParseInfo().getConfig();
if (waylineWaylinesParseInfo != null) { if (waylineWaylinesParseInfo != null) {
List<Wayline> waylines = waylineWaylinesParseInfo.getWaylines(); List<Wayline> waylines = waylineWaylinesParseInfo.getWaylines();
if (waylines != null && waylines.size() > 0) { if (waylines != null && waylines.size() >0) {
List<WaylineExecuteWaypoint> waypoints = waylines.get(0).getWaypoints(); List<WaylineExecuteWaypoint> waypoints = waylines.get(0).getWaypoints();
if (waypoints != null && waypoints.size() > 0) { if (waypoints != null && waypoints.size() > 0) {
//将航点列表保存在本地 //将航点列表保存在本地
Movement.getInstance().setSpeed(configParseInfo.getGlobalTransitionalSpeed());
CurrentWayline.getInstance().setWaypoints(waypoints); CurrentWayline.getInstance().setWaypoints(waypoints);
LogUtil.log(TAG, "该航线有" + waypoints.size() + "个航点"); LogUtil.log(TAG, "该航线有" + waypoints.size() + "个航点");
} else { } else {
@ -332,18 +288,20 @@ public class TakeOffToPointManager extends BaseManager {
} }
WaypointMissionManager.getInstance().pushKMZFileToAircraft(Environment.getExternalStorageDirectory().getPath() + "/" + "aros.kmz", new CommonCallbacks.CompletionCallbackWithProgress<Double>() { WaypointMissionManager.getInstance().pushKMZFileToAircraft(kmzAbsPath, new CommonCallbacks.CompletionCallbackWithProgress<Double>() {
@Override @Override
public void onProgressUpdate(Double progress) { public void onProgressUpdate(Double progress) {
sendEvent2Server("航线上传进度:" + progress, 1); sendEvent2Server("航线上传进度:" + progress, 1);
Movement.getInstance().setTask_current_step(17); Movement.getInstance().setTask_current_step(17);
} }
@Override @Override
public void onSuccess() { public void onSuccess() {
//起飞准备完毕 //起飞准备完毕
Movement.getInstance().setMode_code(2); Movement.getInstance().setMode_code(2);
sendFlightTaskProgress2Server();
sendEvent2Server("航线上传成功,准备执行任务", 1); sendEvent2Server("航线上传成功,准备执行任务", 1);
isPushKMZSuccess = true; isPushKMZSuccess = true;
mainHandler.postDelayed(new Runnable() { mainHandler.postDelayed(new Runnable() {
@ -352,9 +310,10 @@ public class TakeOffToPointManager extends BaseManager {
/** /**
* 7.开始任务 * 7.开始任务
*/ */
//自主起飞 //自主起飞
Movement.getInstance().setMode_code(4); Movement.getInstance().setMode_code(4);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
Movement.getInstance().setTask_current_step(22); Movement.getInstance().setTask_current_step(22);
startMission(message); startMission(message);
pushKMZFileTimes = 0; pushKMZFileTimes = 0;
@ -382,7 +341,7 @@ public class TakeOffToPointManager extends BaseManager {
sendEvent2Server("航线第" + pushKMZFileTimes + "次上传失败,直接关机",2); sendEvent2Server("航线第" + pushKMZFileTimes + "次上传失败,直接关机",2);
//待机 //待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
TaskFailManager.getInstance().sendTaskFailMsg2Server(-1); TaskFailManager.getInstance().sendTaskFailMsg2Server(-1);
} }
@ -422,17 +381,7 @@ public class TakeOffToPointManager extends BaseManager {
sendEvent2Server("任务开始执行", 1); sendEvent2Server("任务开始执行", 1);
Movement.getInstance().setTask_current_step(23); Movement.getInstance().setTask_current_step(23);
sendFlightTaskProgress2Server(); sendFlightTaskProgress2Server();
// Movement.getInstance().setMode_code(5);
//
// //自动起飞
// Movement.getInstance().setMode_code(4);
// //延迟2s
// new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
// Movement.getInstance().setMode_code(17);
// }, 2000);
} }
@Override @Override
public void onFailure(@NonNull IDJIError error) { public void onFailure(@NonNull IDJIError error) {
LogUtil.log(TAG, "航线执行失败:" + new Gson().toJson(error)); LogUtil.log(TAG, "航线执行失败:" + new Gson().toJson(error));
@ -452,7 +401,7 @@ public class TakeOffToPointManager extends BaseManager {
if (!Movement.getInstance().isPlaneWing()) { if (!Movement.getInstance().isPlaneWing()) {
//待机 //待机
Movement.getInstance().setMode_code(0); Movement.getInstance().setMode_code(0);
OSDManager.getInstance().pushFlightAttitude(); sendFlightTaskProgress2Server();
sendEvent2Server("航线第" + startMissionFailTimes + "次开始失败,直接关机:" + "---" + new Gson().toJson(error) + "--" + Movement.getInstance().getQuality(),2); sendEvent2Server("航线第" + startMissionFailTimes + "次开始失败,直接关机:" + "---" + new Gson().toJson(error) + "--" + Movement.getInstance().getQuality(),2);
TaskFailManager.getInstance().sendTaskFailMsg2Server(-1); TaskFailManager.getInstance().sendTaskFailMsg2Server(-1);
@ -464,8 +413,7 @@ public class TakeOffToPointManager extends BaseManager {
} }
} }
}; };
WaypointMissionManager.getInstance().startMission("takeofftopoint", callback);
WaypointMissionManager.getInstance().startMission("ToPoint", callback);
} else { } else {
sendEvent2Server("任务开始失败,设备未连接", 2); sendEvent2Server("任务开始失败,设备未连接", 2);
} }

View File

@ -68,10 +68,10 @@ public class ApronArucoDetect {
// 关键修改1M400下视镜头右后方补偿量像素正值向右补偿 // 关键修改1M400下视镜头右后方补偿量像素正值向右补偿
// 如果还往左偏就调大往右偏就调小建议范围 30-80 // 如果还往左偏就调大往右偏就调小建议范围 30-80
private static final double LENS_OFFSET_X = 35.0; private static final double LENS_OFFSET_X = 15.0;
private static final double LENS_OFFSET_Y = 20.0; private static final double LENS_OFFSET_Y = 20.0;
// 关键修改2放宽居中判定阈值原40补偿后改为60更合理 // 关键修改2放宽居中判定阈值原40补偿后改为60更合理
private static final int CENTER_ERR_MAX = 35; // 居中误差px private static final int CENTER_ERR_MAX = 40; // 居中误差px
public PIDControl pidControlX = null; public PIDControl pidControlX = null;
public PIDControl pidControlY = null; public PIDControl pidControlY = null;
@ -121,11 +121,13 @@ public class ApronArucoDetect {
} }
private static final float SLOW_LAND_SPEED = -0.3f; // 远场慢降 private static final float SLOW_LAND_SPEED = -0.3f; // 远场慢降
private static final int PIXEL_TRIGGER = 350; // 近场像素阈值 private static final float SLOW_SUPER_SPEED = -0.1f; // 超近慢降
private static final int PIXEL_TRIGGER = 400; // 近场像素阈值
public void init() { public void init() {
pidControlX = new PIDControl(0.8f, 0.002f, 0.09f, 0.05f, 2.0f, 0.05f); pidControlX = new PIDControl(0.6f, 0.015f, 0.12f, 0.05f, 2.0f, 0.05f);
pidControlY = new PIDControl(0.8f, 0.002f, 0.09f, 0.05f, 2.0f, 0.05f); pidControlY = new PIDControl(0.6f, 0.015f, 0.12f, 0.05f, 2.0f, 0.05f);
pidControlX.reset(); pidControlX.reset();
pidControlY.reset(); pidControlY.reset();
@ -198,7 +200,7 @@ public class ApronArucoDetect {
arucoNotFoundTag = false; arucoNotFoundTag = false;
int[] idArray = ids.toArray(); int[] idArray = ids.toArray();
int ultrasonicHeight = Movement.getInstance().getUltrasonicHeight(); int ultrasonicHeight = Movement.getInstance().getUltrasonicHeight();
//double flyingHeight = Movement.getInstance().getFlyingHeight(); // double flyingHeight = Movement.getInstance().getElevation();
// 如果只有一个而且是6 // 如果只有一个而且是6
if (idArray.length == 1 && idArray[0] == 6) { if (idArray.length == 1 && idArray[0] == 6) {
@ -226,7 +228,7 @@ public class ApronArucoDetect {
/* 近场 + 对准 + 像素够 → 立即速降 */ /* 近场 + 对准 + 像素够 → 立即速降 */
if (!startFastStick && if (!startFastStick &&
pixelWidth >= PIXEL_TRIGGER && pixelWidth >= PIXEL_TRIGGER &&
// flyingHeight <= 0.4 && // flyingHeight <= 1 &&
ultrasonicHeight <= 4 && ultrasonicHeight <= 4 &&
errX < CENTER_ERR_MAX && errX < CENTER_ERR_MAX &&
errY < CENTER_ERR_MAX) { errY < CENTER_ERR_MAX) {
@ -251,10 +253,8 @@ public class ApronArucoDetect {
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
long lostDuration = endTime - startTime; long lostDuration = endTime - startTime;
//1s到8s内 //1s到8s内
if (lostDuration > 1000 && lostDuration <= 8000) { if (lostDuration > 700 && lostDuration <= 8000) {
if (Movement.getInstance().getUltrasonicHeight()<=30) { if (Movement.getInstance().getUltrasonicHeight()<=30) {
DroneHelper.getInstance().moveVxVyYawrateHeight(0f, 0f, 0f, 0.3f); DroneHelper.getInstance().moveVxVyYawrateHeight(0f, 0f, 0f, 0.3f);
if (dropTimes > Integer.parseInt(AMSConfig.getInstance().getAlternateLandingTimes())) { if (dropTimes > Integer.parseInt(AMSConfig.getInstance().getAlternateLandingTimes())) {
LogUtil.log(TAG, "超过复降限制,去备降点"); LogUtil.log(TAG, "超过复降限制,去备降点");
@ -398,24 +398,34 @@ public class ApronArucoDetect {
double cy = (pts[0].y + pts[1].y + pts[2].y + pts[3].y) / 4.0; double cy = (pts[0].y + pts[1].y + pts[2].y + pts[3].y) / 4.0;
Point screenCenter = new Point(imageWidth / 2.0, imageHeight / 2.0); Point screenCenter = new Point(imageWidth / 2.0, imageHeight / 2.0);
// 关键修改4PID控制也加上相同的偏移补偿注意这里不加abs保留符号给PID判断方向
double errX = (cx - screenCenter.x) + LENS_OFFSET_X; // 向右补偿 double errX = (cx - screenCenter.x) + LENS_OFFSET_X; // 向右补偿
double errY = (cy - screenCenter.y) - LENS_OFFSET_Y; // Y方向不变 double errY = (cy - screenCenter.y) - LENS_OFFSET_Y; // Y方向不变
/* 3. PID 微调水平 */ /* 3. PID 微调水平 */
pidControlX.setInputFilterAll((float) (errX / 800.0)); pidControlX.setInputFilterAll((float) (errX / 700.0));
pidControlY.setInputFilterAll((float) (-errY / 800)); pidControlY.setInputFilterAll((float) (-errY/ 700.0));
float vx = (float) Math.max(-0.25, Math.min(0.25, pidControlX.get_pid())); float vx = (float) Math.max(-0.25, Math.min(0.25, pidControlX.get_pid()));
float vy = (float) Math.max(-0.25, Math.min(0.25, pidControlY.get_pid())); float vy = (float) Math.max(-0.25, Math.min(0.25, pidControlY.get_pid()));
/* 4. 远场慢降:像素 < 1500 且 > 2 m */ /* 4. 远场慢降:像素 < 1500 且 > 2 m */
double pixelWidth = Math.sqrt(Math.pow(pts[1].x - pts[0].x, 2) + double pixelWidth = Math.sqrt(Math.pow(pts[1].x - pts[0].x, 2) +
Math.pow(pts[1].y - pts[0].y, 2)); Math.pow(pts[1].y - pts[0].y, 2));
// double flyingHeight = Movement.getInstance().getElevation();
float vz = (pixelWidth < PIXEL_TRIGGER && int currentHeight = Movement.getInstance().getUltrasonicHeight();
// Movement.getInstance().getFlyingHeight() > 0.4f &&
Movement.getInstance().getUltrasonicHeight() > 4) ? float vz;
SLOW_LAND_SPEED : 0.0f; if (currentHeight <= 4) {
vz = 0.0f; // 近场悬停等速降
} else if (currentHeight <= 6) {
vz = SLOW_SUPER_SPEED; // -0.1f过渡层
} else {
vz = SLOW_LAND_SPEED; // -0.3f远场慢降
}
// if (flyingHeight <= 0.2) {
// vz = 0.0f;
// LogUtil.log(TAG, "相对高度" + flyingHeight + "强制悬停");
// }
/* 5. 输出 */ /* 5. 输出 */
DroneHelper.getInstance().moveVxVyYawrateHeight(vx, vy, 0f, vz); DroneHelper.getInstance().moveVxVyYawrateHeight(vx, vy, 0f, vz);

View File

@ -1,4 +1,4 @@
//package com.shd.nest.viewmodel package com.aros.apron.tools//package com.shd.nest.viewmodel
// //
//import android.annotation.SuppressLint //import android.annotation.SuppressLint
//import android.graphics.Bitmap //import android.graphics.Bitmap

View File

@ -1,4 +1,4 @@
package com.aros.apron.tools
import android.accessibilityservice.AccessibilityService import android.accessibilityservice.AccessibilityService
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Notification import android.app.Notification

View File

@ -0,0 +1,199 @@
package com.aros.apron.tools;
import android.util.Log;
import com.aros.apron.base.BaseManager;
import com.aros.apron.entity.MissionDataBean;
import com.aros.apron.entity.Movement;
import com.aros.apron.manager.TakeOffToPointManager;
import com.dji.wpmzsdk.common.data.Template;
import com.dji.wpmzsdk.manager.WPMZManager;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import dji.sdk.keyvalue.key.FlightControllerKey;
import dji.sdk.keyvalue.key.KeyTools;
import dji.sdk.keyvalue.value.common.LocationCoordinate3D;
import dji.sdk.wpmz.value.mission.*;
import dji.v5.manager.KeyManager;
/**
* 单航点起飞目标点返航
* Java Builder WaypointHeadingParam
*/
public class Generakmztools extends BaseManager {
private Generakmztools() {}
private static class Holder { private static final Generakmztools INSTANCE = new Generakmztools(); }
public static Generakmztools getInstance() { return Holder.INSTANCE; }
public Boolean generateKmz(MissionDataBean data) {
sendEvent2Server("开始生成一键起飞航线", 1);
LocationCoordinate3D lat = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.
KeyAircraftLocation3D));
if (lat == null) {
LogUtil.log("qwq", "当前位置为空,无法生成航线");
sendEvent2Server("生成失败:未获取到飞机当前位置", 1);
return false;
}
if (lat.getLatitude() == null || lat.getLongitude() == null|| lat.getAltitude() == null) {
LogUtil.log("qwq", "当前位置坐标无效");
sendEvent2Server("生成失败:位置坐标无效", 1);
return false;
}
File root = new File("/storage/self/primary/DJIDemo/cache/kmz");
if (!root.exists()) root.mkdirs();
File kmz = new File(root, "takeofftopoint.kmz");
/* 1. <wpml:mission> 基本信息 */
WaylineMission mission = new WaylineMission();
mission.setAuthor("aros");
double now = System.currentTimeMillis();
mission.setCreateTime(now);
mission.setUpdateTime(now);
/* 2. <wpml:missionConfig> 全局策略 */
WaylineMissionConfig config = new WaylineMissionConfig();
//飞向目标点的模式
config.setFlyToWaylineMode(WaylineFlyToWaylineMode.SAFELY);
//航线结束后的动作
config.setFinishAction(WaylineFinishedAction.NO_ACTION);
if(data.getCommanderModeLostAction()==0){
//继续
config.setExitOnRCLostBehavior(WaylineExitOnRCLostBehavior.GO_ON);
}else if(data.getCommanderModeLostAction()==1){
//失控退出航线
config.setExitOnRCLostBehavior(WaylineExitOnRCLostBehavior.EXCUTE_RC_LOST_ACTION);
}
//失控退出航线的动作
if(data.getRcLostAction()==0){
//悬停
config.setExitOnRCLostType(WaylineExitOnRCLostAction.HOVER);
} else if (data.getRcLostAction()==1) {
//精确着陆
config.setExitOnRCLostType(WaylineExitOnRCLostAction.LANDING);
} else if (data.getRcLostAction()==2) {
//返航
config.setExitOnRCLostType(WaylineExitOnRCLostAction.GO_BACK);
}
//全局过度速度
config.setGlobalTransitionalSpeed((double)data.getMaxSpeed());
//全局返航高度
config.setGlobalRTHHeight((double)data.getRthAltitude());
config.setIsGlobalRTHHeightSet(true);
//安全起飞高度
config.setSecurityTakeOffHeight((double)data.getSecurityTakeoffHeight());
config.setIsSecurityTakeOffHeightSet(true);
//为400准备的
WaylineDroneInfo droneInfo = new WaylineDroneInfo();
droneInfo.setDroneType(WaylineDroneType.PM440);
config.setDroneInfo(droneInfo);
//这个航点列表
WaylineWaypoint wp1 = new WaylineWaypoint();
WaylineWaypoint wp = new WaylineWaypoint();
//初始点
wp1.setWaypointIndex(0);
wp1.setLocation(new WaylineLocationCoordinate2D(lat.getLatitude(), lat.getLongitude()));
//wp1.setHeight((double)data.getCommanderFlightHeight());
wp1.setHeight(data.getTargetHeight()- Movement.getInstance().getHeight());
// wp1.setUseGlobalFlightHeight(true);
//椭球高
wp1.setEllipsoidHeight(data.getTargetHeight()- Movement.getInstance().getHeight());
wp1.setUseStraightLine(true);
wp1.setUseGlobalTurnParam(true);
wp1.setUseGlobalYawParam(true);
wp1.setUseGlobalGimbalHeadingParam(true);
wp1.setUseGlobalAutoFlightSpeed(true);
wp1.setIsRisky(false);
//基础设置
wp.setWaypointIndex(1);
wp.setLocation(new WaylineLocationCoordinate2D(data.getTargetLatitude(), data.getTargetLongitude()));
//wp.setHeight((double)data.getCommanderFlightHeight());
wp.setHeight(data.getTargetHeight()- Movement.getInstance().getHeight());
// wp.setUseGlobalFlightHeight(true);
//椭球高
wp.setEllipsoidHeight(data.getTargetHeight()- Movement.getInstance().getHeight());
wp.setUseStraightLine(true);
wp.setUseGlobalTurnParam(true);
wp.setUseGlobalYawParam(true);
wp.setUseGlobalGimbalHeadingParam(true);
wp.setUseGlobalAutoFlightSpeed(true);
wp.setIsRisky(false);
List<WaylineWaypoint> wpList = new ArrayList<>();
wpList.add(wp1);
wpList.add(wp);
/* 4. <wpml:waypointInfo> */
WaylineTemplateWaypointInfo waypointInfo = new WaylineTemplateWaypointInfo();
waypointInfo.setGlobalFlightHeight(data.getTargetHeight());
waypointInfo.setIsGlobalFlightHeightSet(true);
WaylineWaypointYawParam waypointYawParam=new WaylineWaypointYawParam();
waypointYawParam.setYawMode(WaylineWaypointYawMode.FOLLOW_WAYLINE);
waypointInfo.setGlobalYawParam(waypointYawParam);
waypointInfo.setIsTemplateGlobalYawParamSet(true);
WaylineWaypointGimbalHeadingParam waypointGimbalHeadingParam=new WaylineWaypointGimbalHeadingParam();
waypointGimbalHeadingParam.setHeadingMode(WaylineWaypointGimbalHeadingMode.FOLLOW_WAYLINE);
waypointGimbalHeadingParam.setYawAngle(0.0);
waypointGimbalHeadingParam.setPitchAngle(0.0);
waypointInfo.setGlobalGimbalHeadingParam(waypointGimbalHeadingParam);
waypointInfo.setGlobalTurnMode(WaylineWaypointTurnMode.COORDINATE_TURN);
waypointInfo.setIsTemplateGlobalTurnModeSet(true);
waypointInfo.setWaypoints(wpList);
waypointInfo.setUseStraightLine(true);
/* 5. <wpml:coordinateParam> */
WaylineCoordinateParam coordParam = new WaylineCoordinateParam();
coordParam.setCoordinateMode(WaylineCoordinateMode.WGS84);
coordParam.setAltitudeMode(WaylineAltitudeMode.RELATIVE_TO_START_POINT);
coordParam.setPositioningType(WaylinePositioningType.GPS);
/* 6. <wpml:template> */
Template template = new Template();
template.setTemplateId(0);
template.setCoordinateParam(coordParam);
template.setTransitionalSpeed((double)data.getMaxSpeed());
template.setWaypointInfo(waypointInfo);
template.setUseGlobalTransitionalSpeed(true);
template.setAutoFlightSpeed((double)data.getMaxSpeed());
//不写就报错
template.setPayloadParam(new ArrayList<>());
/* 7. 生成文件 */
WPMZManager.getInstance().generateKMZFile(kmz.getAbsolutePath(), mission, config, template);
//验证这个kmz
WaylineCheckErrorMsg result= WPMZManager.getInstance().checkValidation(kmz.getAbsolutePath());
LogUtil.log("qwq",result.toString());
if (result.getValue().isEmpty()) {
LogUtil.log("qwq", "KMZ 校验通过");
sendEvent2Server("一键起飞航线文件生成成功", 1);
return true;
} else {
// 其他错误码照旧报错
LogUtil.log("qwq", "校验失败,错误码:" + result.getValue());
sendEvent2Server("一键起飞航线文件生成失败错误码:"+result.getValue(), 1);
return false;
}
}
}

View File

@ -1,292 +0,0 @@
//package com.aros.apron.tools;
//
//import static org.opencv.core.Core.BORDER_DEFAULT;
//import static org.opencv.core.Core.extractChannel;
//
//import android.content.Context;
//import android.util.Log;
//
//import org.opencv.aruco.Aruco;
//import org.opencv.aruco.Dictionary;
//import org.opencv.core.Core;
//import org.opencv.core.CvType;
//import org.opencv.core.Mat;
//import org.opencv.core.MatOfDouble;
//import org.opencv.core.MatOfPoint3f;
//import org.opencv.core.MatOfRect;
//import org.opencv.core.Point;
//import org.opencv.core.Rect;
//import org.opencv.core.Scalar;
//import org.opencv.core.Size;
//import org.opencv.imgproc.Imgproc;
//import org.opencv.objdetect.CascadeClassifier;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import dji.v5.manager.aircraft.virtualstick.VirtualStickManager;
//
//public class OpenCVHelper {
// private static final Scalar FACE_RECT_COLOR = new Scalar(0, 255, 0, 255);
// private Context context;
// private MatOfPoint3f objPoints;
// private Mat intrinsic;
// private MatOfDouble distortion;
// private Mat logoImg;
// private MatOfPoint3f objectPoints;
//
// public OpenCVHelper(Context context) {
// this.context = context;
// }
//
// public Mat defaultImageProcessing(Mat input) {
// Imgproc.putText(input, "Default", new Point(150, 40), 1, 4, new Scalar(255, 255, 255), 2, 8, false);
// return input;
// }
//
// public Mat convertToGray(Mat input) {
// Mat output = new Mat();
// Imgproc.cvtColor(input, output, Imgproc.COLOR_RGBA2GRAY);
// return output;
// }
//
// public Mat detectEdgesUsingCanny(Mat input) {
// Mat output = new Mat();
// Imgproc.Canny(input, output, 80, 100);
// return output;
// }
//
// public Mat detectEdgesUsingLaplacian(Mat input) {
// Mat grayImg = new Mat();
// Mat intermediateMat = new Mat();
// Mat output = new Mat();
// Imgproc.cvtColor(input, grayImg, Imgproc.COLOR_RGBA2GRAY);
// Imgproc.GaussianBlur(grayImg, grayImg, new Size(3, 3), 0, 0);
// Imgproc.Laplacian(grayImg, intermediateMat, CvType.CV_8U, 3, 1, 0, BORDER_DEFAULT);
// Core.convertScaleAbs(intermediateMat, intermediateMat, 10, 0);
// Imgproc.cvtColor(intermediateMat, output, Imgproc.COLOR_GRAY2RGBA, 4);
// grayImg.release();
// intermediateMat.release();
// return output;
// }
//
// public Mat blurImage(Mat input) {
// Mat grayMat = new Mat();
// Mat output = new Mat();
// Imgproc.cvtColor(input, grayMat, Imgproc.COLOR_RGBA2GRAY);
// Imgproc.GaussianBlur(grayMat, output, new Size(35, 35), 0, 0);
// grayMat.release();
// return output;
// }
//
// public Mat detectFaces(Mat input, CascadeClassifier faceDetector) {
// Mat grayImgMat = new Mat();
// MatOfRect faces = new MatOfRect();
// Mat output;
// Imgproc.cvtColor(input, grayImgMat, Imgproc.COLOR_RGBA2GRAY);
// if (faceDetector != null) {
// faceDetector.detectMultiScale(grayImgMat, faces, 1.1, 2, 2, new Size(60, 60), new Size());
// }
// output = input;
// Rect[] facesArray = faces.toArray();
// for (Rect rect : facesArray) {
// Imgproc.rectangle(output, rect.tl(), rect.br(), FACE_RECT_COLOR, 3);
// }
// return output;
// }
//
// public Mat detectArucoTags(Mat input, Dictionary dictionary) {
//
// Mat grayImgMat = new Mat();
// Mat intermediateImgMat = new Mat();
// Mat output = new Mat();
// Imgproc.cvtColor(input, grayImgMat, Imgproc.COLOR_RGBA2GRAY);
// Imgproc.cvtColor(input, intermediateImgMat, Imgproc.COLOR_RGBA2RGB);
// Mat ids = new Mat();
// List<Mat> corners = new ArrayList<>();
// Aruco.detectMarkers(grayImgMat, dictionary, corners, ids);
// if (ids.depth() > 0) {
//// Log.e("检测到TAG", "----1111------");
// Aruco.drawDetectedMarkers(intermediateImgMat, corners, ids, new Scalar(255, 0, 255));
// moveOnArucoDetected(ids, corners, intermediateImgMat.width(), intermediateImgMat.height());
// }
// Imgproc.cvtColor(intermediateImgMat, output, Imgproc.COLOR_RGB2BGR);
// Imgproc.cvtColor(output, output, Imgproc.COLOR_BGR2RGBA, 4);
// grayImgMat.release();
// intermediateImgMat.release();
// return output;
// }
//
// private void moveOnArucoDetected(Mat ids,
// List<Mat> corners,
// int imageWidth,
// int imageHeight) {
// ////执行逻辑来决定将无人机移动到哪里
// ////计算标记中心
// Scalar markerCenter = new Scalar(0, 0);
// for (Mat corner : corners) {
// markerCenter = Core.mean(corner);
// }
//// Log.e("markerCenter:", markerCenter.toString());
//// Log.e("imageWidth" + imageWidth, "imageHeight" + imageHeight);
// //使所需的标签位于图像框的中心
// //计算相对于图像中心的图像矢量
// Scalar imageVector = new Scalar(markerCenter.val[0] - imageWidth / 2f, markerCenter.val[1] - imageHeight / 2f);
// //将矢量从图像坐标转换为无人机导航坐标
// Scalar motionVector = convertImageVectorToMotionVector(imageVector);
// //如果没有检测到标签则无需移动
// if (ids.size().empty()) {
// motionVector = new Scalar(0, 0);
//// Log.e("未检测到TAG","----1111------");
// }
// if (imageVector.val[0] < 100 && imageVector.val[0] > -100 && imageVector.val[1] < 100 && imageVector.val[1] > -100) {
// VirtualStickManager.getInstance().getLeftStick().setVerticalPosition(-30);
// } else {
// if (imageVector.val[0] < 0) {
// VirtualStickManager.getInstance().getRightStick().setHorizontalPosition(-10);
// }
// if (imageVector.val[0] > 0) {
// VirtualStickManager.getInstance().getRightStick().setHorizontalPosition(10);
// }
// if (imageVector.val[1] < 0) {
// VirtualStickManager.getInstance().getRightStick().setVerticalPosition(-10);
// }
// if (imageVector.val[1] > 0) {
// VirtualStickManager.getInstance().getRightStick().setVerticalPosition(10);
// }
// }
// }
//
//// public void doDroneMoveUsingImage(Mat input, DroneHelper droneHelper) {
//// /*
//// * Remember this function is called every time
//// * a frame is available. So don't do long loop here.
//// */
//// Imgproc.cvtColor(input, input, Imgproc.COLOR_BGR2YUV);
//// extractChannel(input, input, 0);
//// FlightControlData controlData =
//// new FlightControlData(0.1f, 0.0f, 0.0f, 0.0f); //pitch, roll, yaw, verticalThrottle
//// droneHelper.sendMovementCommand(controlData);
//// }
//
// public Mat doAROnImage(Mat input, Dictionary dictionary, DroneHelper droneHelper) {
// //TODO:
// // Since this is the bonus part, only high-level instructions will be provided
// // One way you can do this is to:
// // 1. Identify the Aruco tags with corner pixel location
// // Hint:Aruco.detectMarkers(...)
// // 2. For each corner in 3D space, define their 3D locations
// // The 3D locations you defined here will determine the origin of your coordinate frame
// // 3. Given the 3D locations you defined, their 2D pixel location in the image, and camera parameters
// // You can calculate the 6 DOF of the camera relative to the tag coordinate frame
// // Hint: Calib3d.solvePnP(...)
// // 4. To put artificial object in the image, you need to create 3D points first and project them into 2D image
// // With the projected image points, you can draw lines or polygon
// // Hint: Calib3d.projectPoints(...);
// // 5. To put dji image on a certain location,
// // you need find the homography between the projected 4 corners and the 4 corners of the logo image
// // Hint: Calib3d.findHomography(...);
// // 6. Once the homography is found, warp the image with perspective
// // Hint: Imgproc.warpPerspective(...);
// // 7. Now you have the warped logo image in the right location, just overlay them on top of the camera image
// Mat output = new Mat();
// Mat grayMat = convertToGray(input);
//
// //TODO: Do your magic!!!
// // Hint how to overlay warped logo onto the original camera image
// /*
// Imgproc.cvtColor(logoWarped, grayMat, Imgproc.COLOR_BGR2GRAY);
// Imgproc.threshold(grayMat, grayMat, 0, 255, Imgproc.THRESH_BINARY);
// bitwise_not(grayMat, grayInv);
// input.copyTo(src1Final, grayInv);
// logoWarped.copyTo(src2Final, grayMat);
// Core.add(src1Final, src2Final, output);
// */
// //end magic
//
// if (output.empty()) {
// output = grayMat;
// }
//
// return output;
// }
//
// public void startDetectAruco(DroneHelper droneHelper) {
//// droneHelper.enterVirtualStickMode();
//
// droneHelper.setVerticalModeToVelocity();
//
//// droneHelper.setGimbalPitchDegree(-90.0f);
// }
//
// public void startDroneMove(DroneHelper droneHelper) {
//// droneHelper.enterVirtualStickMode();
// droneHelper.setVerticalModeToVelocity();
// }
//
//// public void startDoAR(DroneHelper droneHelper) {
//// droneHelper.enterVirtualStickMode();
//// droneHelper.setVerticalModeToAbsoluteHeight();
//// Bitmap bMap = BitmapFactory.decodeResource(context.getResources(), R.drawable.dji_logo);
//// logoImg = new Mat();
//// Utils.bitmapToMat(bMap, logoImg);
////
//// //Camera calibration code
//// intrinsic = new Mat(3, 3, CvType.CV_32F);
//// intrinsic.put(0,
//// 0,
//// 1.2702029303551683e+03,
//// 0.,
//// 7.0369652952332717e+02,
//// 0.,
//// 1.2682183239938338e+03,
//// 3.1342369745005681e+02,
//// 0.,
//// 0.,
//// 1.);
////
//// distortion = new MatOfDouble(3.2177759275048554e-02,
//// 1.1688831035623757e+00,
//// -1.6742357543049650e-02,
//// 1.4173384809091350e-02,
//// -6.1914718831876847e+00);
////
//// // Please measure the marker size in Meter and enter it here
//// double markerSizeMeters = 0.13;
//// double halfMarkerSize = markerSizeMeters * 0.5;
////
//// // Self-defined tag location in 3D, this is used in step 2 in doAR
//// objPoints = new MatOfPoint3f();
//// List<Point3> point3List = new ArrayList<>();
//// point3List.add(new Point3(-halfMarkerSize, -halfMarkerSize, 0));
//// point3List.add(new Point3(-halfMarkerSize, halfMarkerSize, 0));
//// point3List.add(new Point3(halfMarkerSize, halfMarkerSize, 0));
//// point3List.add(new Point3(halfMarkerSize, -halfMarkerSize, 0));
//// objPoints.fromList(point3List);
////
//// // AR object points in 3D, this is used in step 4 in doAR
//// objectPoints = new MatOfPoint3f();
////
//// List<Point3> point3DList = new ArrayList<>();
//// point3DList.add(new Point3(-halfMarkerSize, -halfMarkerSize, 0));
//// point3DList.add(new Point3(-halfMarkerSize, halfMarkerSize, 0));
//// point3DList.add(new Point3(halfMarkerSize, halfMarkerSize, 0));
//// point3DList.add(new Point3(halfMarkerSize, -halfMarkerSize, 0));
//// point3DList.add(new Point3(-halfMarkerSize, -halfMarkerSize, markerSizeMeters));
//// point3DList.add(new Point3(-halfMarkerSize, halfMarkerSize, markerSizeMeters));
//// point3DList.add(new Point3(halfMarkerSize, halfMarkerSize, markerSizeMeters));
//// point3DList.add(new Point3(halfMarkerSize, -halfMarkerSize, markerSizeMeters));
////
//// objectPoints.fromList(point3DList);
//// }
//
// private Scalar convertImageVectorToMotionVector(Scalar imageVector) {
// double pX = -imageVector.val[1];
// double pY = imageVector.val[0];
// double divisor = Math.sqrt((pX * pX) + (pY * pY));
// pX = pX / divisor;
// pY = pY / divisor;
//
// return new Scalar(pX * 0.2, pY * 0.2);
// }
//}

View File

@ -1,4 +1,4 @@
// package com.aros.apron.tools//
// //
//import android.media.MediaCodec //import android.media.MediaCodec
//import android.util.Pair //import android.util.Pair

View File

@ -1,4 +1,4 @@
//package com.shd.nest.gateway package com.aros.apron.tools//package com.shd.nest.gateway
// //
//import android.provider.MediaStore //import android.provider.MediaStore
//import com.amazonaws.ClientConfiguration //import com.amazonaws.ClientConfiguration