[6.4.0][启自驾指引] 优化轨迹下载逻辑;修正UI走查问题

This commit is contained in:
renwj
2024-04-25 19:46:28 +08:00
parent 541fbff590
commit cd79d7f50a
7 changed files with 204 additions and 37 deletions

View File

@@ -0,0 +1,159 @@
package com.mogo.functions.test
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.platform.app.InstrumentationRegistry
import chassis.Chassis.GearPosition.GEAR_R
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
import com.mogo.eagle.core.data.enums.DataSourceType.DEFAULT
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisBrakeStateListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGearStateListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisThrottleStateListenerManager
import com.mogo.eagle.core.function.main.MainLauncherActivity
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.SourceType.CHASSIS
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_BRAKE
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_GEAR
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_HAZARD_LIGHTS
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_STEERING
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
import function_state_management.FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import mogo_msg.MogoReportMsg.MogoMsgTimestamp
import mogo_msg.MogoReportMsg.MogoReportMessage
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import system_master.SsmInfo.ModeState
import system_master.SsmInfo.SsmStatusInf
import system_master.SystemStatusInfo
import system_master.SystemStatusInfo.SystemState.SYS_RUNNING
import java.util.concurrent.TimeUnit.MINUTES
import kotlin.random.Random
import kotlin.random.nextInt
@RunWith(AndroidJUnit4::class)
@LargeTest
class TestAutoPilotBeforeLaunch {
lateinit var launch: ActivityScenario<MainLauncherActivity>
@Before
fun before() {
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
}
@Test
fun test() = runBlocking {
val arguments = InstrumentationRegistry.getArguments()
val delay = arguments.getString("delay", "0")
val delayLong = delay.toLong()
if (delayLong <= 0) {
throw AssertionError("illegal state ..")
}
delay(delayLong)
launch(Dispatchers.IO) {
val line = AutoPilotLine(10L, "", "","", "", System.currentTimeMillis(), "")
var flag = false
while (true) {
CallerAutoPilotStatusListenerManager.invokeTrajectoryDownloadReq(line, 0)
CallerAutoPilotStatusListenerManager.invokeAutopilotGuardian(
MogoReportMessage.getDefaultInstance()
.toBuilder()
.setTimestamp(MogoMsgTimestamp.getDefaultInstance().toBuilder().setSec(1).setNsec(1).build())
.setSrc("1")
.setLevel("1")
.setCode("ISYS_INIT_TRAJECTORY_START")
.setMsg("lineid:10")
.build())
delay(2000)
CallerAutoPilotStatusListenerManager.invokeAutopilotGuardian(
MogoReportMessage.getDefaultInstance()
.toBuilder()
.setTimestamp(MogoMsgTimestamp.getDefaultInstance().toBuilder().setSec(1).setNsec(1).build())
.setSrc("1")
.setLevel("1")
.setCode(if (flag) "ISYS_INIT_TRAJECTORY_SUCCESS" else "ISYS_INIT_TRAJECTORY_FAILURE")
.setMsg("lineid:10")
.build())
delay(10000)
flag = !flag
}
}
launch(Dispatchers.IO) {
while (true) {
CallerChassisBrakeStateListenerManager.invokeAutopilotBrake(Random.nextInt(0 .. 100).toFloat())
CallerChassisThrottleStateListenerManager.invokeAutopilotThrottle(Random.nextInt(0..100).toFloat())
CallerChassisGearStateListenerManager.invokeAutopilotGearData(GEAR_R)
val current = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(current.also { it.gnssSpeed = Random.nextInt(0 ..20).toFloat() }, DEFAULT)
delay(500)
}
}
launch(Dispatchers.IO) {
var flag = 1
var isAbility = false
while (true) {
if (flag > 6) {
flag = 1
}
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE
if (flag == 1) {
CallerAutopilotActionsListenerManager.invokeAutopilotAbility(isAbility, UnableLaunchData("", SystemStatusInfo.StatusInfo.getDefaultInstance().toBuilder().setSysState(SYS_RUNNING).build(), SsmStatusInf.getDefaultInstance().toBuilder().setModeState(ModeState.MODE_RUN_READY).setAutoPilotReady(false).setRemotePilotReady(false).build(), FSMStatusReasonRespond.getDefaultInstance()), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_GEAR, "gear")
})
}
if (flag == 2) {
CallerAutopilotActionsListenerManager.invokeAutopilotAbility(isAbility, UnableLaunchData("", SystemStatusInfo.StatusInfo.getDefaultInstance().toBuilder().setSysState(SYS_RUNNING).build(), SsmStatusInf.getDefaultInstance().toBuilder().setModeState(ModeState.MODE_RUN_READY).setAutoPilotReady(false).setRemotePilotReady(false).build(), FSMStatusReasonRespond.getDefaultInstance()), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_STEERING, "steering")
})
}
if (flag == 3) {
CallerAutopilotActionsListenerManager.invokeAutopilotAbility(isAbility, UnableLaunchData("", SystemStatusInfo.StatusInfo.getDefaultInstance().toBuilder().setSysState(SYS_RUNNING).build(), SsmStatusInf.getDefaultInstance().toBuilder().setModeState(ModeState.MODE_RUN_READY).setAutoPilotReady(false).setRemotePilotReady(false).build(), FSMStatusReasonRespond.getDefaultInstance()), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_BRAKE, "brake")
})
}
if (flag == 4) {
CallerAutopilotActionsListenerManager.invokeAutopilotAbility(isAbility, UnableLaunchData("", SystemStatusInfo.StatusInfo.getDefaultInstance().toBuilder().setSysState(SYS_RUNNING).build(), SsmStatusInf.getDefaultInstance().toBuilder().setModeState(ModeState.MODE_RUN_READY).setAutoPilotReady(false).setRemotePilotReady(false).build(), FSMStatusReasonRespond.getDefaultInstance()), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_HAZARD_LIGHTS, "lights")
})
}
if (flag == 5) {
CallerAutopilotActionsListenerManager.invokeAutopilotAbility(isAbility, UnableLaunchData("", SystemStatusInfo.StatusInfo.getDefaultInstance().toBuilder().setSysState(SYS_RUNNING).build(), SsmStatusInf.getDefaultInstance().toBuilder().setModeState(ModeState.MODE_RUN_READY).setAutoPilotReady(false).setRemotePilotReady(false).build(), FSMStatusReasonRespond.getDefaultInstance()), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_THROTTLE, "throttle")
})
}
if (flag == 6) {
CallerAutopilotActionsListenerManager.invokeAutopilotAbility(isAbility, UnableLaunchData("", SystemStatusInfo.StatusInfo.getDefaultInstance().toBuilder().setSysState(SYS_RUNNING).build(), SsmStatusInf.getDefaultInstance().toBuilder().setModeState(ModeState.MODE_RUN_READY).setAutoPilotReady(false).setRemotePilotReady(false).build(), FSMStatusReasonRespond.getDefaultInstance()), ArrayList<UnableLaunchReason>().also {
it += UnableLaunchReason(CHASSIS, CHASSIS_GEAR, "gear")
it += UnableLaunchReason(CHASSIS, CHASSIS_STEERING, "steering")
it += UnableLaunchReason(CHASSIS, CHASSIS_HAZARD_LIGHTS, "lights")
it += UnableLaunchReason(CHASSIS, CHASSIS_THROTTLE, "throttle")
it += UnableLaunchReason(CHASSIS, CHASSIS_BRAKE, "brake")
})
}
delay(2000)
// isAbility = !isAbility
flag ++
}
}
delay(MINUTES.toMillis(10))
}
}