镜头降落
This commit is contained in:
parent
984dadb7bf
commit
1b0de5e340
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -243,12 +243,12 @@ dependencies {
|
||||||
|
|
||||||
|
|
||||||
//vlc拉流
|
//vlc拉流
|
||||||
implementation 'org.videolan.android:libvlc-all:3.6.0'
|
//implementation 'org.videolan.android:libvlc-all:3.6.0'
|
||||||
|
|
||||||
|
|
||||||
//TTS
|
//TTS
|
||||||
|
|
||||||
implementation files('libs/AIKit.aar')
|
implementation files('libs/AIKit.aar')
|
||||||
|
//implementation(name: 'AIKit', ext: 'aar')
|
||||||
|
//implementation files('libs/AIKit.aar')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -129,7 +129,8 @@ class ConfigActivity : BaseActivity() {
|
||||||
configBinding.rbCameraCenter.isChecked = PreferenceUtils.getInstance().cameraLocationType ==1//中间
|
configBinding.rbCameraCenter.isChecked = PreferenceUtils.getInstance().cameraLocationType ==1//中间
|
||||||
configBinding.rbCameraRight.isChecked = PreferenceUtils.getInstance().cameraLocationType ==2//右边
|
configBinding.rbCameraRight.isChecked = PreferenceUtils.getInstance().cameraLocationType ==2//右边
|
||||||
configBinding.rbCameraNull.isChecked = PreferenceUtils.getInstance().cameraLocationType ==3//下视
|
configBinding.rbCameraNull.isChecked = PreferenceUtils.getInstance().cameraLocationType ==3//下视
|
||||||
configBinding.rbCameraMix.isChecked = PreferenceUtils.getInstance().cameraLocationType ==4//融合
|
configBinding.rbCameraMix.isChecked = PreferenceUtils.getInstance().cameraLocationType ==4//融右
|
||||||
|
configBinding.rbCameraMixCenter.isChecked = PreferenceUtils.getInstance().cameraLocationType ==5//融中
|
||||||
|
|
||||||
|
|
||||||
configBinding.btnConfig.setOnClickListener { config() }
|
configBinding.btnConfig.setOnClickListener { config() }
|
||||||
|
|
@ -238,7 +239,7 @@ class ConfigActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configBinding.rbCameraRight.isChecked && !configBinding.rbCameraCenter.isChecked && !configBinding.rbCameraNull.isChecked && !configBinding.rbCameraMix.isChecked) {
|
if (!configBinding.rbCameraRight.isChecked && !configBinding.rbCameraCenter.isChecked && !configBinding.rbCameraNull.isChecked && !configBinding.rbCameraMix.isChecked&& !configBinding.rbCameraMixCenter.isChecked) {
|
||||||
ToastUtil.showToast("未配置主相机位置")
|
ToastUtil.showToast("未配置主相机位置")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -382,6 +383,8 @@ class ConfigActivity : BaseActivity() {
|
||||||
PreferenceUtils.getInstance().cameraLocationType = 3
|
PreferenceUtils.getInstance().cameraLocationType = 3
|
||||||
} else if(configBinding.rbCameraMix.isChecked){
|
} else if(configBinding.rbCameraMix.isChecked){
|
||||||
PreferenceUtils.getInstance().cameraLocationType = 4
|
PreferenceUtils.getInstance().cameraLocationType = 4
|
||||||
|
}else if(configBinding.rbCameraMixCenter.isChecked){
|
||||||
|
PreferenceUtils.getInstance().cameraLocationType = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
ToastUtil.showToast("配置已保存")
|
ToastUtil.showToast("配置已保存")
|
||||||
|
|
|
||||||
|
|
@ -90,8 +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"
|
"tcp://broker.emqx.io"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(PreferenceUtils.getInstance().mqttUserName)){
|
if (TextUtils.isEmpty(PreferenceUtils.getInstance().mqttUserName)){
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,13 @@ import com.aros.apron.manager.OSDManager
|
||||||
import com.aros.apron.manager.PayloadWidgetManager
|
import com.aros.apron.manager.PayloadWidgetManager
|
||||||
import com.aros.apron.manager.PerceptionManager
|
import com.aros.apron.manager.PerceptionManager
|
||||||
import com.aros.apron.manager.RTKManager
|
import com.aros.apron.manager.RTKManager
|
||||||
|
import com.aros.apron.manager.SpeakerManager
|
||||||
import com.aros.apron.manager.StickManager
|
import com.aros.apron.manager.StickManager
|
||||||
import com.aros.apron.manager.StreamManager
|
import com.aros.apron.manager.StreamManager
|
||||||
import com.aros.apron.manager.UdpStreamManager
|
import com.aros.apron.manager.UdpStreamManager
|
||||||
import com.aros.apron.manager.WirelessLinkManager
|
import com.aros.apron.manager.WirelessLinkManager
|
||||||
|
import com.aros.apron.mix.Aprondown
|
||||||
|
import com.aros.apron.mix.Aprongim
|
||||||
import com.aros.apron.tools.AlternateArucoDetect
|
import com.aros.apron.tools.AlternateArucoDetect
|
||||||
import com.aros.apron.tools.ApronArucoDetect
|
import com.aros.apron.tools.ApronArucoDetect
|
||||||
import com.aros.apron.tools.ApronArucoDetectPort
|
import com.aros.apron.tools.ApronArucoDetectPort
|
||||||
|
|
@ -529,6 +532,8 @@ open class MainActivity : BaseActivity() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
fpvParentView = findViewById(R.id.fpv_holder)
|
fpvParentView = findViewById(R.id.fpv_holder)
|
||||||
mDrawerLayout = findViewById(R.id.root_view)
|
mDrawerLayout = findViewById(R.id.root_view)
|
||||||
|
|
@ -704,6 +709,7 @@ open class MainActivity : BaseActivity() {
|
||||||
enableStream()
|
enableStream()
|
||||||
initFpvStream()
|
initFpvStream()
|
||||||
startVtxHeartbeat()
|
startVtxHeartbeat()
|
||||||
|
SpeakerManager.getInstance().initMegaphoneInfo()
|
||||||
|
|
||||||
//PayloadWidgetManager.getInstance().initPayloadInfo();
|
//PayloadWidgetManager.getInstance().initPayloadInfo();
|
||||||
|
|
||||||
|
|
@ -763,8 +769,7 @@ open class MainActivity : BaseActivity() {
|
||||||
LogUtil.log(TAG, "推流类型:" + PreferenceUtils.getInstance().customStreamType)
|
LogUtil.log(TAG, "推流类型:" + PreferenceUtils.getInstance().customStreamType)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (PreferenceUtils.getInstance().cameraLocationType == 4) {
|
} else if (PreferenceUtils.getInstance().cameraLocationType == 4||PreferenceUtils.getInstance().cameraLocationType == 5) {
|
||||||
|
|
||||||
if ((isFlightControllerConnect == null || isFlightControllerConnect != true) && (isCameraConnect == null || isCameraConnect != true)) {
|
if ((isFlightControllerConnect == null || isFlightControllerConnect != true) && (isCameraConnect == null || isCameraConnect != true)) {
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
initDJIManager()
|
initDJIManager()
|
||||||
|
|
@ -802,6 +807,8 @@ open class MainActivity : BaseActivity() {
|
||||||
initMixedStream()
|
initMixedStream()
|
||||||
startVtxHeartbeat()
|
startVtxHeartbeat()
|
||||||
|
|
||||||
|
SpeakerManager.getInstance().initMegaphoneInfo()
|
||||||
|
|
||||||
GeoidManager.getInstance().init(this);
|
GeoidManager.getInstance().init(this);
|
||||||
|
|
||||||
//开启雷达监听器
|
//开启雷达监听器
|
||||||
|
|
@ -904,6 +911,8 @@ open class MainActivity : BaseActivity() {
|
||||||
initCameraStream()
|
initCameraStream()
|
||||||
startVtxHeartbeat()
|
startVtxHeartbeat()
|
||||||
//
|
//
|
||||||
|
SpeakerManager.getInstance().initMegaphoneInfo()
|
||||||
|
|
||||||
|
|
||||||
GeoidManager.getInstance().init(this);
|
GeoidManager.getInstance().init(this);
|
||||||
|
|
||||||
|
|
@ -978,8 +987,8 @@ open class MainActivity : BaseActivity() {
|
||||||
@SuppressLint("SuspiciousIndentation")
|
@SuppressLint("SuspiciousIndentation")
|
||||||
private fun initMixedStream() {
|
private fun initMixedStream() {
|
||||||
// 初始化融合视觉降落识别器
|
// 初始化融合视觉降落识别器
|
||||||
val mixedLanding = MixedVisionLanding.getInstance()
|
//val mixedLanding = MixedVisionLanding.getInstance()
|
||||||
|
|
||||||
// 为 PORT_1(云台相机)添加帧监听器
|
// 为 PORT_1(云台相机)添加帧监听器
|
||||||
cameraManager.addFrameListener(
|
cameraManager.addFrameListener(
|
||||||
ComponentIndexType.PORT_1,
|
ComponentIndexType.PORT_1,
|
||||||
|
|
@ -989,7 +998,34 @@ open class MainActivity : BaseActivity() {
|
||||||
updateVtxHeartbeat()
|
updateVtxHeartbeat()
|
||||||
streamReceive = true
|
streamReceive = true
|
||||||
// 使用融合视觉识别器处理云台相机帧
|
// 使用融合视觉识别器处理云台相机帧
|
||||||
mixedLanding.processGimbalFrame(height, width, frameData, dictionary)
|
//mixedLanding.processGimbalFrame(height, width, frameData, dictionary)
|
||||||
|
//使用云台
|
||||||
|
synchronized(Synchronizedstatus.LOCK_OBJ) {
|
||||||
|
if (!Synchronizedstatus.isIsruningframe() && Synchronizedstatus.isAprongim() && Synchronizedstatus.isSwitchtime()) {
|
||||||
|
try {
|
||||||
|
Synchronizedstatus.setIsruningframe(true)
|
||||||
|
if (startArucoType == 1) {
|
||||||
|
Aprongim.getInstance()?.detectArucoTags(
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
frameData,
|
||||||
|
dictionary
|
||||||
|
)
|
||||||
|
} else if (startArucoType == 2) {
|
||||||
|
AlternateArucoDetect.getInstance()?.detectArucoTags(
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
frameData,
|
||||||
|
dictionary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Synchronizedstatus.setIsruningframe(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为 FPV(下视相机)添加帧监听器
|
// 为 FPV(下视相机)添加帧监听器
|
||||||
|
|
@ -1001,7 +1037,33 @@ open class MainActivity : BaseActivity() {
|
||||||
updateVtxHeartbeat()
|
updateVtxHeartbeat()
|
||||||
streamReceive = true
|
streamReceive = true
|
||||||
// 使用融合视觉识别器处理下视相机帧
|
// 使用融合视觉识别器处理下视相机帧
|
||||||
mixedLanding.processDownwardFrame(height, width, frameData, dictionary)
|
//mixedLanding.processDownwardFrame(height, width, frameData, dictionary)
|
||||||
|
//使用下视觉
|
||||||
|
synchronized(Synchronizedstatus.LOCK_OBJ) {
|
||||||
|
if (!Synchronizedstatus.isIsruningframe() && !Synchronizedstatus.isAprongim() && Synchronizedstatus.isSwitchtime()) {
|
||||||
|
try {
|
||||||
|
Synchronizedstatus.setIsruningframe(true)
|
||||||
|
if (startArucoType == 1) {
|
||||||
|
Aprondown.getInstance()?.detectArucoTags(
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
frameData,
|
||||||
|
dictionary
|
||||||
|
)
|
||||||
|
} else if (startArucoType == 2) {
|
||||||
|
AlternateArucoDetect.getInstance()?.detectArucoTags(
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
frameData,
|
||||||
|
dictionary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Synchronizedstatus.setIsruningframe(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1086,13 +1148,6 @@ open class MainActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// private val mLoaderCallback: BaseLoaderCallback = object : BaseLoaderCallback(this) {
|
// private val mLoaderCallback: BaseLoaderCallback = object : BaseLoaderCallback(this) {
|
||||||
// override fun onManagerConnected(status: Int) {
|
// override fun onManagerConnected(status: Int) {
|
||||||
// if (status == SUCCESS) {
|
// if (status == SUCCESS) {
|
||||||
|
|
@ -1114,7 +1169,6 @@ open class MainActivity : BaseActivity() {
|
||||||
object : CommonCallbacks.CompletionCallbackWithParam<EmptyMsg?> {
|
object : CommonCallbacks.CompletionCallbackWithParam<EmptyMsg?> {
|
||||||
override fun onSuccess(emptyMsg: EmptyMsg?) {
|
override fun onSuccess(emptyMsg: EmptyMsg?) {
|
||||||
LogUtil.log(TAG, "取消降落,识别机库二维码")
|
LogUtil.log(TAG, "取消降落,识别机库二维码")
|
||||||
|
|
||||||
if (PreferenceUtils.getInstance().cameraLocationType == 3) {
|
if (PreferenceUtils.getInstance().cameraLocationType == 3) {
|
||||||
Handler().postDelayed(Runnable {
|
Handler().postDelayed(Runnable {
|
||||||
if (!ApronArucoDetect.getInstance().isTriggerSuccess) {
|
if (!ApronArucoDetect.getInstance().isTriggerSuccess) {
|
||||||
|
|
@ -1123,6 +1177,14 @@ open class MainActivity : BaseActivity() {
|
||||||
AlternateLandingManager.getInstance().startTaskProcess(null)
|
AlternateLandingManager.getInstance().startTaskProcess(null)
|
||||||
}
|
}
|
||||||
}, 6000)
|
}, 6000)
|
||||||
|
} else if (PreferenceUtils.getInstance().cameraLocationType == 4 ||PreferenceUtils.getInstance().cameraLocationType == 5) {
|
||||||
|
Handler().postDelayed(Runnable {
|
||||||
|
if (!Aprongim.getInstance().isTriggerSuccess) {
|
||||||
|
LogUtil.log(TAG, "图传异常:飞往备降点")
|
||||||
|
//测试图传丢失
|
||||||
|
AlternateLandingManager.getInstance().startTaskProcess(null)
|
||||||
|
}
|
||||||
|
}, 6000)
|
||||||
} else {
|
} else {
|
||||||
Handler().postDelayed(Runnable {
|
Handler().postDelayed(Runnable {
|
||||||
if (!ApronArucoDetectPort.getInstance().isTriggerSuccess) {
|
if (!ApronArucoDetectPort.getInstance().isTriggerSuccess) {
|
||||||
|
|
@ -1138,12 +1200,15 @@ open class MainActivity : BaseActivity() {
|
||||||
startArucoType = 1
|
startArucoType = 1
|
||||||
ApronArucoDetect.getInstance().setDetectedBigMarkers()
|
ApronArucoDetect.getInstance().setDetectedBigMarkers()
|
||||||
ApronArucoDetectPort.getInstance().setDetectedBigMarkers()
|
ApronArucoDetectPort.getInstance().setDetectedBigMarkers()
|
||||||
|
Aprongim.getInstance().setDetectedBigMarkers()
|
||||||
|
Aprondown.getInstance().setDetectedBigMarkers()
|
||||||
|
|
||||||
|
|
||||||
DroneHelper.getInstance().setGimbalPitchDegree()
|
DroneHelper.getInstance().setGimbalPitchDegree()
|
||||||
//每次触发识别二维码时,为避免获取控制权失败,使多次获取控制权
|
//每次触发识别二维码时,为避免获取控制权失败,使多次获取控制权
|
||||||
DroneHelper.getInstance().isVirtualStickEnable = false
|
DroneHelper.getInstance().isVirtualStickEnable = false
|
||||||
DroneHelper.getInstance().setVerticalModeToVelocity()
|
DroneHelper.getInstance().setVerticalModeToVelocity()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(error: IDJIError) {
|
override fun onFailure(error: IDJIError) {
|
||||||
if (startArucoType == 1) {
|
if (startArucoType == 1) {
|
||||||
return
|
return
|
||||||
|
|
@ -1152,6 +1217,10 @@ open class MainActivity : BaseActivity() {
|
||||||
LogUtil.log(TAG, "取消降落,识别机库二维码失败:" + Gson().toJson(error))
|
LogUtil.log(TAG, "取消降落,识别机库二维码失败:" + Gson().toJson(error))
|
||||||
ApronArucoDetect.getInstance().setDetectedBigMarkers()
|
ApronArucoDetect.getInstance().setDetectedBigMarkers()
|
||||||
ApronArucoDetectPort.getInstance().setDetectedBigMarkers()
|
ApronArucoDetectPort.getInstance().setDetectedBigMarkers()
|
||||||
|
Aprongim.getInstance().setDetectedBigMarkers()
|
||||||
|
Aprondown.getInstance().setDetectedBigMarkers()
|
||||||
|
|
||||||
|
|
||||||
DroneHelper.getInstance().setGimbalPitchDegree()
|
DroneHelper.getInstance().setGimbalPitchDegree()
|
||||||
//每次触发识别二维码时,为避免获取控制权失败,使多次获取控制权
|
//每次触发识别二维码时,为避免获取控制权失败,使多次获取控制权
|
||||||
DroneHelper.getInstance().isVirtualStickEnable = false
|
DroneHelper.getInstance().isVirtualStickEnable = false
|
||||||
|
|
@ -1167,20 +1236,28 @@ open class MainActivity : BaseActivity() {
|
||||||
LogUtil.log(TAG, "取消降落,识别备降点二维码")
|
LogUtil.log(TAG, "取消降落,识别备降点二维码")
|
||||||
if (PreferenceUtils.getInstance().cameraLocationType == 3) {
|
if (PreferenceUtils.getInstance().cameraLocationType == 3) {
|
||||||
Handler().postDelayed(Runnable {
|
Handler().postDelayed(Runnable {
|
||||||
if (!AlternateArucoDetect.getInstance().isTriggerSuccess) {
|
if (!ApronArucoDetect.getInstance().isTriggerSuccess) {
|
||||||
LogUtil.log(TAG, "图传异常:备降点直接降落")
|
LogUtil.log(TAG, "图传异常:飞往备降点")
|
||||||
//测试图传丢失
|
//测试图传丢失
|
||||||
FlightManager.getInstance().startAutoLanding(null)
|
AlternateLandingManager.getInstance().startTaskProcess(null)
|
||||||
}
|
}
|
||||||
}, 4000)
|
}, 6000)
|
||||||
|
} else if (PreferenceUtils.getInstance().cameraLocationType == 4|| PreferenceUtils.getInstance().cameraLocationType==5) {
|
||||||
|
Handler().postDelayed(Runnable {
|
||||||
|
if (!Aprongim.getInstance().isTriggerSuccess) {
|
||||||
|
LogUtil.log(TAG, "图传异常:飞往备降点")
|
||||||
|
//测试图传丢失
|
||||||
|
AlternateLandingManager.getInstance().startTaskProcess(null)
|
||||||
|
}
|
||||||
|
}, 6000)
|
||||||
} else {
|
} else {
|
||||||
Handler().postDelayed(Runnable {
|
Handler().postDelayed(Runnable {
|
||||||
if (!AlternateArucoDetect.getInstance().isTriggerSuccess) {
|
if (!ApronArucoDetectPort.getInstance().isTriggerSuccess) {
|
||||||
LogUtil.log(TAG, "图传异常:备降点直接降落")
|
LogUtil.log(TAG, "图传异常:飞往备降点")
|
||||||
//测试图传丢失
|
//测试图传丢失
|
||||||
FlightManager.getInstance().startAutoLanding(null)
|
AlternateLandingManager.getInstance().startTaskProcess(null)
|
||||||
}
|
}
|
||||||
}, 4000)
|
}, 6000)
|
||||||
}
|
}
|
||||||
if (startArucoType == 2) {
|
if (startArucoType == 2) {
|
||||||
return
|
return
|
||||||
|
|
@ -1208,12 +1285,13 @@ open class MainActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
FLAG_DOWN_LAND ->
|
FLAG_DOWN_LAND -> {
|
||||||
{
|
|
||||||
|
|
||||||
//重置降落变量
|
//重置降落变量
|
||||||
ApronArucoDetect.getInstance().setStartAruco(false);
|
ApronArucoDetect.getInstance().setStartAruco(false);
|
||||||
ApronArucoDetectPort.getInstance().setStartAruco(false);
|
ApronArucoDetectPort.getInstance().setStartAruco(false);
|
||||||
|
Aprongim.getInstance().setStartAruco(false);
|
||||||
|
Aprondown.getInstance().setStartAruco(false);
|
||||||
|
|
||||||
|
|
||||||
KeyManager.getInstance().performAction<EmptyMsg>(
|
KeyManager.getInstance().performAction<EmptyMsg>(
|
||||||
KeyTools.createKey<EmptyMsg, EmptyMsg>(FlightControllerKey.KeyStartAutoLanding),
|
KeyTools.createKey<EmptyMsg, EmptyMsg>(FlightControllerKey.KeyStartAutoLanding),
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,129 @@
|
||||||
package com.aros.apron.app
|
package com.aros.apron.app
|
||||||
|
|
||||||
|
import android.R
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
import com.aros.apron.models.MSDKManagerVM
|
import com.aros.apron.models.MSDKManagerVM
|
||||||
import com.aros.apron.models.globalViewModels
|
import com.aros.apron.models.globalViewModels
|
||||||
import com.aros.apron.tools.LogUtil
|
import com.aros.apron.tools.LogUtil
|
||||||
|
import com.aros.apron.tools.XTtsPcmGenerator
|
||||||
|
import com.aros.apron.tts.CopyAsset
|
||||||
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.iflytek.aikit.core.AiHelper
|
||||||
|
import com.iflytek.aikit.core.BaseLibrary
|
||||||
|
import com.iflytek.aikit.core.CoreListener
|
||||||
|
import com.iflytek.aikit.core.ErrType
|
||||||
|
import com.iflytek.aikit.core.LogLvl
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
open class ApronApp : Application() {
|
open class ApronApp : Application() {
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getApplication(): Context? {
|
fun getApplication(): Context? {
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
var context: Context? = null
|
|
||||||
|
var context: Context? = null
|
||||||
|
|
||||||
|
// 参数别改(你的密钥)
|
||||||
|
const val APP_ID = "753fd711"
|
||||||
|
const val API_KEY = "35099a7d31abf2259f5ee58cbf8b6791"
|
||||||
|
const val API_SECRET = "ZTdiMDIwYzEwNTA1NjllYjJlYjdmYWFi"
|
||||||
|
const val ABILITY_ID = "e2e44feff" // XTTS 能力 ID
|
||||||
|
const val WORK_DIR = "/storage/self/primary/DJIDemo/cache/tts/" // SDK工作目录
|
||||||
|
|
||||||
|
private var authResult = -1
|
||||||
|
|
||||||
|
fun getAuthResult(): Int {
|
||||||
|
return authResult
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val msdkManagerVM: MSDKManagerVM by globalViewModels()
|
private val msdkManagerVM: MSDKManagerVM by globalViewModels()
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
context=this
|
context = this
|
||||||
initConfig()
|
initConfig()
|
||||||
msdkManagerVM.initMobileSDK(this)
|
msdkManagerVM.initMobileSDK(this)
|
||||||
|
|
||||||
|
// 复制资源文件到指定目录
|
||||||
|
CopyAsset.getInstance(context).copyAssetsToSdcard()
|
||||||
|
// 科大讯飞初始化
|
||||||
|
initXunfeiSDK()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(base: Context?) {
|
override fun attachBaseContext(base: Context?) {
|
||||||
super.attachBaseContext(base)
|
super.attachBaseContext(base)
|
||||||
com.cySdkyc.clx.Helper.install(this)
|
com.cySdkyc.clx.Helper.install(this)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化科大讯飞SDK
|
||||||
|
*/
|
||||||
|
private fun initXunfeiSDK() {
|
||||||
|
// 设置日志信息
|
||||||
|
AiHelper.getInst().setLogInfo(LogLvl.VERBOSE, 1, "$WORK_DIR/aeeLog.txt")
|
||||||
|
|
||||||
|
// 设定初始化参数
|
||||||
|
val params = BaseLibrary.Params.builder()
|
||||||
|
.appId(APP_ID) // 应用ID
|
||||||
|
.apiKey(API_KEY) // APIKEY
|
||||||
|
.apiSecret(API_SECRET) // APISECRET
|
||||||
|
.workDir(WORK_DIR) // SDK工作目录
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// 初始化SDK(在子线程中执行)
|
||||||
|
Thread {
|
||||||
|
AiHelper.getInst().initEntry(applicationContext, params)
|
||||||
|
}.start()
|
||||||
|
|
||||||
|
// 注册SDK初始化状态监听
|
||||||
|
AiHelper.getInst().registerListener(coreListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 授权结果回调
|
||||||
|
private val coreListener = object : CoreListener {
|
||||||
|
override fun onAuthStateChange(type: ErrType, code: Int) {
|
||||||
|
Log.i("AEELog", "core listener code:$code")
|
||||||
|
|
||||||
|
// 使用Handler在主线程中执行UI操作
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
when (type) {
|
||||||
|
ErrType.AUTH -> {
|
||||||
|
authResult = code
|
||||||
|
if (code == 0) {
|
||||||
|
Toast.makeText(applicationContext, "SDK授权成功", Toast.LENGTH_SHORT).show()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(applicationContext, "SDK授权失败,授权码为:$authResult", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ErrType.HTTP -> {
|
||||||
|
Toast.makeText(applicationContext, "SDK状态:HTTP认证结果$code", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Toast.makeText(applicationContext, "SDK状态:其他错误$code", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger 初始化配置
|
* Logger 初始化配置
|
||||||
*/
|
*/
|
||||||
private fun initConfig() {
|
private fun initConfig() {
|
||||||
var formatStrategy = PrettyFormatStrategy.newBuilder()
|
val formatStrategy = PrettyFormatStrategy.newBuilder()
|
||||||
.showThreadInfo(false) // 隐藏线程信息 默认:显示
|
.showThreadInfo(false) // 隐藏线程信息 默认:显示
|
||||||
.methodCount(0) // 决定打印多少行(每一行代表一个方法)默认:2
|
.methodCount(0) // 决定打印多少行(每一行代表一个方法)默认:2
|
||||||
.methodOffset(7) // (Optional) Hides internal method calls up to offset. Default 5
|
.methodOffset(7) // (Optional) Hides internal method calls up to offset. Default 5
|
||||||
|
|
@ -65,12 +140,23 @@ open class ApronApp : Application() {
|
||||||
CrashHandler.getInstance().init()
|
CrashHandler.getInstance().init()
|
||||||
// 初始化 OpenCV
|
// 初始化 OpenCV
|
||||||
if (OpenCVLoader.initLocal()) {
|
if (OpenCVLoader.initLocal()) {
|
||||||
LogUtil.log("qwq","opencv" +
|
LogUtil.log(
|
||||||
"初始化完成")
|
"qwq", "opencv" +
|
||||||
|
"初始化完成"
|
||||||
|
)
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
LogUtil.log("qwq","opencv" +
|
LogUtil.log(
|
||||||
"初始化失败")
|
"qwq", "opencv" +
|
||||||
|
"初始化失败"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTerminate() {
|
||||||
|
super.onTerminate()
|
||||||
|
// 逆初始化SDK
|
||||||
|
AiHelper.getInst().unInit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,6 +29,8 @@ import com.aros.apron.manager.StickManager;
|
||||||
import com.aros.apron.manager.StreamManager;
|
import com.aros.apron.manager.StreamManager;
|
||||||
import com.aros.apron.manager.SystemManager;
|
import com.aros.apron.manager.SystemManager;
|
||||||
import com.aros.apron.manager.TakeOffToPointManager;
|
import com.aros.apron.manager.TakeOffToPointManager;
|
||||||
|
import com.aros.apron.mix.Aprondown;
|
||||||
|
import com.aros.apron.mix.Aprongim;
|
||||||
import com.aros.apron.tools.ApronArucoDetect;
|
import com.aros.apron.tools.ApronArucoDetect;
|
||||||
import com.aros.apron.tools.ApronArucoDetectPort;
|
import com.aros.apron.tools.ApronArucoDetectPort;
|
||||||
import com.aros.apron.tools.Generakmztools;
|
import com.aros.apron.tools.Generakmztools;
|
||||||
|
|
@ -52,7 +54,7 @@ import dji.v5.common.callback.CommonCallbacks;
|
||||||
import dji.v5.common.error.IDJIError;
|
import dji.v5.common.error.IDJIError;
|
||||||
import dji.v5.manager.KeyManager;
|
import dji.v5.manager.KeyManager;
|
||||||
|
|
||||||
public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
|
|
||||||
private String TAG = "MqttCallBack";
|
private String TAG = "MqttCallBack";
|
||||||
Object lock = Synchronizedstatus.LOCK_OBJ;
|
Object lock = Synchronizedstatus.LOCK_OBJ;
|
||||||
|
|
@ -60,11 +62,12 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
|
|
||||||
@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) {
|
||||||
|
|
@ -78,7 +81,9 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
private Runnable vsTimeoutCheck;
|
private Runnable vsTimeoutCheck;
|
||||||
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();
|
||||||
|
|
||||||
|
|
@ -97,7 +102,9 @@ public class MqttCallBack extends BaseManager 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);
|
||||||
|
|
@ -107,11 +114,10 @@ public class MqttCallBack extends BaseManager 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");
|
||||||
|
|
@ -122,9 +128,9 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
MessageDown message = new Gson().fromJson(jsonString, MessageDown.class);
|
MessageDown message = new Gson().fromJson(jsonString, MessageDown.class);
|
||||||
//LogUtil.log(TAG,message.getMethod());
|
//LogUtil.log(TAG,message.getMethod());
|
||||||
|
|
||||||
if(topic.equals(AMSConfig.DOWN_UAV_PSDK_EVENT)){
|
if (topic.equals(AMSConfig.DOWN_UAV_PSDK_EVENT)) {
|
||||||
//负载设置控件
|
//负载设置控件
|
||||||
}else {
|
} else {
|
||||||
switch (message.getMethod()) {
|
switch (message.getMethod()) {
|
||||||
case Constant.PILOT_ON:
|
case Constant.PILOT_ON:
|
||||||
// LogUtil.log(TAG, "收到:遥控器是否开机" + jsonString);
|
// LogUtil.log(TAG, "收到:遥控器是否开机" + jsonString);
|
||||||
|
|
@ -159,19 +165,19 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
CameraManager.getInstance().setCameraVideoStreamSource(message);
|
CameraManager.getInstance().setCameraVideoStreamSource(message);
|
||||||
break;
|
break;
|
||||||
case Constant.FLIGHTTASK_EXECUTE:
|
case Constant.FLIGHTTASK_EXECUTE:
|
||||||
synchronized(lock){
|
synchronized (lock) {
|
||||||
// 检查是否是第一次收到航线指令
|
// 检查是否是第一次收到航线指令
|
||||||
if(Synchronizedstatus.isIsruning()){
|
if (Synchronizedstatus.isIsruning()) {
|
||||||
LogUtil.log(TAG, "自检正在运行");
|
LogUtil.log(TAG, "自检正在运行");
|
||||||
return;
|
return;
|
||||||
} else if(!Synchronizedstatus.getInitStatus()){
|
} else if (!Synchronizedstatus.getInitStatus()) {
|
||||||
Synchronizedstatus.setIsruning(true);
|
Synchronizedstatus.setIsruning(true);
|
||||||
//自检
|
//自检
|
||||||
MissionV3Manager.getInstance().checkVtxWithDelay(()->{
|
MissionV3Manager.getInstance().checkVtxWithDelay(() -> {
|
||||||
Synchronizedstatus.setIsruning(false);
|
Synchronizedstatus.setIsruning(false);
|
||||||
Synchronizedstatus.setInitStatus(true);
|
Synchronizedstatus.setInitStatus(true);
|
||||||
});
|
});
|
||||||
}else if(Synchronizedstatus.getInitStatus()){
|
} else if (Synchronizedstatus.getInitStatus()) {
|
||||||
LogUtil.log(TAG, "收到:航线" + jsonString);
|
LogUtil.log(TAG, "收到:航线" + jsonString);
|
||||||
//设置modecode
|
//设置modecode
|
||||||
Movement.getInstance().setMode_code(1);
|
Movement.getInstance().setMode_code(1);
|
||||||
|
|
@ -197,7 +203,7 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
LogUtil.log(TAG, "收到:返航" + jsonString);
|
LogUtil.log(TAG, "收到:返航" + jsonString);
|
||||||
//自动返航 (如果调用方法失败了 这个设置就有一个问题但是为了方便看懂我就放这里了没放成功的回调里面)
|
//自动返航 (如果调用方法失败了 这个设置就有一个问题但是为了方便看懂我就放这里了没放成功的回调里面)
|
||||||
Movement.getInstance().setMode_code(9);
|
Movement.getInstance().setMode_code(9);
|
||||||
if(!Movement.getInstance().isAlternate()&&!ApronArucoDetectPort.getInstance().isStartAruco()&&!ApronArucoDetect.getInstance().isStartAruco()){
|
if (!Movement.getInstance().isAlternate() && !ApronArucoDetectPort.getInstance().isStartAruco() && !ApronArucoDetect.getInstance().isStartAruco() && !Aprongim.getInstance().isStartAruco() && !Aprondown.getInstance().isStartAruco()) {
|
||||||
// if(Movement.getInstance().getElevation()<15){
|
// if(Movement.getInstance().getElevation()<15){
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
@ -207,9 +213,9 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
FlightManager.getInstance().startGoHome(message);
|
FlightManager.getInstance().startGoHome(message);
|
||||||
}else{
|
} else {
|
||||||
sendMsg2Server(message);
|
sendMsg2Server(message);
|
||||||
sendEvent2Server("正在视觉或飞往备降不允许返航",1);
|
sendEvent2Server("正在视觉或飞往备降不允许返航", 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.INBOUND:
|
case Constant.INBOUND:
|
||||||
|
|
@ -237,18 +243,18 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
// MissionDataBean data = new Gson().fromJson(new Gson().toJson(message.getData()), MissionDataBean.class);
|
// MissionDataBean data = new Gson().fromJson(new Gson().toJson(message.getData()), MissionDataBean.class);
|
||||||
// Boolean generateKmz = Generakmztools.getInstance().generateKmz(data);
|
// Boolean generateKmz = Generakmztools.getInstance().generateKmz(data);
|
||||||
|
|
||||||
synchronized(lock){
|
synchronized (lock) {
|
||||||
if(Synchronizedstatus.isIsruning()){
|
if (Synchronizedstatus.isIsruning()) {
|
||||||
LogUtil.log(TAG, "自检正在运行");
|
LogUtil.log(TAG, "自检正在运行");
|
||||||
return;
|
return;
|
||||||
} else if(!Synchronizedstatus.getInitStatus()){
|
} else if (!Synchronizedstatus.getInitStatus()) {
|
||||||
Synchronizedstatus.setIsruning(true);
|
Synchronizedstatus.setIsruning(true);
|
||||||
//自检
|
//自检
|
||||||
TakeOffToPointManager.getInstance().checkVtxWithDelay(()->{
|
TakeOffToPointManager.getInstance().checkVtxWithDelay(() -> {
|
||||||
Synchronizedstatus.setIsruning(false);
|
Synchronizedstatus.setIsruning(false);
|
||||||
Synchronizedstatus.setInitStatus(true);
|
Synchronizedstatus.setInitStatus(true);
|
||||||
});
|
});
|
||||||
}else if(Synchronizedstatus.getInitStatus()){
|
} else if (Synchronizedstatus.getInitStatus()) {
|
||||||
LogUtil.log(TAG, "收到:一键起飞" + jsonString);
|
LogUtil.log(TAG, "收到:一键起飞" + jsonString);
|
||||||
//设置modecode
|
//设置modecode
|
||||||
Movement.getInstance().setMode_code(1);
|
Movement.getInstance().setMode_code(1);
|
||||||
|
|
@ -321,46 +327,46 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
break;
|
break;
|
||||||
case Constant.CAMERA_SCREEN_DRAG:
|
case Constant.CAMERA_SCREEN_DRAG:
|
||||||
LogUtil.log(TAG, "收到:负载控制—画面拖动控制" + jsonString);
|
LogUtil.log(TAG, "收到:负载控制—画面拖动控制" + jsonString);
|
||||||
if(ApronArucoDetect.getInstance().isStartAruco()||ApronArucoDetectPort.getInstance().isStartAruco()){
|
if (ApronArucoDetect.getInstance().isStartAruco() || ApronArucoDetectPort.getInstance().isStartAruco() || Aprongim.getInstance().isStartAruco() || Aprondown.getInstance().isStartAruco()) {
|
||||||
sendEvent2Server("自动降落不可以动负载",1);
|
sendEvent2Server("自动降落不可以动负载", 1);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
GimbalManager.getInstance().camera_screen_drag(message);
|
GimbalManager.getInstance().camera_screen_drag(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.CAMERA_AIM:
|
case Constant.CAMERA_AIM:
|
||||||
LogUtil.log(TAG, "收到:负载控制—双击成为 AIM" + jsonString);
|
LogUtil.log(TAG, "收到:负载控制—双击成为 AIM" + jsonString);
|
||||||
if(ApronArucoDetect.getInstance().isStartAruco()||ApronArucoDetectPort.getInstance().isStartAruco()){
|
if (ApronArucoDetect.getInstance().isStartAruco() || ApronArucoDetectPort.getInstance().isStartAruco() || Aprongim.getInstance().isStartAruco() || Aprondown.getInstance().isStartAruco()) {
|
||||||
sendEvent2Server("自动降落不可以动负载",1);
|
sendEvent2Server("自动降落不可以动负载", 1);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
CameraManager.getInstance().tapZoomAtTarget(message);
|
CameraManager.getInstance().tapZoomAtTarget(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.CAMERA_FOCAL_LENGTH_SET:
|
case Constant.CAMERA_FOCAL_LENGTH_SET:
|
||||||
LogUtil.log(TAG, "收到:负载控制—变焦" + jsonString);
|
LogUtil.log(TAG, "收到:负载控制—变焦" + jsonString);
|
||||||
if(ApronArucoDetect.getInstance().isStartAruco()||ApronArucoDetectPort.getInstance().isStartAruco()){
|
if (ApronArucoDetect.getInstance().isStartAruco() || ApronArucoDetectPort.getInstance().isStartAruco() || Aprongim.getInstance().isStartAruco() || Aprondown.getInstance().isStartAruco()) {
|
||||||
sendEvent2Server("自动降落不可以动负载",1);
|
sendEvent2Server("自动降落不可以动负载", 1);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
CameraManager.getInstance().setCameraZoomRatios(message);
|
CameraManager.getInstance().setCameraZoomRatios(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.GIMBAL_RESET:
|
case Constant.GIMBAL_RESET:
|
||||||
LogUtil.log(TAG, "收到:负载控制—重置云台" + jsonString);
|
LogUtil.log(TAG, "收到:负载控制—重置云台" + jsonString);
|
||||||
if(ApronArucoDetect.getInstance().isStartAruco()||ApronArucoDetectPort.getInstance().isStartAruco()){
|
if (ApronArucoDetect.getInstance().isStartAruco() || ApronArucoDetectPort.getInstance().isStartAruco() || Aprongim.getInstance().isStartAruco() || Aprondown.getInstance().isStartAruco()) {
|
||||||
sendEvent2Server("自动降落不可以动负载",1);
|
sendEvent2Server("自动降落不可以动负载", 1);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
GimbalManager.getInstance().gimbalReset(message);
|
GimbalManager.getInstance().gimbalReset(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.CAMERA_LOOK_AT:
|
case Constant.CAMERA_LOOK_AT:
|
||||||
LogUtil.log(TAG, "收到:负载控制—Look At" + jsonString);
|
LogUtil.log(TAG, "收到:负载控制—Look At" + jsonString);
|
||||||
if(ApronArucoDetect.getInstance().isStartAruco()||ApronArucoDetectPort.getInstance().isStartAruco()){
|
if (ApronArucoDetect.getInstance().isStartAruco() || ApronArucoDetectPort.getInstance().isStartAruco() || Aprongim.getInstance().isStartAruco() || Aprondown.getInstance().isStartAruco()) {
|
||||||
sendEvent2Server("自动降落不可以动负载",1);
|
sendEvent2Server("自动降落不可以动负载", 1);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
GimbalManager.getInstance().gimbalLookAt(message);
|
GimbalManager.getInstance().gimbalLookAt(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -410,51 +416,139 @@ public class MqttCallBack extends BaseManager implements MqttCallbackExtended {
|
||||||
break;
|
break;
|
||||||
case Constant.CAMERA_FRAME_ZOOM:
|
case Constant.CAMERA_FRAME_ZOOM:
|
||||||
LogUtil.log(TAG, "收到:框选变焦" + jsonString);
|
LogUtil.log(TAG, "收到:框选变焦" + jsonString);
|
||||||
if(ApronArucoDetect.getInstance().isStartAruco()||ApronArucoDetectPort.getInstance().isStartAruco()){
|
if (ApronArucoDetect.getInstance().isStartAruco() || ApronArucoDetectPort.getInstance().isStartAruco() || Aprongim.getInstance().isStartAruco() || Aprondown.getInstance().isStartAruco()) {
|
||||||
sendEvent2Server("自动降落不可以动负载",1);
|
sendEvent2Server("自动降落不可以动负载", 1);
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
CameraManager.getInstance().camera_frame_zoom(message);
|
CameraManager.getInstance().camera_frame_zoom(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.SPEAKER_AUDIO_PLAY_START:
|
case Constant.SPEAKER_AUDIO_PLAY_START:
|
||||||
LogUtil.log(TAG, "收到:喊话器-开始播放音频" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-开始播放音频" + jsonString);
|
||||||
SpeakerProgressReporter.getInstance().startAudioReport(2);
|
SpeakerProgressReporter.getInstance().startAudioReport(2);
|
||||||
SpeakerManager.getInstance().speakerAudioPlayStart(message);
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerAudioPlayStart(message);
|
||||||
|
Synchronizedstatus.setSpeakrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.SPEAKER_TTS_PLAY_START:
|
case Constant.SPEAKER_TTS_PLAY_START:
|
||||||
LogUtil.log(TAG, "收到:喊话器-开始播放TTS文本" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-开始播放TTS文本" + jsonString);
|
||||||
SpeakerProgressReporter.getInstance().startTTSReport(2);
|
SpeakerProgressReporter.getInstance().startTTSReport(2);
|
||||||
SpeakerManager.getInstance().speakerTTSPlayStart(message, 0);
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerTTSPlayStart(message, 0);
|
||||||
|
Synchronizedstatus.setSpeakTTSrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.SPEAKER_REPLAY:
|
case Constant.SPEAKER_REPLAY:
|
||||||
LogUtil.log(TAG, "收到:喊话器-重新播放" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-重新播放" + jsonString);
|
||||||
SpeakerManager.getInstance().speakerReply(message);
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerReply(message);
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Constant.SPEAKER_PLAY_STOP:
|
case Constant.SPEAKER_PLAY_STOP:
|
||||||
LogUtil.log(TAG, "收到:喊话器-停止播放" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-停止播放" + jsonString);
|
||||||
SpeakerManager.getInstance().speakerStop(message);
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerStop(message);
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Constant.SPEAKER_PLAY_MODE_SET:
|
case Constant.SPEAKER_PLAY_MODE_SET:
|
||||||
LogUtil.log(TAG, "收到:喊话器-设置播放模式" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-设置播放模式" + jsonString);
|
||||||
SpeakerManager.getInstance().speakerPlayModeSet(message);
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerPlayModeSet(message);
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Constant.SPEAKER_PLAY_VOLUME_SET:
|
case Constant.SPEAKER_PLAY_VOLUME_SET:
|
||||||
LogUtil.log(TAG, "收到:喊话器-设置音量" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-设置音量" + jsonString);
|
||||||
SpeakerManager.getInstance().speakerPlayVolumeSet(message);
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerPlayVolumeSet(message);
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Constant.DRC_SPEAKER_TTS_SET:
|
case Constant.DRC_SPEAKER_TTS_SET:
|
||||||
LogUtil.log(TAG, "收到:喊话器-TTS喊话设置" + jsonString);
|
LogUtil.log(TAG, "收到:喊话器-TTS喊话设置" + jsonString);
|
||||||
SpeakerManager.getInstance().speakerTTSPlayStart(message, 1);
|
|
||||||
|
synchronized (lock) {
|
||||||
|
if (!Synchronizedstatus.isSpeakrunning()) {
|
||||||
|
SpeakerManager.getInstance().speakerTTSPlayStart(message, 1);
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(true);
|
||||||
|
}else{
|
||||||
|
sendMsg2Server(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Constant.UAV_LIVE_FPV:
|
case Constant.UAV_LIVE_FPV:
|
||||||
//LogUtil.log(TAG, "收到:切换推流fpv" + jsonString);
|
//LogUtil.log(TAG, "收到:切换推流fpv" + jsonString);
|
||||||
StreamManager.getInstance().switchptspfpv(ComponentIndexType.FPV,message);
|
StreamManager.getInstance().switchptspfpv(ComponentIndexType.FPV, message);
|
||||||
break;
|
break;
|
||||||
case Constant.UAV_LIVE_CAMERA:
|
case Constant.UAV_LIVE_CAMERA:
|
||||||
//LogUtil.log(TAG, "收到:切换推流camera" + jsonString);
|
//LogUtil.log(TAG, "收到:切换推流camera" + jsonString);
|
||||||
StreamManager.getInstance().switchptspport(ComponentIndexType.PORT_1,message);
|
StreamManager.getInstance().switchptspport(ComponentIndexType.PORT_1, message);
|
||||||
break;
|
break;
|
||||||
|
case Constant.DRC_LIGHT_BRIGHTNESS_SET:
|
||||||
|
synchronized (lock) {
|
||||||
|
if (Synchronizedstatus.isLight_brightnessrunning()){
|
||||||
|
return;
|
||||||
|
}else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// LogUtil.log(TAG, "收到:A1亮度设置 " + jsonString);
|
||||||
|
// 处理亮度设置逻辑
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Constant.DRC_LIGHT_MODE_SET:
|
||||||
|
// LogUtil.log(TAG, "收到:A1模式设置 " + jsonString);
|
||||||
|
// 处理模式设置逻辑
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Constant.DRC_LIGHT_FINE_TUNING_SET:
|
||||||
|
// LogUtil.log(TAG, "收到:A1左右角度微调 " + jsonString);
|
||||||
|
// 处理左右角度微调逻辑
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Constant.DRC_LIGHT_CALIBRATION:
|
||||||
|
// LogUtil.log(TAG, "收到:A1云台校准 " + jsonString);
|
||||||
|
// 处理云台校准逻辑
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
// //获取控制权
|
// //获取控制权
|
||||||
// case 60007:
|
// case 60007:
|
||||||
|
|
@ -808,21 +902,23 @@ public class MqttCallBack extends BaseManager 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 {
|
||||||
// if (reconnect) {//重新订阅
|
// if (reconnect) {//重新订阅
|
||||||
LogUtil.log(TAG, "MQtt ConnectComplete:" + serverURI);
|
LogUtil.log(TAG, "MQtt ConnectComplete:" + serverURI);
|
||||||
MqttManager.getInstance().mqttAndroidClient.subscribe(topics, qos);//订阅主题:注册
|
MqttManager.getInstance().mqttAndroidClient.subscribe(topics, qos);//订阅主题:注册
|
||||||
// MqttManager.getInstance().mqttAndroidClient.subscribe(AMSConfig.DOWN_UAV_EVENT_REPLY, 1);//订阅主题:注册
|
// MqttManager.getInstance().mqttAndroidClient.subscribe(AMSConfig.DOWN_UAV_EVENT_REPLY, 1);//订阅主题:注册
|
||||||
// publish(topic,"注册",0);
|
// publish(topic,"注册",0);
|
||||||
// }
|
// }
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.log(TAG, "MQtt ConnectException:" + e.toString());
|
LogUtil.log(TAG, "MQtt ConnectException:" + e.toString());
|
||||||
|
|
|
||||||
|
|
@ -330,4 +330,21 @@ public class Constant {
|
||||||
* 推流切换camera
|
* 推流切换camera
|
||||||
*/
|
*/
|
||||||
public static final String UAV_LIVE_CAMERA="uav_live_camera";
|
public static final String UAV_LIVE_CAMERA="uav_live_camera";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final String DRC_LIGHT_BRIGHTNESS_SET="drc_light_brightness_set";
|
||||||
|
//A1模式设置
|
||||||
|
public static final String DRC_LIGHT_MODE_SET="drc_light_mode_set";
|
||||||
|
//A1左右角度微调
|
||||||
|
public static final String DRC_LIGHT_FINE_TUNING_SET="drc_light_fine_tuning_set";
|
||||||
|
//A1云台校准
|
||||||
|
public static final String DRC_LIGHT_CALIBRATION="drc_light_calibration";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,68 @@ public class MessageDown {
|
||||||
private int volume;
|
private int volume;
|
||||||
private int type;
|
private int type;
|
||||||
private int language;
|
private int language;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Tts tts;
|
private Tts tts;
|
||||||
|
|
||||||
|
//探照灯
|
||||||
|
private int group;
|
||||||
|
// brightness: 亮度 1-100 (int)
|
||||||
|
private int brightness;
|
||||||
|
// mode: 模式 0-关闭 1-常亮 2-爆闪 3-快速爆闪 4-交替爆闪 (enum_int)
|
||||||
|
private int mode;
|
||||||
|
// position: 灯位置 0-左灯 1-右灯 (enum_int)
|
||||||
|
private int position;
|
||||||
|
// value: 左右角度微调值 -3° 到 +3° (int)
|
||||||
|
private int value;
|
||||||
|
// saved: 是否保存 0-否 1-是 (bool)
|
||||||
|
private boolean saved;
|
||||||
|
|
||||||
|
public int getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup(int group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBrightness() {
|
||||||
|
return brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrightness(int brightness) {
|
||||||
|
this.brightness = brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(int mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSaved() {
|
||||||
|
return saved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSaved(boolean saved) {
|
||||||
|
this.saved = saved;
|
||||||
|
}
|
||||||
|
|
||||||
public Tts getTts() {
|
public Tts getTts() {
|
||||||
return tts;
|
return tts;
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,76 @@ public class Synchronizedstatus {
|
||||||
|
|
||||||
private static volatile boolean isruningframe=false;
|
private static volatile boolean isruningframe=false;
|
||||||
|
|
||||||
|
private static volatile boolean aprongim=true;
|
||||||
|
|
||||||
|
|
||||||
|
private static volatile boolean switchtime=true;
|
||||||
|
|
||||||
|
//探照灯线程
|
||||||
|
private static volatile boolean light_brightnessrunning=false;
|
||||||
|
|
||||||
|
//喊话器线程
|
||||||
|
private static volatile boolean speakrunning=false;
|
||||||
|
|
||||||
|
|
||||||
|
private static volatile boolean speakTTSrunning=false;
|
||||||
|
private static volatile boolean speaksetrunning=false;
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean isSpeaksetrunning() {
|
||||||
|
return speaksetrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSpeaksetrunning(boolean speaksetrunning) {
|
||||||
|
Synchronizedstatus.speaksetrunning = speaksetrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpeakTTSrunning() {
|
||||||
|
return speakTTSrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSpeakTTSrunning(boolean speakTTSrunning) {
|
||||||
|
Synchronizedstatus.speakTTSrunning = speakTTSrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpeakrunning() {
|
||||||
|
return speakrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSpeakrunning(boolean speakrunning) {
|
||||||
|
Synchronizedstatus.speakrunning = speakrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLight_brightnessrunning() {
|
||||||
|
return light_brightnessrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLight_brightnessrunning(boolean light_brightnessrunning) {
|
||||||
|
Synchronizedstatus.light_brightnessrunning = light_brightnessrunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSwitchtime() {
|
||||||
|
return switchtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSwitchtime(boolean switchtime) {
|
||||||
|
Synchronizedstatus.switchtime = switchtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAprongim() {
|
||||||
|
return aprongim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAprongim(boolean aprongim) {
|
||||||
|
Synchronizedstatus.aprongim = aprongim;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isIsruningframe() {
|
public static boolean isIsruningframe() {
|
||||||
return isruningframe;
|
return isruningframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void setIsruningframe(boolean isruningframe) {
|
public static void setIsruningframe(boolean isruningframe) {
|
||||||
Synchronizedstatus.isruningframe = isruningframe;
|
Synchronizedstatus.isruningframe = isruningframe;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,123 @@
|
||||||
package com.aros.apron.entity;
|
package com.aros.apron.entity;
|
||||||
|
|
||||||
|
|
||||||
public class XTTSParams {
|
public class XTTSParams {
|
||||||
|
|
||||||
public String vcn = "xiaoyan";
|
// 默认参数值
|
||||||
public int language =1 ;
|
public static final String DEFAULT_VCN = "xiaoyan";
|
||||||
public int pitch = 50;
|
public static final int DEFAULT_LANGUAGE = 1;
|
||||||
public int speed = 50;
|
public static final int DEFAULT_PITCH = 50;
|
||||||
public int volume = 100;
|
public static final int DEFAULT_SPEED = 50;
|
||||||
|
public static final int DEFAULT_VOLUME = 100;
|
||||||
|
|
||||||
}
|
// 参数范围
|
||||||
|
public static final int MIN_PITCH = 0;
|
||||||
|
public static final int MAX_PITCH = 100;
|
||||||
|
public static final int MIN_SPEED = 0;
|
||||||
|
public static final int MAX_SPEED = 100;
|
||||||
|
public static final int MIN_VOLUME = 0;
|
||||||
|
public static final int MAX_VOLUME = 100;
|
||||||
|
|
||||||
|
public String vcn = DEFAULT_VCN;
|
||||||
|
public int language = DEFAULT_LANGUAGE;
|
||||||
|
public int pitch = DEFAULT_PITCH;
|
||||||
|
public int speed = DEFAULT_SPEED;
|
||||||
|
public int volume = DEFAULT_VOLUME;
|
||||||
|
|
||||||
|
// 默认构造方法
|
||||||
|
public XTTSParams() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全参数构造方法
|
||||||
|
public XTTSParams(String vcn, int language, int pitch, int speed, int volume) {
|
||||||
|
setVcn(vcn);
|
||||||
|
setLanguage(language);
|
||||||
|
setPitch(pitch);
|
||||||
|
setSpeed(speed);
|
||||||
|
setVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter 和 Setter 方法
|
||||||
|
public String getVcn() {
|
||||||
|
return vcn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVcn(String vcn) {
|
||||||
|
if (vcn != null && !vcn.isEmpty()) {
|
||||||
|
this.vcn = vcn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLanguage(int language) {
|
||||||
|
// 确保语言代码为正数
|
||||||
|
if (language > 0) {
|
||||||
|
this.language = language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPitch() {
|
||||||
|
return pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPitch(int pitch) {
|
||||||
|
// 确保语调在有效范围内
|
||||||
|
this.pitch = Math.max(MIN_PITCH, Math.min(MAX_PITCH, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpeed(int speed) {
|
||||||
|
// 确保语速在有效范围内
|
||||||
|
this.speed = Math.max(MIN_SPEED, Math.min(MAX_SPEED, speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVolume() {
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume(int volume) {
|
||||||
|
// 确保音量在有效范围内
|
||||||
|
this.volume = Math.max(MIN_VOLUME, Math.min(MAX_VOLUME, volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 预设配置方法
|
||||||
|
public static XTTSParams createDefault() {
|
||||||
|
return new XTTSParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XTTSParams createFemaleVoice() {
|
||||||
|
return new XTTSParams("xiaoyan", 1, 50, 50, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XTTSParams createMaleVoice() {
|
||||||
|
return new XTTSParams("xiaofeng", 1, 50, 50, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XTTSParams createFastSpeed() {
|
||||||
|
XTTSParams params = new XTTSParams();
|
||||||
|
params.setSpeed(70);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XTTSParams createSlowSpeed() {
|
||||||
|
XTTSParams params = new XTTSParams();
|
||||||
|
params.setSpeed(30);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "XTTSParams{" +
|
||||||
|
"vcn='" + vcn + '\'' +
|
||||||
|
", language=" + language +
|
||||||
|
", pitch=" + pitch +
|
||||||
|
", speed=" + speed +
|
||||||
|
", volume=" + volume +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.aros.apron.manager;
|
||||||
|
|
||||||
|
public class A1Manager {
|
||||||
|
|
||||||
|
private String TAG = this.getClass().getSimpleName();
|
||||||
|
public A1Manager() {
|
||||||
|
}
|
||||||
|
private static class A1Managerholder {
|
||||||
|
private static final A1Manager INSTANCE = new A1Manager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static A1Manager getInstance() {
|
||||||
|
return A1Manager.A1Managerholder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//探照灯亮度设置
|
||||||
|
public void setdrc_light_brightness_set(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//探照灯模式设置
|
||||||
|
public void setdrc_light_mode_set(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//探照灯左右角度微调
|
||||||
|
public void setdrc_light_fine_tuning_set(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// 探照灯云台校准
|
||||||
|
public void setdrc_light_calibrationt(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -86,6 +86,7 @@ public class CameraManager extends BaseManager {
|
||||||
panoHandler.removeCallbacks(panoRunnable);
|
panoHandler.removeCallbacks(panoRunnable);
|
||||||
|
|
||||||
sendCameraPhotoTakeProgress2Server(); // 最后报一次
|
sendCameraPhotoTakeProgress2Server(); // 最后报一次
|
||||||
|
Movement.getInstance().setMode_code(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -139,11 +140,12 @@ public void initCameraInfo() {
|
||||||
// Movement.getInstance().setPhoto_status("fail");
|
// Movement.getInstance().setPhoto_status("fail");
|
||||||
} else if (t1 == VisionPhotoPanoramaMissionState.PROCESSING) {
|
} else if (t1 == VisionPhotoPanoramaMissionState.PROCESSING) {
|
||||||
Movement.getInstance().setPhoto_current_step(3005);
|
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");
|
|
||||||
}
|
}
|
||||||
|
// else if (t1 == VisionPhotoPanoramaMissionState.FORBIDDEN) {
|
||||||
|
// Movement.getInstance().setPhoto_result(1);
|
||||||
|
// Movement.getInstance().setPhoto_current_step(3000);
|
||||||
|
// Movement.getInstance().setPhoto_status("fail");
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -663,6 +665,10 @@ public void setCameraMode(MessageDown message) {
|
||||||
} else if (cameraMode == 3) {
|
} else if (cameraMode == 3) {
|
||||||
cameraModevalue = 12;
|
cameraModevalue = 12;
|
||||||
}
|
}
|
||||||
|
// if(cameraMode == 3){
|
||||||
|
// //退出回放模式
|
||||||
|
// MediaManager.getInstance().disablePlayback();
|
||||||
|
// }
|
||||||
|
|
||||||
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),
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ import com.aros.apron.constant.AMSConfig;
|
||||||
import com.aros.apron.entity.ApronExecutionStatus;
|
import com.aros.apron.entity.ApronExecutionStatus;
|
||||||
import com.aros.apron.entity.MessageDown;
|
import com.aros.apron.entity.MessageDown;
|
||||||
import com.aros.apron.entity.Movement;
|
import com.aros.apron.entity.Movement;
|
||||||
|
import com.aros.apron.mix.Aprondown;
|
||||||
|
import com.aros.apron.mix.Aprongim;
|
||||||
import com.aros.apron.tools.AlternateArucoDetect;
|
import com.aros.apron.tools.AlternateArucoDetect;
|
||||||
import com.aros.apron.tools.ApronArucoDetect;
|
import com.aros.apron.tools.ApronArucoDetect;
|
||||||
import com.aros.apron.tools.ApronArucoDetectPort;
|
import com.aros.apron.tools.ApronArucoDetectPort;
|
||||||
|
|
@ -1164,6 +1166,7 @@ public class FlightManager extends BaseManager {
|
||||||
// 释放控制权失败时的处理
|
// 释放控制权失败时的处理
|
||||||
LogUtil.log(TAG, "释放控制权失败,无法执行自动降落: " + error.toString());
|
LogUtil.log(TAG, "释放控制权失败,无法执行自动降落: " + error.toString());
|
||||||
// 可以添加重试逻辑或其他错误处理
|
// 可以添加重试逻辑或其他错误处理
|
||||||
|
EventBus.getDefault().post(FLAG_DOWN_LAND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1178,7 +1181,7 @@ public class FlightManager extends BaseManager {
|
||||||
if (PreferenceUtils.getInstance().getNeedTriggerAlterArucoLand()) {
|
if (PreferenceUtils.getInstance().getNeedTriggerAlterArucoLand()) {
|
||||||
return !isTriggerLanding && (isFlying || isMotorsOn) && AlternateArucoDetect.getInstance().isCanLanding();
|
return !isTriggerLanding && (isFlying || isMotorsOn) && AlternateArucoDetect.getInstance().isCanLanding();
|
||||||
} else {
|
} else {
|
||||||
return !isTriggerLanding && (isFlying || isMotorsOn) && (ApronArucoDetect.getInstance().isCanLanding() || ApronArucoDetectPort.getInstance().isCanLanding());
|
return !isTriggerLanding && (isFlying || isMotorsOn) && (ApronArucoDetect.getInstance().isCanLanding() || ApronArucoDetectPort.getInstance().isCanLanding()|| Aprongim.getInstance().isCanLanding()|| Aprondown.getInstance().isCanLanding());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1199,6 +1202,9 @@ public class FlightManager extends BaseManager {
|
||||||
sendCloseCabinDoorMsg = false;
|
sendCloseCabinDoorMsg = false;
|
||||||
ApronArucoDetect.getInstance().setCanLanding(false);
|
ApronArucoDetect.getInstance().setCanLanding(false);
|
||||||
ApronArucoDetectPort.getInstance().setCanLanding(false);
|
ApronArucoDetectPort.getInstance().setCanLanding(false);
|
||||||
|
Aprondown.getInstance().setCanLanding(false);
|
||||||
|
Aprongim.getInstance().setCanLanding(false);
|
||||||
|
|
||||||
// 发布事件,通知其他组件停止Aruco检测
|
// 发布事件,通知其他组件停止Aruco检测
|
||||||
EventBus.getDefault().post(FLAG_STOP_ARUCO);
|
EventBus.getDefault().post(FLAG_STOP_ARUCO);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
|
||||||
import com.aros.apron.base.BaseManager;
|
import com.aros.apron.base.BaseManager;
|
||||||
import com.aros.apron.entity.MessageDown;
|
import com.aros.apron.entity.MessageDown;
|
||||||
import com.aros.apron.entity.Movement;
|
import com.aros.apron.entity.Movement;
|
||||||
|
import com.aros.apron.mix.Aprongim;
|
||||||
import com.aros.apron.tools.ApronArucoDetect;
|
import com.aros.apron.tools.ApronArucoDetect;
|
||||||
import com.aros.apron.tools.ApronArucoDetectPort;
|
import com.aros.apron.tools.ApronArucoDetectPort;
|
||||||
import com.aros.apron.tools.LogUtil;
|
import com.aros.apron.tools.LogUtil;
|
||||||
|
|
@ -59,6 +60,12 @@ public class GimbalManager extends BaseManager {
|
||||||
public void initGimbalInfo() {
|
public void initGimbalInfo() {
|
||||||
ApronArucoDetect.getInstance().setDoublePayload(PreferenceUtils.getInstance().getCameraLocationType() == 2);
|
ApronArucoDetect.getInstance().setDoublePayload(PreferenceUtils.getInstance().getCameraLocationType() == 2);
|
||||||
ApronArucoDetectPort.getInstance().setDoublePayload(PreferenceUtils.getInstance().getCameraLocationType() == 2);
|
ApronArucoDetectPort.getInstance().setDoublePayload(PreferenceUtils.getInstance().getCameraLocationType() == 2);
|
||||||
|
|
||||||
|
|
||||||
|
Aprongim.getInstance().setDoublePayload(PreferenceUtils.getInstance().getCameraLocationType() == 4);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LogUtil.log(TAG, "主摄像头位置:" + PreferenceUtils.getInstance().getCameraLocationType());
|
LogUtil.log(TAG, "主摄像头位置:" + PreferenceUtils.getInstance().getCameraLocationType());
|
||||||
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
Boolean isConnect = KeyManager.getInstance().getValue(KeyTools.createKey(FlightControllerKey.KeyConnection));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||||
import com.aros.apron.base.BaseManager;
|
import com.aros.apron.base.BaseManager;
|
||||||
import com.aros.apron.entity.MessageDown;
|
import com.aros.apron.entity.MessageDown;
|
||||||
import com.aros.apron.entity.Movement;
|
import com.aros.apron.entity.Movement;
|
||||||
|
import com.aros.apron.entity.Synchronizedstatus;
|
||||||
import com.aros.apron.entity.XTTSParams;
|
import com.aros.apron.entity.XTTSParams;
|
||||||
import com.aros.apron.tools.LogUtil;
|
import com.aros.apron.tools.LogUtil;
|
||||||
import com.aros.apron.tools.SpeakerProgressReporter;
|
import com.aros.apron.tools.SpeakerProgressReporter;
|
||||||
|
|
@ -45,6 +46,7 @@ public class SpeakerManager extends BaseManager {
|
||||||
return SpeakerHolder.INSTANCE;
|
return SpeakerHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
private int megaphoneStatus;
|
private int megaphoneStatus;
|
||||||
|
private XTtsPcmGenerator ttsGenerator;
|
||||||
public void initMegaphoneInfo() {
|
public void initMegaphoneInfo() {
|
||||||
MegaphoneManager.getInstance().addMegaphoneInfoListener(new MegaphoneInfoListener() {
|
MegaphoneManager.getInstance().addMegaphoneInfoListener(new MegaphoneInfoListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -65,10 +67,16 @@ public class SpeakerManager extends BaseManager {
|
||||||
LogUtil.log(TAG,"喊话器位置设置失败:"+getIDJIErrorMsg(error));
|
LogUtil.log(TAG,"喊话器位置设置失败:"+getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
public void speakerAudioPlayStart(MessageDown message) {
|
public void speakerAudioPlayStart(MessageDown message) {
|
||||||
|
sendMsg2Server(message);
|
||||||
|
//暂停播放
|
||||||
|
stop();
|
||||||
|
|
||||||
if (TextUtils.isEmpty(message.getData().getFile().getUrl())) {
|
if (TextUtils.isEmpty(message.getData().getFile().getUrl())) {
|
||||||
sendFailMsg2Server(message, "喊话文件下载地址为空");
|
sendFailMsg2Server(message, "喊话文件下载地址为空");
|
||||||
|
LogUtil.log(TAG,"喊话文件下载地址为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Request request = new Request.Builder().url(message.getData().getFile().getUrl()).build();
|
Request request = new Request.Builder().url(message.getData().getFile().getUrl()).build();
|
||||||
|
|
@ -76,6 +84,7 @@ public class SpeakerManager extends BaseManager {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e) {
|
public void onFailure(Call call, IOException e) {
|
||||||
sendEvent2Server(".pcm文件下载失败:" + e.toString(), 2);
|
sendEvent2Server(".pcm文件下载失败:" + e.toString(), 2);
|
||||||
|
LogUtil.log(TAG,"pcm文件下载失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -86,7 +95,7 @@ public class SpeakerManager extends BaseManager {
|
||||||
int len = 0;
|
int len = 0;
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
// 储存下载文件的目录
|
// 储存下载文件的目录
|
||||||
File dir = new File(Environment.getExternalStorageDirectory().getPath());
|
File dir = new File("/storage/self/primary/DJIDemo/cache/tts/output/");
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
@ -98,8 +107,14 @@ public class SpeakerManager extends BaseManager {
|
||||||
fos.write(buf, 0, len);
|
fos.write(buf, 0, len);
|
||||||
}
|
}
|
||||||
fos.flush();
|
fos.flush();
|
||||||
|
// 检查 PCM 文件大小
|
||||||
|
LogUtil.log(TAG, "PCM 文件大小: " + file.length() + " bytes");
|
||||||
sendEvent2Server("喊话.pcm文件下载成功", 1);
|
sendEvent2Server("喊话.pcm文件下载成功", 1);
|
||||||
String opusFilePath = PCMTools.INSTANCE.convertToOpusFileSync(file.getAbsolutePath());
|
String opusFilePath = PCMTools.INSTANCE.convertToOpusFileSync(file.getAbsolutePath());
|
||||||
|
// 检查 opus 文件路径和大小
|
||||||
|
File opusFile = new File(opusFilePath);
|
||||||
|
LogUtil.log(TAG, "Opus 文件路径: " + opusFilePath);
|
||||||
|
LogUtil.log(TAG, "Opus 文件大小: " + (opusFile.exists() ? opusFile.length() : 0) + " bytes");
|
||||||
|
|
||||||
Movement.getInstance().setStep_key("download");
|
Movement.getInstance().setStep_key("download");
|
||||||
Movement.getInstance().setTTS_status("in_progress");
|
Movement.getInstance().setTTS_status("in_progress");
|
||||||
|
|
@ -109,6 +124,8 @@ public class SpeakerManager extends BaseManager {
|
||||||
null);
|
null);
|
||||||
MegaphoneManager.getInstance().startPushingFileToMegaphone(fileInfo,
|
MegaphoneManager.getInstance().startPushingFileToMegaphone(fileInfo,
|
||||||
new CommonCallbacks.CompletionCallbackWithProgress<Integer>() {
|
new CommonCallbacks.CompletionCallbackWithProgress<Integer>() {
|
||||||
|
private boolean isCallbackExecuted = false; // 确保回调只执行一次
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressUpdate(Integer integer) {
|
public void onProgressUpdate(Integer integer) {
|
||||||
|
|
||||||
|
|
@ -119,6 +136,12 @@ public class SpeakerManager extends BaseManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
// 确保回调只执行一次
|
||||||
|
if (isCallbackExecuted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isCallbackExecuted = true;
|
||||||
|
|
||||||
LogUtil.log(TAG, "喊话器内容上传成功");
|
LogUtil.log(TAG, "喊话器内容上传成功");
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -127,13 +150,16 @@ public class SpeakerManager extends BaseManager {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
Movement.getInstance().setTTS_status("ok");
|
Movement.getInstance().setTTS_status("ok");
|
||||||
|
|
||||||
sendEvent2Server("喊话器播放音频成功", 1);
|
sendEvent2Server("喊话器播放音频成功", 1);
|
||||||
|
LogUtil.log(TAG,"喊话器播放音频成功");
|
||||||
|
Synchronizedstatus.setSpeakrunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
sendEvent2Server("喊话器播放音频失败:" + getIDJIErrorMsg(error), 2);
|
sendEvent2Server("喊话器播放音频失败:" + getIDJIErrorMsg(error), 2);
|
||||||
|
Synchronizedstatus.setSpeakrunning(false);
|
||||||
|
LogUtil.log(TAG,"喊话器播放音频失败"+ getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -142,17 +168,22 @@ public class SpeakerManager extends BaseManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
|
// 确保回调只执行一次
|
||||||
|
if (isCallbackExecuted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isCallbackExecuted = true;
|
||||||
|
|
||||||
sendFailMsg2Server(message, "喊话器内容上传失败:" + getIDJIErrorMsg(error));
|
sendFailMsg2Server(message, "喊话器内容上传失败:" + getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendEvent2Server("喊话.pcm文件下载失败:" + e.toString(), 2);
|
sendEvent2Server("喊话.pcm文件下载失败:" + e.toString(), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -160,14 +191,17 @@ public class SpeakerManager extends BaseManager {
|
||||||
MegaphoneManager.getInstance().startPlay(new CommonCallbacks.CompletionCallback() {
|
MegaphoneManager.getInstance().startPlay(new CommonCallbacks.CompletionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
sendMsg2Server(message);
|
sendMsg2Server(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
sendFailMsg2Server(message, "喊话器播放音频失败:" + getIDJIErrorMsg(error));
|
sendFailMsg2Server(message, "喊话器播放音频失败:" + getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void speakerStop(MessageDown message) {
|
public void speakerStop(MessageDown message) {
|
||||||
|
|
@ -176,6 +210,7 @@ public class SpeakerManager extends BaseManager {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
SpeakerProgressReporter.getInstance().stopAudioReport();
|
SpeakerProgressReporter.getInstance().stopAudioReport();
|
||||||
SpeakerProgressReporter.getInstance().stopTTSReport();
|
SpeakerProgressReporter.getInstance().stopTTSReport();
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
sendMsg2Server(message);
|
sendMsg2Server(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,23 +218,41 @@ public class SpeakerManager extends BaseManager {
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
SpeakerProgressReporter.getInstance().stopAudioReport();
|
SpeakerProgressReporter.getInstance().stopAudioReport();
|
||||||
SpeakerProgressReporter.getInstance().stopTTSReport();
|
SpeakerProgressReporter.getInstance().stopTTSReport();
|
||||||
sendMsg2Server(message);
|
|
||||||
sendFailMsg2Server(message, "喊话器停止播放失败:" + getIDJIErrorMsg(error));
|
sendFailMsg2Server(message, "喊话器停止播放失败:" + getIDJIErrorMsg(error));
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public void stop(){
|
||||||
|
MegaphoneManager.getInstance().stopPlay(new CommonCallbacks.CompletionCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
SpeakerProgressReporter.getInstance().stopAudioReport();
|
||||||
|
SpeakerProgressReporter.getInstance().stopTTSReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
|
SpeakerProgressReporter.getInstance().stopAudioReport();
|
||||||
|
SpeakerProgressReporter.getInstance().stopTTSReport();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void speakerPlayModeSet(MessageDown message) {
|
public void speakerPlayModeSet(MessageDown message) {
|
||||||
MegaphoneManager.getInstance().setPlayMode(message.getData().getPlay_mode() == 0 ?
|
MegaphoneManager.getInstance().setPlayMode(message.getData().getPlay_mode() == 0 ?
|
||||||
PlayMode.SINGLE : PlayMode.LOOP, new CommonCallbacks.CompletionCallback() {
|
PlayMode.SINGLE : PlayMode.LOOP, new CommonCallbacks.CompletionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
Movement.getInstance().setStep_key("change_work_mode");
|
|
||||||
sendMsg2Server(message);
|
sendMsg2Server(message);
|
||||||
|
Movement.getInstance().setStep_key("change_work_mode");
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
sendFailMsg2Server(message, "喊话器播放模式设置失败:" + getIDJIErrorMsg(error));
|
sendFailMsg2Server(message, "喊话器播放模式设置失败:" + getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -217,60 +270,105 @@ public class SpeakerManager extends BaseManager {
|
||||||
sendFailMsg2Server(message, "喊话器音量设置失败:" + getIDJIErrorMsg(error));
|
sendFailMsg2Server(message, "喊话器音量设置失败:" + getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Synchronizedstatus.setSpeaksetrunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
public void speakerTTSPlayStart(MessageDown message, int type) {
|
public void speakerTTSPlayStart(MessageDown message, int type) {
|
||||||
|
//暂停播放
|
||||||
|
stop();
|
||||||
|
|
||||||
|
LogUtil.log(TAG, "开始执行 speakerTTSPlayStart 方法,type: " + type);
|
||||||
|
// 检查是否正在运行
|
||||||
|
if (Synchronizedstatus.isSpeakTTSrunning()) {
|
||||||
|
LogUtil.log(TAG, "喊话器TTS播放正在运行,跳过本次请求");
|
||||||
|
sendFailMsg2Server(message, "喊话器TTS播放正在运行");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 设置为正在运行
|
||||||
|
Synchronizedstatus.setSpeakTTSrunning(true);
|
||||||
|
LogUtil.log(TAG, "设置 speakTTSrunning 为 true");
|
||||||
|
|
||||||
message.getData().getTts().getMd5();
|
message.getData().getTts().getMd5();
|
||||||
|
// 使用 com.aros.apron.entity.XTTSParams 类型
|
||||||
XTTSParams params = new XTTSParams();
|
XTTSParams params = new XTTSParams();
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
text = message.getData().getTts().getText();
|
text = message.getData().getTts().getText();
|
||||||
|
// 设置默认参数值
|
||||||
|
params.setVcn("xiaofeng");
|
||||||
|
params.setLanguage(1);
|
||||||
|
params.setSpeed(50);
|
||||||
|
params.setVolume(100);
|
||||||
|
LogUtil.log(TAG, "type == 0,text: " + text + ", vcn: " + params.getVcn() + ", language: " + params.getLanguage() + ", speed: " + params.getSpeed() + ", volume: " + params.getVolume());
|
||||||
} else {
|
} else {
|
||||||
if (megaphoneStatus == 2) {
|
if (megaphoneStatus == 2) {
|
||||||
|
LogUtil.log(TAG, "type != 0,megaphoneStatus == 2,执行 stopPlay");
|
||||||
MegaphoneManager.getInstance().stopPlay(new CommonCallbacks.CompletionCallback() {
|
MegaphoneManager.getInstance().stopPlay(new CommonCallbacks.CompletionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
LogUtil.log(TAG, "终止喊话成功");
|
||||||
LogUtil.log(TAG, "终止喊话");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
LogUtil.log(TAG, "终止喊话失败:" + getIDJIErrorMsg(error));
|
LogUtil.log(TAG, "终止喊话失败:" + getIDJIErrorMsg(error));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
params.vcn = message.getData().getType() == 0 ? "xiaofeng" : "xiaoyan";
|
params.setVcn(message.getData().getType() == 0 ? "xiaofeng" : "xiaoyan");
|
||||||
params.language = message.getData().getLanguage() == 0 ? 1 : 2;
|
params.setLanguage(message.getData().getLanguage() == 0 ? 1 : 2);
|
||||||
params.speed = message.getData().getSpeed();
|
params.setSpeed(message.getData().getSpeed());
|
||||||
params.volume = message.getData().getVolume();
|
params.setVolume(message.getData().getVolume());
|
||||||
|
LogUtil.log(TAG, "type != 0,vcn: " + params.getVcn() + ", language: " + params.getLanguage() + ", speed: " + params.getSpeed() + ", volume: " + params.getVolume());
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(text)) {
|
if (TextUtils.isEmpty(text)) {
|
||||||
|
LogUtil.log(TAG, "喊话内容为空,跳过本次请求");
|
||||||
sendFailMsg2Server(message, "喊话失败:喊话内容为空");
|
sendFailMsg2Server(message, "喊话失败:喊话内容为空");
|
||||||
|
Synchronizedstatus.setSpeakTTSrunning(false);
|
||||||
|
LogUtil.log(TAG, "设置 speakTTSrunning 为 false");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XTtsPcmGenerator tts = new XTtsPcmGenerator();
|
LogUtil.log(TAG, "创建 XTtsPcmGenerator 实例");
|
||||||
AiListener listener = tts.buildListener();
|
ttsGenerator = new XTtsPcmGenerator();
|
||||||
tts.init(listener);
|
LogUtil.log(TAG, "准备 PCM 文件");
|
||||||
|
|
||||||
File pcmFile = new File(Utils.getSDCardPath() + "/pcm", "tts_output_local.pcm");
|
// 使用固定的文件夹路径
|
||||||
|
String fixedDirPath = "/storage/self/primary/DJIDemo/cache/tts/output/";
|
||||||
|
File outputDir = new File(fixedDirPath);
|
||||||
|
if (!outputDir.exists()) {
|
||||||
|
LogUtil.log(TAG, "创建输出目录: " + fixedDirPath);
|
||||||
|
outputDir.mkdirs();
|
||||||
|
}
|
||||||
|
// 使用带时间戳的文件名,避免覆盖
|
||||||
|
String fileName = "output_" + System.currentTimeMillis() + ".pcm";
|
||||||
|
File pcmFile = new File(outputDir, fileName);
|
||||||
|
LogUtil.log(TAG, "创建 PCM 文件: " + pcmFile.getAbsolutePath());
|
||||||
|
|
||||||
int synthToPcm = tts.synthToPcm(
|
// 合成文本到固定路径
|
||||||
text,
|
LogUtil.log(TAG, "开始调用 synthToPcm 方法,text: " + text);
|
||||||
params,
|
File pcmFileResult = ttsGenerator.synthToPcm(text, params, pcmFile);
|
||||||
pcmFile
|
if (pcmFileResult != null && pcmFileResult.length() > 0) {
|
||||||
);
|
LogUtil.log(TAG, "合成完成,PCM 文件路径: " + pcmFileResult.getAbsolutePath());
|
||||||
if (synthToPcm == 0) {
|
|
||||||
sendMsg2Server(message);
|
sendMsg2Server(message);
|
||||||
String opusFilePath = PCMTools.INSTANCE.convertToOpusFileSync(pcmFile.getAbsolutePath());
|
// 检查 PCM 文件大小
|
||||||
|
LogUtil.log(TAG, "TTS PCM 文件大小: " + pcmFileResult.length() + " bytes");
|
||||||
|
// 转换为 OPUS 格式
|
||||||
|
LogUtil.log(TAG, "开始转换为 OPUS 格式");
|
||||||
|
String opusFilePath = PCMTools.INSTANCE.convertToOpusFileSync(pcmFileResult.getAbsolutePath());
|
||||||
|
// 检查 opus 文件路径和大小
|
||||||
|
File opusFile = new File(opusFilePath);
|
||||||
|
LogUtil.log(TAG, "TTS Opus 文件路径: " + opusFilePath);
|
||||||
|
LogUtil.log(TAG, "TTS Opus 文件大小: " + (opusFile.exists() ? opusFile.length() : 0) + " bytes");
|
||||||
|
|
||||||
FileInfo fileInfo = new FileInfo(UploadType.VOICE_FILE,
|
FileInfo fileInfo = new FileInfo(UploadType.VOICE_FILE,
|
||||||
new File(opusFilePath),
|
new File(opusFilePath),
|
||||||
null);
|
null);
|
||||||
|
LogUtil.log(TAG, "开始上传文件到喊话器");
|
||||||
MegaphoneManager.getInstance().startPushingFileToMegaphone(fileInfo,
|
MegaphoneManager.getInstance().startPushingFileToMegaphone(fileInfo,
|
||||||
new CommonCallbacks.CompletionCallbackWithProgress<Integer>() {
|
new CommonCallbacks.CompletionCallbackWithProgress<Integer>() {
|
||||||
|
private boolean isCallbackExecuted = false; // 确保回调只执行一次
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressUpdate(Integer integer) {
|
public void onProgressUpdate(Integer integer) {
|
||||||
Movement.getInstance().setTTS_status("in_progress");
|
Movement.getInstance().setTTS_status("in_progress");
|
||||||
|
|
@ -281,21 +379,32 @@ public class SpeakerManager extends BaseManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
// 确保回调只执行一次
|
||||||
|
if (isCallbackExecuted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isCallbackExecuted = true;
|
||||||
|
|
||||||
LogUtil.log(TAG, "喊话器内容上传成功");
|
LogUtil.log(TAG, "喊话器内容上传成功");
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
LogUtil.log(TAG, "开始播放音频");
|
||||||
MegaphoneManager.getInstance().startPlay(new CommonCallbacks.CompletionCallback() {
|
MegaphoneManager.getInstance().startPlay(new CommonCallbacks.CompletionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
Movement.getInstance().setTTS_status("ok");
|
Movement.getInstance().setTTS_status("ok");
|
||||||
Movement.getInstance().setStep_key("play");
|
Movement.getInstance().setStep_key("play");
|
||||||
sendEvent2Server("喊话器播放TTS音频成功", 1);
|
sendEvent2Server("喊话器播放TTS音频成功", 1);
|
||||||
|
LogUtil.log(TAG,"喊话器播放TTS音频成功");
|
||||||
|
Synchronizedstatus.setSpeakTTSrunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
sendEvent2Server("喊话器播放TTS音频失败:" + getIDJIErrorMsg(error), 2);
|
sendEvent2Server("喊话器播放TTS音频失败:" + getIDJIErrorMsg(error), 2);
|
||||||
|
LogUtil.log(TAG,"喊话器播放TTS音频失败qwq" + getIDJIErrorMsg(error));
|
||||||
|
Synchronizedstatus.setSpeakTTSrunning(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -304,11 +413,22 @@ public class SpeakerManager extends BaseManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull IDJIError error) {
|
public void onFailure(@NonNull IDJIError error) {
|
||||||
|
// 确保回调只执行一次
|
||||||
|
if (isCallbackExecuted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isCallbackExecuted = true;
|
||||||
|
|
||||||
sendFailMsg2Server(message, "喊话器内容上传失败:" + getIDJIErrorMsg(error));
|
sendFailMsg2Server(message, "喊话器内容上传失败:" + getIDJIErrorMsg(error));
|
||||||
|
LogUtil.log(TAG, "喊话器内容上传失败:" + getIDJIErrorMsg(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
sendFailMsg2Server(message, "tts合成失败");
|
LogUtil.log(TAG, "合成失败,PCM 文件为空");
|
||||||
|
sendFailMsg2Server(message, "合成失败,PCM 文件为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogUtil.log(TAG, "设置 speakTTSrunning 为 false");
|
||||||
|
LogUtil.log(TAG, "speakerTTSPlayStart 方法执行完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,10 +79,13 @@ public class TakeOffToPointManager extends BaseManager {
|
||||||
Movement.getInstance().setIstakeoffex(true);
|
Movement.getInstance().setIstakeoffex(true);
|
||||||
|
|
||||||
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() + "");
|
||||||
PreferenceUtils.getInstance().setAlternatePointLat(message.getData().getAlternate_land_point().getLatitude() + "");
|
PreferenceUtils.getInstance().setAlternatePointLat(message.getData().getAlternate_land_point().getLatitude() + "");
|
||||||
|
|
||||||
PreferenceUtils.getInstance().setAlternatePointSecurityHeight(
|
PreferenceUtils.getInstance().setAlternatePointSecurityHeight(
|
||||||
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, "生成");
|
LogUtil.log(TAG, "生成");
|
||||||
|
|
|
||||||
|
|
@ -1,133 +1,133 @@
|
||||||
package com.aros.apron.manager;
|
//package com.aros.apron.manager;
|
||||||
|
//
|
||||||
import android.content.Context;
|
//import android.content.Context;
|
||||||
import android.os.Handler;
|
//import android.os.Handler;
|
||||||
import android.os.Looper;
|
//import android.os.Looper;
|
||||||
|
//
|
||||||
import com.aros.apron.tools.LogUtil;
|
//import com.aros.apron.tools.LogUtil;
|
||||||
|
//
|
||||||
import org.videolan.libvlc.LibVLC;
|
//import org.videolan.libvlc.LibVLC;
|
||||||
import org.videolan.libvlc.Media;
|
//import org.videolan.libvlc.Media;
|
||||||
import org.videolan.libvlc.MediaPlayer;
|
//import org.videolan.libvlc.MediaPlayer;
|
||||||
|
//
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* RTSP流检测工具(严格匹配LibVLC 3.6.0源码)
|
// * RTSP流检测工具(严格匹配LibVLC 3.6.0源码)
|
||||||
* 核心:单例、初始化、拉流检测、成功/失败回调(无任何冗余)
|
// * 核心:单例、初始化、拉流检测、成功/失败回调(无任何冗余)
|
||||||
*/
|
// */
|
||||||
public class VlcRtspManager {
|
//public class VlcRtspManager {
|
||||||
private static volatile VlcRtspManager instance;
|
// private static volatile VlcRtspManager instance;
|
||||||
private static final long CHECK_TIMEOUT = 5000L; // 5秒超时
|
// private static final long CHECK_TIMEOUT = 5000L; // 5秒超时
|
||||||
|
//
|
||||||
private LibVLC libVLC;
|
// private LibVLC libVLC;
|
||||||
private MediaPlayer mediaPlayer;
|
// private MediaPlayer mediaPlayer;
|
||||||
private Handler handler = new Handler(Looper.getMainLooper());
|
// private Handler handler = new Handler(Looper.getMainLooper());
|
||||||
private OnRtspCheckListener checkListener;
|
// private OnRtspCheckListener checkListener;
|
||||||
private boolean isChecking = false;
|
// private boolean isChecking = false;
|
||||||
|
//
|
||||||
// 仅保留成功/失败回调
|
// // 仅保留成功/失败回调
|
||||||
public interface OnRtspCheckListener {
|
// public interface OnRtspCheckListener {
|
||||||
void onSuccess(); // 拉流成功
|
// void onSuccess(); // 拉流成功
|
||||||
void onFailed(); // 拉流失败
|
// void onFailed(); // 拉流失败
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 单例
|
// // 单例
|
||||||
private VlcRtspManager() {}
|
// private VlcRtspManager() {}
|
||||||
public static VlcRtspManager getInstance() {
|
// public static VlcRtspManager getInstance() {
|
||||||
if (instance == null) {
|
// if (instance == null) {
|
||||||
synchronized (VlcRtspManager.class) {
|
// synchronized (VlcRtspManager.class) {
|
||||||
if (instance == null) {
|
// if (instance == null) {
|
||||||
instance = new VlcRtspManager();
|
// instance = new VlcRtspManager();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return instance;
|
// return instance;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 初始化(3.6.0 源码级配置)
|
// // 初始化(3.6.0 源码级配置)
|
||||||
public void init(Context context) {
|
// public void init(Context context) {
|
||||||
if (libVLC != null) return;
|
// if (libVLC != null) return;
|
||||||
|
//
|
||||||
List<String> options = new ArrayList<>();
|
// List<String> options = new ArrayList<>();
|
||||||
options.add("--rtsp-tcp");
|
// options.add("--rtsp-tcp");
|
||||||
options.add("--network-caching=500");
|
// options.add("--network-caching=500");
|
||||||
options.add("--vout=none");
|
// options.add("--vout=none");
|
||||||
options.add("--aout=none");
|
// options.add("--aout=none");
|
||||||
options.add("--quiet");
|
// options.add("--quiet");
|
||||||
|
//
|
||||||
libVLC = new LibVLC(context.getApplicationContext(), options);
|
// libVLC = new LibVLC(context.getApplicationContext(), options);
|
||||||
mediaPlayer = new MediaPlayer(libVLC);
|
// mediaPlayer = new MediaPlayer(libVLC);
|
||||||
|
//
|
||||||
// ====================== 核心修正:3.6.0 事件判定(源码级) ======================
|
// // ====================== 核心修正:3.6.0 事件判定(源码级) ======================
|
||||||
// 参考3.6.0源码:MediaPlayer.Event的type是int型,对应EventType枚举的ordinal()
|
// // 参考3.6.0源码:MediaPlayer.Event的type是int型,对应EventType枚举的ordinal()
|
||||||
mediaPlayer.setEventListener(new MediaPlayer.EventListener() {
|
// mediaPlayer.setEventListener(new MediaPlayer.EventListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onEvent(MediaPlayer.Event event) {
|
// public void onEvent(MediaPlayer.Event event) {
|
||||||
// 3.6.0源码中:
|
// // 3.6.0源码中:
|
||||||
// EventType.Playing.ordinal() = 0
|
// // EventType.Playing.ordinal() = 0
|
||||||
// EventType.Error.ordinal() = 1
|
// // EventType.Error.ordinal() = 1
|
||||||
// 直接用整型判定,避开枚举引用错误
|
// // 直接用整型判定,避开枚举引用错误
|
||||||
if (event.type == 0) { // Playing事件
|
// if (event.type == 0) { // Playing事件
|
||||||
if (checkListener != null) checkListener.onSuccess();
|
// if (checkListener != null) checkListener.onSuccess();
|
||||||
stopCheck();
|
// stopCheck();
|
||||||
} else if (event.type == 1) { // Error事件
|
// } else if (event.type == 1) { // Error事件
|
||||||
if (checkListener != null) checkListener.onFailed();
|
// if (checkListener != null) checkListener.onFailed();
|
||||||
stopCheck();
|
// stopCheck();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 检测RTSP流(拉流测试)
|
// // 检测RTSP流(拉流测试)
|
||||||
public void checkRtspStream(String rtspUrl, OnRtspCheckListener listener) {
|
// public void checkRtspStream(String rtspUrl, OnRtspCheckListener listener) {
|
||||||
stopCheck();
|
// stopCheck();
|
||||||
|
//
|
||||||
this.checkListener = listener;
|
// this.checkListener = listener;
|
||||||
this.isChecking = true;
|
// this.isChecking = true;
|
||||||
|
//
|
||||||
// 超时检测
|
// // 超时检测
|
||||||
handler.postDelayed(() -> {
|
// handler.postDelayed(() -> {
|
||||||
if (isChecking) {
|
// if (isChecking) {
|
||||||
if (checkListener != null) checkListener.onFailed();
|
// if (checkListener != null) checkListener.onFailed();
|
||||||
stopCheck();
|
// stopCheck();
|
||||||
}
|
// }
|
||||||
}, CHECK_TIMEOUT);
|
// }, CHECK_TIMEOUT);
|
||||||
|
//
|
||||||
// 拉流(3.6.0 源码级写法)
|
// // 拉流(3.6.0 源码级写法)
|
||||||
try {
|
// try {
|
||||||
Media media = new Media(libVLC, rtspUrl);
|
// Media media = new Media(libVLC, rtspUrl);
|
||||||
mediaPlayer.setMedia(media);
|
// mediaPlayer.setMedia(media);
|
||||||
media.release();
|
// media.release();
|
||||||
mediaPlayer.play();
|
// mediaPlayer.play();
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
LogUtil.log("VlcRtspManager", "拉流异常:" + e.getMessage());
|
// LogUtil.log("VlcRtspManager", "拉流异常:" + e.getMessage());
|
||||||
if (checkListener != null) checkListener.onFailed();
|
// if (checkListener != null) checkListener.onFailed();
|
||||||
stopCheck();
|
// stopCheck();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 停止检测(私有)
|
// // 停止检测(私有)
|
||||||
private void stopCheck() {
|
// private void stopCheck() {
|
||||||
isChecking = false;
|
// isChecking = false;
|
||||||
handler.removeCallbacksAndMessages(null);
|
// handler.removeCallbacksAndMessages(null);
|
||||||
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
// if (mediaPlayer != null && mediaPlayer.isPlaying()) {
|
||||||
mediaPlayer.stop();
|
// mediaPlayer.stop();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 释放资源(可选)
|
// // 释放资源(可选)
|
||||||
public void release() {
|
// public void release() {
|
||||||
stopCheck();
|
// stopCheck();
|
||||||
if (mediaPlayer != null) {
|
// if (mediaPlayer != null) {
|
||||||
mediaPlayer.release();
|
// mediaPlayer.release();
|
||||||
mediaPlayer = null;
|
// mediaPlayer = null;
|
||||||
}
|
// }
|
||||||
if (libVLC != null) {
|
// if (libVLC != null) {
|
||||||
libVLC.release();
|
// libVLC.release();
|
||||||
libVLC = null;
|
// libVLC = null;
|
||||||
}
|
// }
|
||||||
instance = null;
|
// instance = null;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
@ -61,6 +61,7 @@ public class MixedVisionLanding {
|
||||||
private static final int MAX_SWITCH_COUNT = 2;
|
private static final int MAX_SWITCH_COUNT = 2;
|
||||||
private boolean isLanding = false;
|
private boolean isLanding = false;
|
||||||
private boolean isDoublePayload = false;
|
private boolean isDoublePayload = false;
|
||||||
|
private int startArucoType = 0; // 1执行机库二维码识别 2执行备降点二维码识别
|
||||||
|
|
||||||
// ========== 云台相机参数 ==========
|
// ========== 云台相机参数 ==========
|
||||||
private static double GIMBAL_LENS_OFFSET_X = 0;
|
private static double GIMBAL_LENS_OFFSET_X = 0;
|
||||||
|
|
@ -105,6 +106,7 @@ public class MixedVisionLanding {
|
||||||
private boolean downwardDropTimesTag = false;
|
private boolean downwardDropTimesTag = false;
|
||||||
private long downwardStartTime = 0;
|
private long downwardStartTime = 0;
|
||||||
private long downwardEndTime = 0;
|
private long downwardEndTime = 0;
|
||||||
|
private boolean downwardIsYawAligned = false;
|
||||||
|
|
||||||
// ========== 执行器 ==========
|
// ========== 执行器 ==========
|
||||||
private ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
|
private ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
|
||||||
|
|
@ -134,19 +136,24 @@ public class MixedVisionLanding {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startLanding() {
|
public void startLanding() {
|
||||||
LogUtil.log(TAG_LOG, "开始融合视觉降落");
|
synchronized (this) {
|
||||||
isLanding = true;
|
LogUtil.log(TAG_LOG, "开始融合视觉降落");
|
||||||
currentMode = LandingMode.GIMBAL_CAMERA;
|
isLanding = true;
|
||||||
switchCount = 0;
|
currentMode = LandingMode.GIMBAL_CAMERA;
|
||||||
resetGimbalState();
|
switchCount = 0;
|
||||||
resetDownwardState();
|
resetGimbalState();
|
||||||
|
resetDownwardState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopLanding() {
|
public void stopLanding() {
|
||||||
LogUtil.log(TAG_LOG, "停止融合视觉降落");
|
synchronized (this) {
|
||||||
isLanding = false;
|
LogUtil.log(TAG_LOG, "停止融合视觉降落");
|
||||||
resetGimbalState();
|
isLanding = false;
|
||||||
resetDownwardState();
|
startArucoType = 0;
|
||||||
|
resetGimbalState();
|
||||||
|
resetDownwardState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LandingMode getCurrentMode() {
|
public LandingMode getCurrentMode() {
|
||||||
|
|
@ -161,84 +168,100 @@ public class MixedVisionLanding {
|
||||||
return isLanding;
|
return isLanding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStartArucoType() {
|
||||||
|
return startArucoType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartArucoType(int type) {
|
||||||
|
startArucoType = type;
|
||||||
|
}
|
||||||
|
|
||||||
// ========== 云台相机帧处理 ==========
|
// ========== 云台相机帧处理 ==========
|
||||||
public void processGimbalFrame(int height, int width, byte[] data, Dictionary dictionary) {
|
public void processGimbalFrame(int height, int width, byte[] data, Dictionary dictionary) {
|
||||||
if (!isLanding || currentMode != LandingMode.GIMBAL_CAMERA) {
|
synchronized (this) {
|
||||||
return;
|
if (!isLanding || currentMode != LandingMode.GIMBAL_CAMERA || startArucoType == 0) {
|
||||||
}
|
return;
|
||||||
|
|
||||||
gimbalIsTriggerSuccess = true;
|
|
||||||
Movement.getInstance().setVirtualStickEnableReason(2);
|
|
||||||
|
|
||||||
if (gimbalIsStartAruco || gimbalStartFastStick) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentFrame = gimbalFrameCounter++;
|
|
||||||
if (currentFrame % 3 != 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentFrame % 30 != 0) {
|
|
||||||
DroneHelper.getInstance().setGimbalPitchdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
gimbalIsStartAruco = true;
|
|
||||||
if (lastGimbalFuture != null && !lastGimbalFuture.isDone()) {
|
|
||||||
lastGimbalFuture.cancel(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ultHeight = Movement.getInstance().getUltrasonicHeight();
|
|
||||||
updateGimbalLensOffset(ultHeight);
|
|
||||||
|
|
||||||
final int finalUltHeight = ultHeight;
|
|
||||||
lastGimbalFuture = executor.schedule(() -> {
|
|
||||||
try {
|
|
||||||
processGimbalFrameInternal(height, width, data, dictionary, finalUltHeight);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogUtil.log(TAG_LOG, "云台相机处理异常: " + e);
|
|
||||||
gimbalIsStartAruco = false;
|
|
||||||
handleLandingFailure();
|
|
||||||
}
|
}
|
||||||
}, 0, TimeUnit.MILLISECONDS);
|
|
||||||
|
gimbalIsTriggerSuccess = true;
|
||||||
|
Movement.getInstance().setVirtualStickEnableReason(2);
|
||||||
|
|
||||||
|
if (gimbalIsStartAruco || gimbalStartFastStick) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentFrame = gimbalFrameCounter++;
|
||||||
|
if (currentFrame % 3 != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentFrame % 30 != 0) {
|
||||||
|
DroneHelper.getInstance().setGimbalPitchdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
gimbalIsStartAruco = true;
|
||||||
|
if (lastGimbalFuture != null && !lastGimbalFuture.isDone()) {
|
||||||
|
lastGimbalFuture.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ultHeight = Movement.getInstance().getUltrasonicHeight();
|
||||||
|
updateGimbalLensOffset(ultHeight);
|
||||||
|
|
||||||
|
final int finalUltHeight = ultHeight;
|
||||||
|
lastGimbalFuture = executor.schedule(() -> {
|
||||||
|
try {
|
||||||
|
processGimbalFrameInternal(height, width, data, dictionary, finalUltHeight);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG_LOG, "云台相机处理异常: " + e);
|
||||||
|
synchronized (MixedVisionLanding.this) {
|
||||||
|
gimbalIsStartAruco = false;
|
||||||
|
}
|
||||||
|
handleLandingFailure();
|
||||||
|
}
|
||||||
|
}, 0, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 下视相机帧处理 ==========
|
// ========== 下视相机帧处理 ==========
|
||||||
public void processDownwardFrame(int height, int width, byte[] data, Dictionary dictionary) {
|
public void processDownwardFrame(int height, int width, byte[] data, Dictionary dictionary) {
|
||||||
if (!isLanding || currentMode != LandingMode.DOWNWARD_CAMERA) {
|
synchronized (this) {
|
||||||
return;
|
if (!isLanding || currentMode != LandingMode.DOWNWARD_CAMERA || startArucoType == 0) {
|
||||||
}
|
return;
|
||||||
|
|
||||||
downwardIsTriggerSuccess = true;
|
|
||||||
Movement.getInstance().setVirtualStickEnableReason(2);
|
|
||||||
|
|
||||||
if (downwardIsStartAruco || downwardStartFastStick) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentFrame = downwardFrameCounter++;
|
|
||||||
if (currentFrame % 2 != 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
downwardIsStartAruco = true;
|
|
||||||
if (lastDownwardFuture != null && !lastDownwardFuture.isDone()) {
|
|
||||||
lastDownwardFuture.cancel(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ultHeight = Movement.getInstance().getUltrasonicHeight();
|
|
||||||
updateDownwardLensOffset(ultHeight);
|
|
||||||
|
|
||||||
final int finalUltHeight = ultHeight;
|
|
||||||
lastDownwardFuture = executor.schedule(() -> {
|
|
||||||
try {
|
|
||||||
processDownwardFrameInternal(height, width, data, dictionary, finalUltHeight);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogUtil.log(TAG_LOG, "下视相机处理异常: " + e);
|
|
||||||
downwardIsStartAruco = false;
|
|
||||||
handleLandingFailure();
|
|
||||||
}
|
}
|
||||||
}, 0, TimeUnit.MILLISECONDS);
|
|
||||||
|
downwardIsTriggerSuccess = true;
|
||||||
|
Movement.getInstance().setVirtualStickEnableReason(2);
|
||||||
|
|
||||||
|
if (downwardIsStartAruco || downwardStartFastStick) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentFrame = downwardFrameCounter++;
|
||||||
|
if (currentFrame % 2 != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
downwardIsStartAruco = true;
|
||||||
|
if (lastDownwardFuture != null && !lastDownwardFuture.isDone()) {
|
||||||
|
lastDownwardFuture.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ultHeight = Movement.getInstance().getUltrasonicHeight();
|
||||||
|
updateDownwardLensOffset(ultHeight);
|
||||||
|
|
||||||
|
final int finalUltHeight = ultHeight;
|
||||||
|
lastDownwardFuture = executor.schedule(() -> {
|
||||||
|
try {
|
||||||
|
processDownwardFrameInternal(height, width, data, dictionary, finalUltHeight);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG_LOG, "下视相机处理异常: " + e);
|
||||||
|
synchronized (MixedVisionLanding.this) {
|
||||||
|
downwardIsStartAruco = false;
|
||||||
|
}
|
||||||
|
handleLandingFailure();
|
||||||
|
}
|
||||||
|
}, 0, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 云台相机内部处理 ==========
|
// ========== 云台相机内部处理 ==========
|
||||||
|
|
@ -397,8 +420,24 @@ public class MixedVisionLanding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 正常修正
|
// 旋转处理
|
||||||
moveOnArucoDetected(new ArucoMarker(1, corner6, 0.24f), rgbMat.width(), rgbMat.height());
|
if (ultHeight > 30 && !downwardIsYawAligned) {
|
||||||
|
double yawError = calculateYawErrorFromCorners(points);
|
||||||
|
double absYaw = Math.abs(yawError);
|
||||||
|
|
||||||
|
if (absYaw < 10.0) {
|
||||||
|
downwardIsYawAligned = true;
|
||||||
|
LogUtil.log(TAG_LOG, "【下视旋转到位】偏航已对准");
|
||||||
|
DroneHelper.getInstance().moveVxVyYawrateHeight(0f, 0f, 0f, 0f);
|
||||||
|
} else {
|
||||||
|
float yawRate = calculateYawRate(yawError, ultHeight);
|
||||||
|
LogUtil.log(TAG_LOG, String.format("【下视执行】纯旋转 yawRate=%.1f avgYaw=%.1f", yawRate, yawError));
|
||||||
|
DroneHelper.getInstance().moveVxVyYawrateHeight(0f, 0f, yawRate, 0f);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 正常修正
|
||||||
|
moveOnArucoDetected(new ArucoMarker(1, corner6, 0.24f), rgbMat.width(), rgbMat.height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleDownwardLostMarker(ultHeight);
|
handleDownwardLostMarker(ultHeight);
|
||||||
|
|
@ -817,30 +856,32 @@ public class MixedVisionLanding {
|
||||||
|
|
||||||
// ========== 降落失败处理(切换相机) ==========
|
// ========== 降落失败处理(切换相机) ==========
|
||||||
private void handleLandingFailure() {
|
private void handleLandingFailure() {
|
||||||
if (!isLanding) {
|
synchronized (this) {
|
||||||
return;
|
if (!isLanding) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switchCount++;
|
switchCount++;
|
||||||
LogUtil.log(TAG_LOG, "切换相机,当前切换次数: " + switchCount);
|
LogUtil.log(TAG_LOG, "切换相机,当前切换次数: " + switchCount);
|
||||||
|
|
||||||
// 切换到另一个相机
|
// 切换到另一个相机
|
||||||
if (currentMode == LandingMode.GIMBAL_CAMERA) {
|
if (currentMode == LandingMode.GIMBAL_CAMERA) {
|
||||||
currentMode = LandingMode.DOWNWARD_CAMERA;
|
currentMode = LandingMode.DOWNWARD_CAMERA;
|
||||||
LogUtil.log(TAG_LOG, "切换到下视相机");
|
LogUtil.log(TAG_LOG, "切换到下视相机");
|
||||||
resetDownwardState();
|
resetDownwardState();
|
||||||
} else {
|
} else {
|
||||||
currentMode = LandingMode.GIMBAL_CAMERA;
|
currentMode = LandingMode.GIMBAL_CAMERA;
|
||||||
LogUtil.log(TAG_LOG, "切换到云台相机");
|
LogUtil.log(TAG_LOG, "切换到云台相机");
|
||||||
resetGimbalState();
|
resetGimbalState();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果达到最大切换次数,触发备降
|
// 如果达到最大切换次数,触发备降
|
||||||
if (switchCount >= MAX_SWITCH_COUNT) {
|
if (switchCount >= MAX_SWITCH_COUNT) {
|
||||||
LogUtil.log(TAG_LOG, "达到最大切换次数,触发备降");
|
LogUtil.log(TAG_LOG, "达到最大切换次数,触发备降");
|
||||||
stopLanding();
|
stopLanding();
|
||||||
AlternateLandingManager.getInstance().startTaskProcess(null);
|
AlternateLandingManager.getInstance().startTaskProcess(null);
|
||||||
Movement.getInstance().setAlternate(true);
|
Movement.getInstance().setAlternate(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -876,6 +917,7 @@ public class MixedVisionLanding {
|
||||||
downwardDropTimesTag = false;
|
downwardDropTimesTag = false;
|
||||||
downwardStartTime = 0;
|
downwardStartTime = 0;
|
||||||
downwardEndTime = 0;
|
downwardEndTime = 0;
|
||||||
|
downwardIsYawAligned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 更新云台相机镜头偏移 ==========
|
// ========== 更新云台相机镜头偏移 ==========
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TTS 文本转 PCM 工具类
|
||||||
|
* 使用同步方式实现,避免依赖回调机制
|
||||||
|
*/
|
||||||
public class XTtsPcmGenerator {
|
public class XTtsPcmGenerator {
|
||||||
|
|
||||||
private static final String TAG = "XTTS";
|
private static final String TAG = "XTTS";
|
||||||
|
|
@ -21,31 +25,40 @@ public class XTtsPcmGenerator {
|
||||||
|
|
||||||
private AiHandle aiHandle;
|
private AiHandle aiHandle;
|
||||||
private FileOutputStream pcmOut;
|
private FileOutputStream pcmOut;
|
||||||
|
private boolean isSynthesisComplete = false;
|
||||||
|
|
||||||
public void init(AiListener listener) {
|
|
||||||
AiHelper.getInst().registerListener(ABILITY_ID, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合成文本为 PCM 文件
|
* 合成文本为 PCM 文件(同步方法)
|
||||||
*/
|
*/
|
||||||
public int synthToPcm(
|
public File synthToPcm(String text, XTTSParams params, File pcmFile) {
|
||||||
String text,
|
LogUtil.log(TAG, "开始执行 synthToPcm 方法,text: " + text);
|
||||||
XTTSParams params,
|
|
||||||
File pcmFile
|
// 参数验证
|
||||||
) {
|
if (text == null || text.length() == 0 || params == null || pcmFile == null) {
|
||||||
|
LogUtil.log(TAG, "参数无效");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置合成完成标志
|
||||||
|
isSynthesisComplete = false;
|
||||||
|
|
||||||
|
// 准备文件输出流
|
||||||
File parent = pcmFile.getParentFile();
|
File parent = pcmFile.getParentFile();
|
||||||
if (parent != null && !parent.exists()) {
|
if (parent != null && !parent.exists()) {
|
||||||
parent.mkdirs();
|
parent.mkdirs();
|
||||||
}
|
LogUtil.log(TAG, "创建输出目录: " + parent.getAbsolutePath());
|
||||||
try {
|
|
||||||
pcmOut = new FileOutputStream(pcmFile, false);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
pcmOut = new FileOutputStream(pcmFile, false);
|
||||||
|
LogUtil.log(TAG, "文件输出流创建成功: " + pcmFile.getAbsolutePath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG, "创建文件输出流失败: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建参数
|
||||||
AiInput.Builder paramBuilder = AiInput.builder();
|
AiInput.Builder paramBuilder = AiInput.builder();
|
||||||
paramBuilder.param("vcn", params.vcn);
|
paramBuilder.param("vcn", params.vcn);
|
||||||
paramBuilder.param("language", params.language);
|
paramBuilder.param("language", params.language);
|
||||||
|
|
@ -54,44 +67,79 @@ public class XTtsPcmGenerator {
|
||||||
paramBuilder.param("speed", params.speed);
|
paramBuilder.param("speed", params.speed);
|
||||||
paramBuilder.param("volume", params.volume);
|
paramBuilder.param("volume", params.volume);
|
||||||
|
|
||||||
aiHandle = AiHelper.getInst().start(
|
// 构建监听器
|
||||||
ABILITY_ID,
|
AiListener listener = buildListener();
|
||||||
paramBuilder.build(),
|
LogUtil.log(TAG, "监听器创建成功");
|
||||||
null
|
|
||||||
);
|
|
||||||
|
|
||||||
if (aiHandle.getCode() != 0) {
|
// 注册监听器
|
||||||
LogUtil.log(TAG, "start failed: " + aiHandle.getCode());
|
try {
|
||||||
return aiHandle.getCode();
|
AiHelper.getInst().registerListener(ABILITY_ID, listener);
|
||||||
|
LogUtil.log(TAG, "监听器注册成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG, "监听器注册失败: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
close();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
AiText aiText = AiText.get("text")
|
// 启动 TTS 引擎
|
||||||
.data(text)
|
aiHandle = AiHelper.getInst().start(ABILITY_ID, paramBuilder.build(), null);
|
||||||
.valid();
|
if (aiHandle.getCode() != 0) {
|
||||||
|
LogUtil.log(TAG, "启动 TTS 引擎失败: " + aiHandle.getCode());
|
||||||
|
close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LogUtil.log(TAG, "TTS 引擎启动成功");
|
||||||
|
|
||||||
AiRequest request = AiRequest.builder()
|
// 构建请求
|
||||||
.payload(aiText)
|
AiText aiText = AiText.get("text").data(text).valid();
|
||||||
.build();
|
AiRequest request = AiRequest.builder().payload(aiText).build();
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
int ret = AiHelper.getInst().write(request, aiHandle);
|
int ret = AiHelper.getInst().write(request, aiHandle);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LogUtil.log(TAG, "write failed: " + ret);
|
LogUtil.log(TAG, "发送 TTS 请求失败: " + ret);
|
||||||
return ret;
|
close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LogUtil.log(TAG, "TTS 请求发送成功,开始合成");
|
||||||
|
|
||||||
|
// 等待合成完成(最多等待 30 秒)
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
while (System.currentTimeMillis() - startTime < 30000) {
|
||||||
|
if (isSynthesisComplete) {
|
||||||
|
LogUtil.log(TAG, "合成完成标志已设置");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
// 关闭资源
|
||||||
|
close();
|
||||||
|
|
||||||
|
// 检查 PCM 文件大小
|
||||||
|
if (pcmFile.exists() && pcmFile.length() > 0) {
|
||||||
|
LogUtil.log(TAG, "合成成功,PCM 文件大小: " + pcmFile.length() + " bytes");
|
||||||
|
return pcmFile;
|
||||||
|
} else {
|
||||||
|
LogUtil.log(TAG, "合成失败,PCM 文件为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内部使用的监听器
|
* 构建监听器
|
||||||
*/
|
*/
|
||||||
public AiListener buildListener() {
|
private AiListener buildListener() {
|
||||||
return new AiListener() {
|
return new AiListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResult(int handleID, List<AiResponse> list, Object usrContext) {
|
public void onResult(int handleID, List<AiResponse> list, Object usrContext) {
|
||||||
if (list == null){
|
if (list == null) {
|
||||||
LogUtil.log(TAG,"list == null");
|
LogUtil.log(TAG, "onResult: list == null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,6 +147,7 @@ public class XTtsPcmGenerator {
|
||||||
if ("audio".equals(resp.getKey())) {
|
if ("audio".equals(resp.getKey())) {
|
||||||
byte[] pcm = resp.getValue();
|
byte[] pcm = resp.getValue();
|
||||||
if (pcm != null && pcm.length > 0) {
|
if (pcm != null && pcm.length > 0) {
|
||||||
|
LogUtil.log(TAG, "接收到 PCM 数据,长度: " + pcm.length + " bytes");
|
||||||
writePcm(pcm);
|
writePcm(pcm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,48 +156,59 @@ public class XTtsPcmGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(int handleID, int event, List<AiResponse> eventData, Object usrContext) {
|
public void onEvent(int handleID, int event, List<AiResponse> eventData, Object usrContext) {
|
||||||
|
LogUtil.log(TAG, "收到事件: " + event);
|
||||||
if (event == AeeEvent.AEE_EVENT_END.getValue()) {
|
if (event == AeeEvent.AEE_EVENT_END.getValue()) {
|
||||||
close();
|
LogUtil.log(TAG, "合成完成事件");
|
||||||
|
isSynthesisComplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(int handleID, int err, String msg, Object usrContext) {
|
public void onError(int handleID, int err, String msg, Object usrContext) {
|
||||||
LogUtil.log(TAG, "XTTS error: " + err + ", " + msg);
|
LogUtil.log(TAG, "合成错误: " + err + ", " + msg);
|
||||||
close();
|
isSynthesisComplete = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写入 PCM 数据
|
||||||
|
*/
|
||||||
private synchronized void writePcm(byte[] data) {
|
private synchronized void writePcm(byte[] data) {
|
||||||
try {
|
if (pcmOut != null) {
|
||||||
if (pcmOut != null) {
|
try {
|
||||||
pcmOut.write(data);
|
pcmOut.write(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG, "写入 PCM 数据失败: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭资源
|
||||||
|
*/
|
||||||
private void close() {
|
private void close() {
|
||||||
|
LogUtil.log(TAG, "关闭资源");
|
||||||
try {
|
try {
|
||||||
if (pcmOut != null) {
|
if (pcmOut != null) {
|
||||||
pcmOut.flush();
|
pcmOut.flush();
|
||||||
pcmOut.close();
|
pcmOut.close();
|
||||||
pcmOut = null;
|
pcmOut = null;
|
||||||
|
LogUtil.log(TAG, "文件输出流已关闭");
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG, "关闭文件输出流失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if (aiHandle != null) {
|
try {
|
||||||
AiHelper.getInst().end(aiHandle);
|
if (aiHandle != null) {
|
||||||
aiHandle = null;
|
AiHelper.getInst().end(aiHandle);
|
||||||
|
aiHandle = null;
|
||||||
|
LogUtil.log(TAG, "AI 引擎已关闭");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.log(TAG, "关闭 AI 引擎失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 释放引擎(App 退出时调用)
|
|
||||||
*/
|
|
||||||
// public void release() {
|
|
||||||
// AiHelper.getInst().engineUnInit(ABILITY_ID);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.aros.apron.tts;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class CopyAsset {
|
||||||
|
|
||||||
|
private static volatile CopyAsset instance;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
// 私有构造方法
|
||||||
|
private CopyAsset(Context context) {
|
||||||
|
// 使用Application Context避免内存泄漏
|
||||||
|
this.context = context.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取单例实例
|
||||||
|
public static CopyAsset getInstance(Context context) {
|
||||||
|
if (instance == null) {
|
||||||
|
synchronized (CopyAsset.class) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CopyAsset(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyAssetsToSdcard() {
|
||||||
|
// 修改目标路径
|
||||||
|
String sdcardPath = "/storage/self/primary/DJIDemo/cache/tts/";
|
||||||
|
File sdcardDir = new File(sdcardPath);
|
||||||
|
if (!sdcardDir.exists()) {
|
||||||
|
// 创建目录,包括所有父目录
|
||||||
|
sdcardDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
AssetManager assetManager = context.getAssets();
|
||||||
|
String[] files = assetManager.list("aikit_resources");
|
||||||
|
if (files != null) { // 防止assets目录不存在导致的空指针
|
||||||
|
for (String file : files) {
|
||||||
|
File destFile = new File(sdcardPath + file);
|
||||||
|
if (!destFile.exists()) { // 仅在文件不存在时复制
|
||||||
|
InputStream in = assetManager.open("aikit_resources/" + file);
|
||||||
|
FileOutputStream out = new FileOutputStream(destFile);
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int read;
|
||||||
|
while ((read = in.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -738,26 +738,33 @@
|
||||||
android:id="@+id/rb_camera_right"
|
android:id="@+id/rb_camera_right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="右侧" />
|
android:text="右" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb_camera_center"
|
android:id="@+id/rb_camera_center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:text="中间" />
|
android:text="中" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb_camera_null"
|
android:id="@+id/rb_camera_null"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:text="下视" />
|
android:text="下" />
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb_camera_mix"
|
android:id="@+id/rb_camera_mix"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:text="融合" />
|
android:text="融右" />
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rb_camera_mix_center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="0dp"
|
||||||
|
android:text="融中" />
|
||||||
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -738,27 +738,33 @@
|
||||||
android:id="@+id/rb_camera_right"
|
android:id="@+id/rb_camera_right"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="右侧" />
|
android:text="右" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb_camera_center"
|
android:id="@+id/rb_camera_center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:text="中间" />
|
android:text="中" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb_camera_null"
|
android:id="@+id/rb_camera_null"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:text="下视" />
|
android:text="下" />
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/rb_camera_mix"
|
android:id="@+id/rb_camera_mix"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="0dp"
|
||||||
android:text="融合" />
|
android:text="融右" />
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rb_camera_mix_center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="0dp"
|
||||||
|
android:text="融中" />
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
//flatDir { dirs 'libs' }
|
||||||
jcenter(){ url 'https://jcenter.bintray.com/'}
|
jcenter(){ url 'https://jcenter.bintray.com/'}
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
maven {
|
maven {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue