[6.5.0]调整起步提醒/提前减速

This commit is contained in:
xuxinchao
2024-07-08 19:04:38 +08:00
parent f95c7b4bd4
commit c5bf3381bd

View File

@@ -18,10 +18,14 @@ import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.enums.TrafficLightEnum
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.data.multidisplay.TelematicConstant
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
@@ -31,6 +35,7 @@ import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.zhjt.service.chain.ChainLog
import perception.FusionTrafficLightOuterClass
import kotlin.math.abs
fun TrafficLightStatus.convert(): TrafficLightEnum {
return when {
@@ -57,7 +62,8 @@ fun convert(state: FusionTrafficLightOuterClass.FusionLightState): TrafficLightE
* @优先级OBU,云,工控
* @since: 2022/4/28
*/
class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener {
class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener,
IMoGoChassisLocationGCJ02Listener {
companion object {
const val TAG = "TrafficLightDispatcher"
@@ -89,12 +95,17 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
private var lightCountDownTimer: CountDownTimer? = null
private var lastLightTime: Long = System.currentTimeMillis()
private var currentSpeed: Float = 0f
private var isPrompted: Boolean = false //是否提示过起步提醒/提前减速,每个路口仅提示一次
fun initServer(context: Context) {
mContext = context
//注册监听AI云.OBU路侧获取红绿灯状态
CallerTrafficLightListenerManager.addListener(TAG, this)
//注册监听工控机感知红绿灯
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
//注册获取当前车速
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 1, this)
}
/**
@@ -114,7 +125,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
}
if (!hasObuLightStatus) {
if (!hasAiLightStatus) {
trafficLights?.let {
trafficLights?.let { it ->
var light: FusionTrafficLightOuterClass.FusionTrafficLight? = null
if (it.hasStraight()) {
light = it.straight
@@ -161,6 +172,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
if(convert(light.state) == TrafficLightEnum.BLACK){
//隐藏当前红绿灯以及额外提示框
CallerTrafficLightListenerManager.disableTrafficLight()
isPrompted = false
}else{
//有下一和下二灯态则为融合V2N红绿灯数据
onFusionTrafficLight(convert(light.state),light.duration.toInt(),
@@ -180,16 +192,44 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
* 车辆行驶中若判断当前绿灯自车基于当前速度需提速10%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹”
* 车辆行驶中若判断当前红灯自车基于当前速度需降低60%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹”
*/
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !isPrompted){
//车辆等红灯,在红/黄灯剩余5s且下一灯态为绿灯时提示“红灯即将变绿”并在变为绿灯时有提示起步的动效
if((light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_YELLOW_FUSION || light.state ==FusionTrafficLightOuterClass.FusionLightState.STATE_RED_FUSION)
&& light.duration < 5 && light.nextState == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION){
//语音播放
//语音播放:红灯即将变绿
AIAssist.getInstance(mContext).speakTTSVoice("红灯即将变绿")
isPrompted = true
}
//车辆行驶中若判断当前绿灯自车无法通过在绿灯剩余5s且下一灯态为红/黄灯时,提示“蘑菇提醒您及时减速,避免路口急刹”
if(light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION && light.duration < 5){
CallerMapRoadListenerManager.getStopLineDistance()?.let { dis->
if(currentSpeed*light.duration < dis){
//语音播放:蘑菇提醒您及时减速,避免路口急刹
AIAssist.getInstance(mContext).speakTTSVoice("蘑菇提醒您及时减速,避免路口急刹")
isPrompted = true
}
}
}
//车辆行驶中若判断当前绿灯自车基于当前速度需提速10%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹”
if(light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION){
CallerMapRoadListenerManager.getStopLineDistance()?.let{distance->
if(currentSpeed*light.duration*1.1 < distance){
//语音播放:蘑菇提醒您及时减速,避免路口急刹
AIAssist.getInstance(mContext).speakTTSVoice("蘑菇提醒您及时减速,避免路口急刹")
isPrompted = true
}
}
}
//车辆行驶中若判断当前红灯自车基于当前速度需降低60%以上才可通过时,提示“蘑菇提醒您及时减速,避免路口急刹”
if(light.state ==FusionTrafficLightOuterClass.FusionLightState.STATE_RED_FUSION){
CallerMapRoadListenerManager.getStopLineDistance()?.let{distance->
if(currentSpeed*0.4*light.duration > distance){
//语音播放:蘑菇提醒您及时减速,避免路口急刹
AIAssist.getInstance(mContext).speakTTSVoice("蘑菇提醒您及时减速,避免路口急刹")
isPrompted = true
}
}
}
//TODO 需要知道当前车速和当前位置距离路口的距离
// if(light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION && light.duration < 5){
//
// }
}
@@ -464,6 +504,15 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
CallerTrafficLightListenerManager.removeListener(TAG)
//取消注册监听工控机感知红绿灯
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
//取消注册获取当前车速
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
}
/**
* 当前车速
*/
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
currentSpeed = abs(mogoLocation?.gnssSpeed ?: 0f)
}
}