From 4cd995569a252f94631b9b5357d083670fda6c9c Mon Sep 17 00:00:00 2001 From: aibingbing Date: Thu, 30 Nov 2023 15:14:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=87=AA=E4=B8=BB=E7=AE=97=E8=B7=AF=E9=AA=8C?= =?UTF-8?q?=E8=AF=81]=20feat:=20=E5=88=B0=E7=BB=88=E7=82=B9=E5=90=8E=20?= =?UTF-8?q?=E4=B8=BB=E5=8A=A8=E5=BC=B9=E5=87=BA=20=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=BC=B9=E6=A1=86=EF=BC=9B=20refactor:=20?= =?UTF-8?q?=E7=AE=97=E8=B7=AF=E6=A8=A1=E5=BC=8F=E4=B8=8B=20=E6=8E=A5?= =?UTF-8?q?=E5=8D=95=E6=8C=89=E9=92=AE=20=E4=BF=AE=E6=94=B9=E6=88=90?= =?UTF-8?q?=E7=BD=AE=E7=81=B0UI=EF=BC=8C=E4=BD=86=E6=98=AF=E4=BE=9D?= =?UTF-8?q?=E7=84=B6=E5=8F=AF=E7=82=B9=E5=87=BB=EF=BC=8C=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=97=B6=E6=8F=90=E7=A4=BAtoast;=20fix:=20=E5=88=B0=E8=BE=BE?= =?UTF-8?q?=E7=BB=88=E7=82=B9=E5=90=8E=20=E9=9C=80=E8=A6=81=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E5=8F=96=E6=B6=88=E8=87=AA=E5=8A=A8=E9=A9=BE=E9=A9=B6?= =?UTF-8?q?=EF=BC=8C=E5=90=A6=E5=88=99=E4=BC=9A=E4=B8=80=E7=9B=B4=E5=9C=A8?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=A9=BE=E9=A9=B6=E7=8A=B6=E6=80=81=E5=92=8C?= =?UTF-8?q?D=E6=8C=A1=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../och/taxi/callback/ITaxiRoutingCallback.kt | 2 + .../och/taxi/ui/base/BaseTaxiTabFragment.kt | 2 +- .../com/mogo/och/taxi/ui/base/TaxiFragment.kt | 4 +- .../routing/TaxiRoutingChooseLineViewModel.kt | 6 + .../routing/TaxiRoutingFragmentViewModel.kt | 52 +++++- .../och/taxi/ui/routing/TaxiRoutingModel.kt | 160 +++++++++++++++++- .../taxi_autopilot_text_color_selector.xml | 4 +- .../taxi_operation_status_bg_selector_new.xml | 4 +- 8 files changed, 222 insertions(+), 12 deletions(-) diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/callback/ITaxiRoutingCallback.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/callback/ITaxiRoutingCallback.kt index 980921759f..22fcb34e93 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/callback/ITaxiRoutingCallback.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/callback/ITaxiRoutingCallback.kt @@ -12,4 +12,6 @@ interface ITaxiRoutingCallback { fun onSubmitGrayLineIssueLocationFailed(errorStr: String) fun onSubmitEndTaskSuccess() fun onSubmitEndTaskFailed(errorStr: String) + fun onAutoPilotArriveAtEndStation(grayId: Long?) + fun onGDMapArriveAtEndStation(grayId: Long?) } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/base/BaseTaxiTabFragment.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/base/BaseTaxiTabFragment.kt index a2aac8167a..4855ec3b86 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/base/BaseTaxiTabFragment.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/base/BaseTaxiTabFragment.kt @@ -200,7 +200,7 @@ abstract class BaseTaxiTabFragment> : MvpFragment(), if (MogoStatusManager.getInstance().isTaxiUnmanedDriverTakingOrders) { return } - module_mogo_och_operation_status.isEnabled = !isRoutingVerifyMode - val isBtnEnable = module_mogo_och_operation_status.isEnabled + module_mogo_och_operation_status.isChecked = !isRoutingVerifyMode + val isBtnEnable = module_mogo_och_operation_status.isChecked if (isBtnEnable) { module_mogo_och_operation_status.setCompoundDrawablesWithIntrinsicBounds( resources.getDrawable(R.drawable.shape_size_operation_out), diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/routing/TaxiRoutingChooseLineViewModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/routing/TaxiRoutingChooseLineViewModel.kt index 9f48d57ca1..f6f733248e 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/routing/TaxiRoutingChooseLineViewModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/routing/TaxiRoutingChooseLineViewModel.kt @@ -104,6 +104,12 @@ class TaxiRoutingChooseLineViewModel : BaseViewModel { DebugView.printInfoMsg("[开始任务] 准备开始任务") val grayLineBean = intent.routingTask.grayLineBean val contrailBean = intent.routingTask.contrailBean + val grayId = intent.routingTask.grayId if (grayLineBean == null || contrailBean == null) { ToastUtils.showShort("灰度线路或轨迹信息异常,请稍后再试") DebugView.printErrorMsg("[开始任务] 灰度线路或轨迹信息异常,请稍后再试") return } DebugView.printInfoMsg("[启自驾] 准备启动自驾") - TaxiRoutingModel.updateCurrentGrayLineAndContrail(grayLineBean, contrailBean) + TaxiRoutingModel.updateCurrentGrayLineAndContrail( + grayLineBean, + contrailBean, + grayId + ) TaxiRoutingModel.startAutoPilot(grayLineBean!!, contrailBean!!) + //添加到站监听 + TaxiRoutingModel.addAutoPilotStatusListener() + TaxiRoutingModel.addGDMapCurrentLocationListener() sendUiState { copy( routingUiState = RoutingUIState.ShowFinishTaskButton(intent.routingTask) @@ -133,10 +142,13 @@ class TaxiRoutingFragmentViewModel : BaseViewModel = ConcurrentHashMap() @@ -69,6 +79,131 @@ object TaxiRoutingModel { mOrderStatusCallback = callback } + fun addAutoPilotStatusListener() { + CallerAutoPilotStatusListenerManager.addListener(TAG, mMogoAutopilotStatusListener) + } + + fun removeAutoPilotStatusListener() { + CallerAutoPilotStatusListenerManager.removeListener(TAG) + } + + //MAP到站监听 + private val mMogoAutopilotStatusListener: IMoGoAutopilotStatusListener = + object : IMoGoAutopilotStatusListener { + override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) { + } + + override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) { + } + + override fun onAutopilotStatusResponse(state: Int) { + } + + override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) { + CallerLogger.i( + TAG, + "onAutopilotArriveAtStation = ${arrivalNotification.toString()}" + ) + DebugView.printInfoMsg("[MAP到站通知] 上报到站,location=${arrivalNotification?.endLocation}") + + val endSiteLat: Double? = currentGrayLineBean?.endSite?.gcjLat + val endSiteLon: Double? = currentGrayLineBean?.endSite?.gcjLon + val mapEndSiteLatWgs: Double? = arrivalNotification?.endLocation?.latitude + val mapEndSiteLonWgs: Double? = arrivalNotification?.endLocation?.longitude + if (endSiteLon != null && endSiteLat != null && mapEndSiteLonWgs != null && mapEndSiteLatWgs != null) { + val latLngs = + CoordinateUtils.transformWgsToGcj(mapEndSiteLatWgs, mapEndSiteLonWgs) + val distance = CoordinateUtils.calculateLineDistance( + endSiteLon, endSiteLat, + latLngs[0], latLngs[1] + ).toDouble() + if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) {// 两坐标小于15米 + DebugView.printInfoMsg("[MAP到站通知] 到站坐标和任务终点15米内, 请求到站") + mTaxiRoutingCallbackMap.forEach { + val listener = it.value + listener.onAutoPilotArriveAtEndStation(currentGrayId) + } + } else { + DebugView.printInfoMsg("[MAP到站通知] 到站坐标和任务终点不一致, 不请求到站") + } + } else { + DebugView.printErrorMsg( + "[MAP到站通知] 上报到站,数据异常,endSiteLat = $endSiteLat, endSiteLon = $endSiteLon, " + + "mapEndSiteLat = $mapEndSiteLatWgs, mapEndSiteLon = $mapEndSiteLonWgs" + ) + } + } + } + + // 自车定位监听 + private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener = + object : IMoGoChassisLocationGCJ02Listener { + override fun onChassisLocationGCJ02(currentLocation: MogoLocation?) { + //位置变化时,通过围栏判断是否到达x点 + if (null == currentLocation) return + val endSite = currentGrayLineBean?.endSite ?: return + + val endLon = endSite.gcjLon + val endLat = endSite.gcjLat + + val distance = CoordinateUtils.calculateLineDistance( + endLon, + endLat, + currentLocation.longitude, + currentLocation.latitude + ).toDouble() + CallerLogger.i(TAG, "judgeEndStation() distance = $distance") + //1、当前位置和站点围栏15m内 + if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) { + //2、开始计算当前位置和站点的向量角度 < 90度 未经过 >90度 经过 + val stationAngle = DrivingDirectionUtils.getDegreeOfCar2Poi( + currentLocation.longitude, + currentLocation.latitude, + endLon, + endLat, + currentLocation.heading.toInt() + ).toDouble() + CallerLogger.i(TAG, "judgeEndStation() stationAngle = $stationAngle") + + //3、刚过站且过站距离在15m内, 提交到站 + if (stationAngle > 90) { + CallerLogger.i(TAG, "judgeEndStation() = 刚过站且在15m内") + DebugView.printInfoMsg( + "[自车定位围栏] 触发围栏, endSiteId=${currentGrayLineBean?.endSite?.siteId}, endSiteName=${currentGrayLineBean?.endSite?.siteName}, lineId=${currentGrayLineBean?.lineId},围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米 刚过站且在15m内" + ) + mTaxiRoutingCallbackMap.forEach { + val listener = it.value + listener.onGDMapArriveAtEndStation(currentGrayId) + } + } else { + // 4、 没有过站距离小于15m 速度小于0.3(根据M1来的模数 可能要调) + if (currentLocation.gnssSpeed < 0.3) { + CallerLogger.i( + TAG, + "judgeEndStation() = 没有过站、速度基本为零且在15m内" + ) + DebugView.printInfoMsg( + "[自车定位围栏] 触发围栏, endSiteId=${currentGrayLineBean?.endSite?.siteId}, endSiteName=${currentGrayLineBean?.endSite?.siteName}, lineId=${currentGrayLineBean?.lineId},围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米 没有过站、速度基本为零且在15m内" + ) + mTaxiRoutingCallbackMap.forEach { + val listener = it.value + listener.onGDMapArriveAtEndStation(currentGrayId) + } + } + } + } + } + } + + fun addGDMapCurrentLocationListener() { + //定位监听, 传false是高德坐标系 10 -> 100ms一次 + CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, mMapLocationListener) + } + + fun removeGDMapCurrentLocationListener() { + CallerChassisLocationGCJ02ListenerManager.removeListener(TAG) + } + fun queryRoutingGrayLineList() { DebugView.printInfoMsg("[查询灰度路线] 准备发送请求,sn=${MoGoAiCloudClientConfig.getInstance().sn}") TaxiRoutingServiceManager.queryRoutingGrayLineList(mContext, @@ -302,14 +437,22 @@ object TaxiRoutingModel { }) } - fun updateCurrentGrayLineAndContrail(grayLineBean: GrayLineBean?, contrailBean: ContrailBean?) { + fun updateCurrentGrayLineAndContrail( + grayLineBean: GrayLineBean?, + contrailBean: ContrailBean?, + grayId: Long? + ) { currentGrayLineBean = grayLineBean currentContrailBean = contrailBean + currentGrayId = grayId } fun startAutoPilotByClick() { if (currentGrayLineBean == null || currentContrailBean == null) { - CallerLogger.e(TAG, "startAutoPilotByClick 异常,currentGrayLineBean == null || currentContrailBean == null") + CallerLogger.e( + TAG, + "startAutoPilotByClick 异常,currentGrayLineBean == null || currentContrailBean == null" + ) DebugView.printErrorMsg("[启自驾] startAutoPilotByClick 异常,currentGrayLineBean == null || currentContrailBean == null") return } @@ -398,6 +541,19 @@ object TaxiRoutingModel { return parameters } + /** + * 结束自动驾驶 + * */ + fun cancelAutopilot() { + try { + CallerAutoPilotControlManager.cancelAutoPilot() + DebugView.printInfoMsg("[取消自驾] 调用成功") + CallerLogger.d(TAG, "结束自动驾驶") + } catch (e: Exception) { + e.printStackTrace() + } + } + /** * 显示/隐藏 前往任务目的地的导航 * diff --git a/OCH/taxi/unmanned-driver/src/main/res/color/taxi_autopilot_text_color_selector.xml b/OCH/taxi/unmanned-driver/src/main/res/color/taxi_autopilot_text_color_selector.xml index a5d1f74aec..e2572e7227 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/color/taxi_autopilot_text_color_selector.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/color/taxi_autopilot_text_color_selector.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_operation_status_bg_selector_new.xml b/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_operation_status_bg_selector_new.xml index 8c100f97eb..4382691e0a 100755 --- a/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_operation_status_bg_selector_new.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_operation_status_bg_selector_new.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file