[自主算路验证] feat: 到终点后 主动弹出 结束任务弹框;

refactor: 算路模式下 接单按钮 修改成置灰UI,但是依然可点击,点击时提示toast;
fix: 到达终点后 需要主动取消自动驾驶,否则会一直在自动驾驶状态和D挡;
This commit is contained in:
aibingbing
2023-11-30 15:14:32 +08:00
parent 37e6028086
commit 4cd995569a
8 changed files with 222 additions and 12 deletions

View File

@@ -12,4 +12,6 @@ interface ITaxiRoutingCallback {
fun onSubmitGrayLineIssueLocationFailed(errorStr: String)
fun onSubmitEndTaskSuccess()
fun onSubmitEndTaskFailed(errorStr: String)
fun onAutoPilotArriveAtEndStation(grayId: Long?)
fun onGDMapArriveAtEndStation(grayId: Long?)
}

View File

@@ -200,7 +200,7 @@ abstract class BaseTaxiTabFragment<V : IView, P : Presenter<V>> : MvpFragment<V,
module_mogo_och_operation_status.setOnClickListener(object : OnPreventFastClickListener() {
override fun onClickImpl(v: View?) {
if (MogoStatusManager.getInstance().isTaxiUnmanedDriverLineRoutingVerifyMode) {
ToastUtils.showLong("请先切换到Taxi无人化流程模式后使用")
ToastUtils.showLong("退出验证模式后再接单吧")
return
}
onChangeOperationStatus()

View File

@@ -273,8 +273,8 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
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),

View File

@@ -104,6 +104,12 @@ class TaxiRoutingChooseLineViewModel : BaseViewModel<TaxiRoutingUiState, TaxiRou
override fun onSubmitEndTaskFailed(errorStr: String) {
}
override fun onAutoPilotArriveAtEndStation(grayId: Long?) {
}
override fun onGDMapArriveAtEndStation(grayId: Long?) {
}
override fun onCleared() {
super.onCleared()
TaxiRoutingModel.removeTaxiRoutingListener(TAG)

View File

@@ -53,21 +53,30 @@ class TaxiRoutingFragmentViewModel : BaseViewModel<TaxiRoutingUiState, TaxiRouti
)
}
// 设置灰度路线任务执行状态,切换模式时判断使用
MogoStatusManager.getInstance().setTaxiUnmanedDriverLineRoutingPerformTask(TAG, true)
MogoStatusManager.getInstance()
.setTaxiUnmanedDriverLineRoutingPerformTask(TAG, true)
}
is TaxiRoutingUiIntent.StartTaskAction -> {
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<TaxiRoutingUiState, TaxiRouti
routingUiState = RoutingUIState.Init
)
}
TaxiRoutingModel.updateCurrentGrayLineAndContrail(null, null)
TaxiRoutingModel.updateCurrentGrayLineAndContrail(null, null, -1L)
// 设置灰度路线任务执行状态,切换模式时判断使用
MogoStatusManager.getInstance().setTaxiUnmanedDriverLineRoutingPerformTask(TAG, false)
TaxiRoutingModel.startNaviToEndStationByAMap(false)
// 移除到站监听
TaxiRoutingModel.removeAutoPilotStatusListener()
TaxiRoutingModel.removeGDMapCurrentLocationListener()
}
override fun onSubmitEndTaskFailed(errorStr: String) {
@@ -148,6 +160,40 @@ class TaxiRoutingFragmentViewModel : BaseViewModel<TaxiRoutingUiState, TaxiRouti
}
}
override fun onAutoPilotArriveAtEndStation(grayId: Long?) {
TaxiRoutingModel.removeAutoPilotStatusListener()
TaxiRoutingModel.removeGDMapCurrentLocationListener()
TaxiRoutingModel.cancelAutopilot()
DebugView.printInfoMsg("[结束任务] 到终点站,自动展示结束任务弹框")
sendUiState {
copy(
routingUiState = RoutingUIState.ShowFeedbackDialog(
grayId ?: -1L,
System.currentTimeMillis()
)
)
}
}
override fun onGDMapArriveAtEndStation(grayId: Long?) {
TaxiRoutingModel.removeAutoPilotStatusListener()
TaxiRoutingModel.removeGDMapCurrentLocationListener()
TaxiRoutingModel.cancelAutopilot()
DebugView.printInfoMsg("[结束任务] 到终点站,自动展示结束任务弹框")
sendUiState {
copy(
routingUiState = RoutingUIState.ShowFeedbackDialog(
grayId ?: -1L,
System.currentTimeMillis()
)
)
}
}
override fun onCleared() {
TaxiRoutingModel.removeTaxiRoutingListener(TAG)
super.onCleared()

View File

@@ -7,10 +7,17 @@ import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.data.BaseData
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.network.utils.GsonUtil
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.NetworkUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
@@ -29,6 +36,8 @@ import com.mogo.och.taxi.callback.ITaxiRoutingCallback
import com.mogo.och.taxi.constant.TaxiUnmannedConst
import com.mogo.och.taxi.network.TaxiRoutingServiceManager
import com.mogo.och.taxi.ui.debug.DebugView
import mogo.telematics.pad.MessagePad
import mogo_msg.MogoReportMsg
import java.util.concurrent.ConcurrentHashMap
object TaxiRoutingModel {
@@ -39,6 +48,7 @@ object TaxiRoutingModel {
private var currentGrayLineBean: GrayLineBean? = null
private var currentContrailBean: ContrailBean? = null
private var currentGrayId: Long? = null
private val mTaxiRoutingCallbackMap: ConcurrentHashMap<String, ITaxiRoutingCallback> =
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()
}
}
/**
* 显示/隐藏 前往任务目的地的导航
*

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/taxi_autopilot_text_color_normal" android:state_enabled="true"/>
<item android:color="@color/taxi_autopilot_text_color_disable" android:state_enabled="false"/>
<item android:color="@color/taxi_autopilot_text_color_normal" android:state_focused="true"/>
<item android:color="@color/taxi_autopilot_text_color_disable" android:state_focused="false"/>
</selector>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/taxi_operation_status_bg_disabled" android:state_enabled="false" />
<item android:drawable="@drawable/taxi_operation_status_bg" android:state_enabled="true"/>
<item android:drawable="@drawable/taxi_operation_status_bg_disabled" android:state_checked="false" />
<item android:drawable="@drawable/taxi_operation_status_bg" android:state_checked="true"/>
</selector>