diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt index c2e4c9383f..fc0bc0cee0 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt @@ -45,6 +45,7 @@ import com.mogo.och.common.module.manager.autopilot.autopilot.IOchAutopilotStatu import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotStatusListenerManager import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics +import com.mogo.och.common.module.manager.autopilot.line.ILineCallback import com.mogo.och.common.module.manager.autopilot.line.LineManager import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager import com.mogo.och.common.module.manager.distance.IDistanceListener @@ -214,6 +215,7 @@ object TaxiTaskModel { OchAutoPilotStatusListenerManager.addListener(TAG, mMogoAutopilotStatusListener) //定位监听, 传false是高德坐标系 10 -> 100ms一次 OchLocationManager.addGCJ02Listener(TAG, 5, mMapLocationListener) + LineManager.addListener(TAG,iLineCallback) //2021.11.1 自动驾驶路线规划接口 CallerPlanningRottingListenerManager.addListener(TAG, mMogoAutopilotPlanningListener) //开启自驾后 异常信息返回 @@ -235,6 +237,7 @@ object TaxiTaskModel { // 注销地图监听 OchLocationManager.removeGCJ02Listener(TAG) + LineManager.removeListener(TAG) OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgMonitorType) OchAutoPilotStatusListenerManager.removeListener(mMogoAutopilotStatusListener) CallerPlanningRottingListenerManager.removeListener(mMogoAutopilotPlanningListener) @@ -276,14 +279,6 @@ object TaxiTaskModel { private val mMogoAutopilotStatusListener: IOchAutopilotStatusListener = object : IOchAutopilotStatusListener { override fun onAutopilotIpcConnectStatusChanged(status: AdasConstants.IpcConnectionStatus, reason: String?) { -// DebugView.printInfoMsg( -// "[域控连接状态变化] status=$status, reason=${ -// if (TextUtils.isEmpty( -// reason -// ) -// ) "" else reason -// }" -// ) } override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?, lineId: Long) { @@ -390,10 +385,10 @@ object TaxiTaskModel { ).toDouble() if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE){// 两坐标小于15米 DebugView.printInfoMsg("[MAP到站通知] 到站坐标和任务终点15米内, 请求到站") - autopilotArriveAtStation() }else{ DebugView.printInfoMsg("[MAP到站通知] 到站坐标和任务终点不一致, 不请求到站") } + autopilotArriveAtStation() }else{ DebugView.printInfoMsg("[MAP到站通知] endSiteLat = $endSiteLat, endSiteLon = $endSiteLon, " + "mapEndSiteLat = $mapEndSiteLatWgs, mapEndSiteLon = $mapEndSiteLonWgs") @@ -410,10 +405,17 @@ object TaxiTaskModel { } } - override fun canStartAutopilot(canStart: Boolean) { - super.canStartAutopilot(canStart) + } + private val iLineCallback: ILineCallback = + object : ILineCallback { + override fun arrivedStationSuccessBySearch() { + super.arrivedStationSuccessBySearch() + if (checkCurrentTaskCondition() + && QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder) + ) { + judgeTaskEndSiteStation() + } } - } // 自车定位 @@ -422,18 +424,12 @@ object TaxiTaskModel { override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { //位置变化时,通过围栏判断是否到达x点 if (null == mogoLocation) return - - OCHThreadPoolManager.getsInstance().locationExecute { - if (mDriveToNearestStationTask != null) { - judgeDriveToNearestStationTaskStation(mDriveToNearestStationTask, mogoLocation) + if (mDriveToNearestStationTask != null) { + OCHThreadPoolManager.getsInstance().locationExecute { + if (mDriveToNearestStationTask != null) { + judgeDriveToNearestStationTaskStation(mDriveToNearestStationTask, mogoLocation) + } } - - if (checkCurrentTaskCondition() - && QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder) - ) { - judgeTaskEndSiteStation(mogoLocation) - } - } } } @@ -1310,65 +1306,20 @@ object TaxiTaskModel { } } - private fun judgeTaskEndSiteStation(currentLocation: MogoLocation) { + private fun judgeTaskEndSiteStation() { if (!checkCurrentTaskCondition() || !QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)) { return } val endSite = mCurrentTaskWithOrder!!.endSite ?: return - val endLon = endSite.gcjLon - val endLat = endSite.gcjLat - val distance = CoordinateUtils.calculateLineDistance( - endLon, endLat, - currentLocation.longitude, currentLocation.latitude - ).toDouble() - i(TAG, "judgeEndStation() distance = $distance") - if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) { //1、当前位置和站点围栏15m内 - - //2、开始计算当前位置和站点的向量角度 < 90度 未经过 >90度 经过 - val stationAngle = DrivingDirectionUtils.getDegreeOfCar2Poi( - currentLocation.longitude, - currentLocation.latitude, - endLon, - endLat, currentLocation.heading.toInt() - ).toDouble() - i( - TAG, - "judgeEndStation() stationAngle = $stationAngle" - ) - - if (!checkCurrentTaskCondition() - || !QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder) - ) { - i(TAG, "task null or TaskStatus = ${getCurTaskStatus()}") - return - } - //3、刚过站且过站距离在15m内, 提交到站 - if (stationAngle > 90) { - i(TAG, "judgeEndStation() = 刚过站且在15m内") - DebugView.printInfoMsg( - "[自车定位围栏] 触发围栏,任务类型:${ - TaskTypeEnum.valueOf( - mCurrentTaskWithOrder?.taskType ?: 0 - )?.name - },围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米 刚过站且在15m内" - ) - submitArriveSite(endSite.siteId, true) - } else { - // 4、 没有过站距离小于15m 速度小于0.3(根据M1来的模数 可能要调) - if (currentLocation.gnssSpeed < 0.3) { - i(TAG, "judgeEndStation() = 没有过站、速度基本为零且在15m内") - DebugView.printInfoMsg( - "[自车定位围栏] 触发围栏,任务类型:${ - TaskTypeEnum.valueOf( - mCurrentTaskWithOrder?.taskType ?: 0 - )?.name - },围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米 没有过站、速度基本为零且在15m内" - ) - submitArriveSite(endSite.siteId, true) - } - } + if (!checkCurrentTaskCondition() + || !QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder) + ) { + i(TAG, "task null or TaskStatus = ${getCurTaskStatus()}") + return } + + submitArriveSite(endSite.siteId, true) } /**