[6.4.0][启自驾指引] a的值改为加速度值
This commit is contained in:
@@ -133,7 +133,7 @@ class TestAutoPilotBeforeLaunch {
|
||||
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)
|
||||
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(current.also { it.gnssSpeed = Random.nextInt(0 ..20).toFloat(); it.setAcceleration(Random.nextInt(-100, 100).toDouble()) }, DEFAULT)
|
||||
delay(Random.nextInt(10..50).toLong())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,12 +297,31 @@ interface IAutopilotPreLaunchStatus
|
||||
/**
|
||||
* 速度
|
||||
*/
|
||||
data class SpeedStatus(val speed: Float): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
data class SpeedStatus(val speed: Float, var acc: Float): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as SpeedStatus
|
||||
|
||||
if (speed != other.speed) return false
|
||||
if (acc != other.acc) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = speed.hashCode()
|
||||
result = 31 * result + acc.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,10 @@ internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLoc
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var last: Float? = null
|
||||
private var lastSpeed: Float? = null
|
||||
|
||||
@Volatile
|
||||
private var lastAcc: Float? = null
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 5, this)
|
||||
@@ -36,10 +39,17 @@ internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLoc
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (last != mogoLocation?.gnssSpeed) {
|
||||
send(SpeedStatus(mogoLocation?.gnssSpeed ?: 0f))
|
||||
last = mogoLocation?.gnssSpeed
|
||||
var isChanged = false
|
||||
if (lastSpeed != mogoLocation?.gnssSpeed) {
|
||||
isChanged = true
|
||||
lastSpeed = mogoLocation?.gnssSpeed
|
||||
}
|
||||
if (!isChanged && lastAcc != mogoLocation?.acceleration) {
|
||||
isChanged = true
|
||||
lastAcc = mogoLocation?.acceleration
|
||||
}
|
||||
if (isChanged) {
|
||||
send(SpeedStatus(mogoLocation?.gnssSpeed ?: 0f, mogoLocation?.acceleration ?: 0f))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ internal class StatusModel : ViewModel() {
|
||||
it += DoubleFlashStatus(0)
|
||||
it += GearStatus(0)
|
||||
it += RouteDownloadStatus()
|
||||
it += SpeedStatus(0f)
|
||||
it += SpeedStatus(0f, 0f)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -88,9 +88,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
}
|
||||
}
|
||||
is AcceleratorStatus -> {
|
||||
val angle = status.angle
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
tv_brake_or_accelerator?.text = "a:${angle.toInt()}"
|
||||
}
|
||||
is BrakeStatus -> {
|
||||
val angle = status.angle
|
||||
@@ -105,6 +103,7 @@ class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
}
|
||||
is SpeedStatus -> {
|
||||
speed?.text = "${(abs(status.speed) * 3.6f).toInt()}"
|
||||
tv_brake_or_accelerator?.text = String.format("%.1f", status.acc)
|
||||
}
|
||||
else -> {
|
||||
Logger.d(TAG, "other state: $status")
|
||||
|
||||
Reference in New Issue
Block a user