[6.4.0][启自驾指引] a的值改为加速度值

This commit is contained in:
renwj
2024-04-28 16:26:00 +08:00
parent f2a0c20b03
commit e11d4a4003
5 changed files with 39 additions and 11 deletions

View File

@@ -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
}
}
/**

View File

@@ -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))
}
}
}

View File

@@ -26,7 +26,7 @@ internal class StatusModel : ViewModel() {
it += DoubleFlashStatus(0)
it += GearStatus(0)
it += RouteDownloadStatus()
it += SpeedStatus(0f)
it += SpeedStatus(0f, 0f)
})
}

View File

@@ -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")