[8.1.0][feat]优化决策功能

This commit is contained in:
chenfufeng
2025-06-16 20:02:27 +08:00
parent 157ab16b4d
commit ae836ca847
12 changed files with 249 additions and 26 deletions

View File

@@ -11,6 +11,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListe
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.map.MogoMap
import com.mogo.map.MogoMap.Companion.mapInstance
import me.jessyan.autosize.utils.AutoSizeUtils
import mogo.telematics.pad.MessagePad
class DecisionDataManager private constructor() : IMoGoPlanningTrajectoryListener {
@@ -38,6 +39,22 @@ class DecisionDataManager private constructor() : IMoGoPlanningTrajectoryListene
private var lastUpdateTime = 0L
/**
* 高精地图宽、高
*/
@Volatile
var mapWidth = 808
@Volatile
var mapHeight = 1300
/**
* 决策地图宽、高
*/
@Volatile
var decWidth = 238
@Volatile
var decHeight = 458
init {
val frequentThread = HandlerThread("decision_thread")
frequentThread.start()
@@ -93,15 +110,12 @@ class DecisionDataManager private constructor() : IMoGoPlanningTrajectoryListene
var y = 0f
var offset = 0f
for (i in 0 until lonLatList.size) {
x = lonLatList[i].x * 238 / 808.toFloat()
x = lonLatList[i].x * decWidth / mapWidth.toFloat()
points[i * 2] = x
// TODO:需要根据UI布局而变化成比例缩放(高精地图返回的y轴是镜像的需要在y轴方向上翻转一下)
// float yB = heightB - (yA * (heightB / heightA));
// yB = 480 - (yA * 480 / 1300)
y = (458 + 14 - lonLatList[i].y * 458 / 1300).toFloat()
y = (decHeight + 14 - lonLatList[i].y * decHeight / mapHeight).toFloat()
if (i == 0) {
offset = 357 - y// carBitmapTop等于height * 0.78offset = carBitmapTop - 1stY
offset = decHeight * 0.78f - y// carBitmapTop等于height * 0.78offset = carBitmapTop - 1stY
}
points[i * 2 + 1] = y + offset
Log.d(TAG, "转换后的屏幕坐标为:(${x},${y})")

View File

@@ -35,6 +35,22 @@ class PredictionDataManager private constructor() {
private var lastUpdateTime = 0L
/**
* 高精地图宽、高
*/
@Volatile
var mapWidth = 808
@Volatile
var mapHeight = 1300
/**
* 决策地图宽、高
*/
@Volatile
var decWidth = 238
@Volatile
var decHeight = 458
init {
val frequentThread = HandlerThread("prediction_thread")
frequentThread.start()
@@ -95,15 +111,12 @@ class PredictionDataManager private constructor() {
var y = 0f
var offset = 0f
for (i in 0 until lonLatList.size) {
x = lonLatList[i].x * 238 / 808.toFloat()
x = lonLatList[i].x * decWidth / mapWidth.toFloat()
points[i * 2] = x
// TODO:需要根据UI布局而变化成比例缩放(高精地图返回的y轴是镜像的需要在y轴方向上翻转一下)
// float yB = heightB - (yA * (heightB / heightA));
// yB = 480 - (yA * 480 / 1300)
y = (458 + 14 - lonLatList[i].y * 458 / 1300).toFloat()
y = (decHeight + 14 - lonLatList[i].y * decHeight / mapHeight).toFloat()
if (i == 0) {
offset = 357 - y// carBitmapTop等于height * 0.78offset = carBitmapTop - 1stY
offset = decHeight * 0.78f - y// carBitmapTop等于height * 0.78offset = carBitmapTop - 1stY
}
points[i * 2 + 1] = y + offset
Log.d(TAG, "预测数据转换后的屏幕坐标为:(${x},${y})")

View File

@@ -15,8 +15,11 @@ import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.business.routeoverlay.DecisionDataManager
import com.mogo.eagle.core.function.business.routeoverlay.PredictionDataManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
import com.mogo.eagle.core.function.map.R
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import me.jessyan.autosize.utils.AutoSizeUtils
import kotlin.math.min
@@ -110,6 +113,9 @@ class CoordinateAnimationView @JvmOverloads constructor(
AutoSizeUtils.dp2px(context, 128f),
AutoSizeUtils.dp2px(context, 280f)
)
if (index == 1) {
storeWidthsAndHeights()
}
// circlePaint = Paint()
// circlePaint!!.color = Color.RED
// circlePaint!!.style = Paint.Style.STROKE
@@ -156,6 +162,10 @@ class CoordinateAnimationView @JvmOverloads constructor(
setLayerType(LAYER_TYPE_HARDWARE, null)
}
private fun storeWidthsAndHeights() {
// TODO:("此时获得的宽高为0")
}
private fun getOriginBitmap(resId: Int, desWidth: Int, desHeight: Int): Bitmap {
val bitmap = BitmapFactory.decodeResource(resources, resId)
val scaleWidth = (bitmap.width * 2)

View File

@@ -26,15 +26,32 @@ class DecisionLayout @JvmOverloads constructor(
@Volatile
private var lastTime = 0L
private var carType = 0
init {
LayoutInflater.from(context).inflate(R.layout.layout_decision_container, this, true)
initView()
initView(attrs)
}
private fun initView() {
private fun initView(attrs: AttributeSet?) {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.CarMapLayout)
carType = typedArray.getInt(R.styleable.CarMapLayout_car_type, 0)
typedArray.recycle()
when (carType) {
0 -> LayoutInflater.from(context).inflate(R.layout.layout_decision_container, this, true)
else -> LayoutInflater.from(context).inflate(R.layout.layout_b2_decision_container, this, true)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
}
fun onCreate(savedInstanceState: Bundle?) {
}

View File

@@ -3,15 +3,20 @@ package com.mogo.eagle.core.function.view
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.util.Log
import androidx.lifecycle.LifecycleObserver
import chassis.Chassis
import com.mogo.eagle.core.data.config.FunctionBuildConfig.accThreshold
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisStatesListener
import com.mogo.eagle.core.function.business.routeoverlay.DecisionDataManager
import com.mogo.eagle.core.function.business.routeoverlay.PredictionDataManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisStatesListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.view.CoordinateAnimationView.Companion
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
import com.mogo.map.MogoMap
import com.mogo.map.MogoMapView

View File

@@ -12,13 +12,22 @@ class PredictionLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs) {
private var carType = 0
init {
LayoutInflater.from(context).inflate(R.layout.layout_prediction_container, this, true)
initView()
initView(attrs)
}
private fun initView() {
private fun initView(attrs: AttributeSet?) {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.CarMapLayout)
carType = typedArray.getInt(R.styleable.CarMapLayout_car_type, 0)
typedArray.recycle()
when (carType) {
0 -> LayoutInflater.from(context).inflate(R.layout.layout_prediction_container, this, true)
else -> LayoutInflater.from(context).inflate(R.layout.layout_b2_prediction_container, this, true)
}
}
fun onCreate(savedInstanceState: Bundle?) {

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<com.mogo.eagle.core.function.view.CoordinateAnimationView
android:id="@+id/preDetailView2"
android:layout_width="110dp"
android:layout_height="211dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="@dimen/dp_27"
android:layout_marginBottom="24dp"
app:map_index="0"
/>
<com.mogo.eagle.core.function.view.CoordinateAnimationView
android:id="@+id/decMapView"
android:layout_width="110dp"
android:layout_height="211dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="24dp"
app:map_index="1"
/>
<com.mogo.eagle.core.function.view.CoordinateAnimationView
android:id="@+id/preDetailView3"
android:layout_width="110dp"
android:layout_height="211dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="@dimen/dp_27"
android:layout_marginBottom="20dp"
app:map_index="2"
/>
<TextView
android:id="@+id/tvDecTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AIP 规划与决策"
android:textColor="#394047"
android:textSize="32dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/dp_39"
/>
<TextView
android:id="@+id/tvPre1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDecTitle"
android:layout_marginStart="@dimen/dp_58"
android:layout_marginTop="@dimen/dp_15"
android:text="11%"
android:textColor="#63707D"
android:textSize="33dp"
/>
<TextView
android:id="@+id/tvPre2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDecTitle"
android:layout_marginTop="@dimen/dp_15"
android:text="86%"
android:textColor="#63707D"
android:textSize="33dp"
/>
<TextView
android:id="@+id/tvPre3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDecTitle"
android:layout_marginEnd="@dimen/dp_58"
android:layout_marginTop="@dimen/dp_15"
android:text="3%"
android:textColor="#63707D"
android:textSize="33dp"
/>
</merge>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Prediction 预测"
android:textColor="#394047"
android:textSize="@dimen/dp_32"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/dp_41"
/>
<com.mogo.eagle.core.function.view.PredictionMapView
android:id="@+id/preDetailView"
android:layout_width="373dp"
android:layout_height="294dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="26dp"
app:carPosition="6"
app:isAutoLocation="false"
app:isDisplayAnim="false"
app:isWeatherEnable="false"
app:styleMode="MAP_STYLE_DAY_VR_AIP"
app:vrAngleMode="MAP_STYLE_VR_ANGLE_TOP" />
</merge>

View File

@@ -80,4 +80,11 @@
<declare-styleable name="CoordinateAnimationView">
<attr name="map_index" format="integer" />
</declare-styleable>
<declare-styleable name="CarMapLayout">
<attr name="car_type" format="enum" >
<enum name="Taxi" value="0" />
<enum name="B2" value="1" /> />
</attr>
</declare-styleable>
</resources>