[8.2.8][需求] AIP开关修改为随时开关,引导线更改为aip开启时使用不同的颜色

This commit is contained in:
xinfengkun
2025-12-03 14:02:21 +08:00
parent aa5fdae1ac
commit fcdeb250b5
11 changed files with 120 additions and 53 deletions

View File

@@ -93,12 +93,12 @@ class DecisionDataManager private constructor() : IMoGoPlanningTrajectoryListene
}
}
override fun onAutopilotTrajectory(trajectoryInfos: MutableList<MessagePad.TrajectoryPoint>) {
override fun onAutopilotTrajectory(trajectory: MessagePad.Trajectory) {
ThreadUtils.getCpuPool().execute {
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
mogoMap?.let { map ->
val lonLatList = ArrayList<android.graphics.Point>()
trajectoryInfos.forEach {
trajectory.pointsList.forEach {
map.toScreenLocation(it.longitude, it.latitude)?.let { point ->
lonLatList.add(point)
Log.d(TAG, "转换后的屏幕坐标为:(${point.x},${point.y})")

View File

@@ -28,7 +28,7 @@ public class MogoRouteOverlayManager implements
private static volatile MogoRouteOverlayManager sInstance;
private static final String TAG = "Route";
private final LinkedList<List<MessagePad.TrajectoryPoint>> queue = new LinkedList<>();
private final LinkedList<MessagePad.Trajectory> queue = new LinkedList<>();
private final AtomicBoolean hasGreenWave = new AtomicBoolean(false);
@@ -118,11 +118,11 @@ public class MogoRouteOverlayManager implements
}
@Override
public void onAutopilotTrajectory(@NonNull List<MessagePad.TrajectoryPoint> items) {
public void onAutopilotTrajectory(@NonNull MessagePad.Trajectory trajectory) {
// Log.d(TAG, "-- onAutopilotTrajectory --: " + (items != null ? items.size() : "0"));
synchronized (queue) {
queue.clear();
queue.offer(items);
queue.offer(trajectory);
}
}
@@ -147,8 +147,8 @@ public class MogoRouteOverlayManager implements
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 3 ---");
synchronized (queue) {
if (!queue.isEmpty()) {
List<MessagePad.TrajectoryPoint> items = queue.pollLast();
if (items != null && !items.isEmpty()) {
MessagePad.Trajectory items = queue.pollLast();
if (items != null && !items.getPointsList().isEmpty()) {
RouteOverlayDrawer.getInstance().drawTrajectoryList(items, gnssInfo.getHeading(), hasGreenWave.get());
}
}

View File

@@ -101,6 +101,7 @@ public class RouteOverlayDrawer {
private class RenderTask implements Runnable {
private volatile List<MessagePad.TrajectoryPoint> routeList;
private volatile boolean isAIPTrajectory;
private final Pools.Pool<MogoLatLng> pools;
private final LinkedList<MogoLatLng> points;
@@ -113,8 +114,9 @@ public class RouteOverlayDrawer {
this.points = new LinkedList<>();
}
public void setData(List<MessagePad.TrajectoryPoint> routeList, double bearing, boolean hasGreenWave) {
this.routeList = routeList;
public void setData(MessagePad.Trajectory trajectory, double bearing, boolean hasGreenWave) {
this.routeList = trajectory.getPointsList();
this.isAIPTrajectory = trajectory.getIsAIPTrajectory();
this.bearing = bearing;
this.hasGreenWave = hasGreenWave;
}
@@ -139,7 +141,8 @@ public class RouteOverlayDrawer {
}
boolean isColorfulStrategy = !hasGreenWave && !AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode);
if (isColorfulStrategy) {
RouteStrategy.INSTANCE.start();
RouteStrategy.INSTANCE.start(isAIPTrajectory);
// RouteStrategy.INSTANCE.start(FunctionBuildConfig.isActivateAip);
} else {
if (colors == null || colors.isEmpty()) {
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
@@ -294,12 +297,12 @@ public class RouteOverlayDrawer {
private volatile RenderTask mRenderTask;
public void drawTrajectoryList(List<MessagePad.TrajectoryPoint> routeList, double bearing, boolean hasGreenWave) {
public void drawTrajectoryList(MessagePad.Trajectory trajectory, double bearing, boolean hasGreenWave) {
if (mogoOverlayManager != null) {
if (mRenderTask == null) {
mRenderTask = new RenderTask();
}
mRenderTask.setData(routeList, bearing, hasGreenWave);
mRenderTask.setData(trajectory, bearing, hasGreenWave);
if (mRenderHandler != null) {
mRenderHandler.removeCallbacks(mRenderTask);
mRenderHandler.post(mRenderTask);

View File

@@ -23,6 +23,12 @@ class Colors {
val COLOR_BLUE_DARK = Color.parseColor("#FF074EFF")
val COLOR_RED_DARK = Color.parseColor("#FFFF5F00")
val COLOR_TRANSPARENT = Color.parseColor("#0030A3FF")
// 新增AIP 模式颜色定义
val COLOR_AIP_GREEN = Color.parseColor("#FFA428E1")
val COLOR_AIP_GREEN_DARK = Color.parseColor("#FFB948F8")
val COLOR_AIP_ORANGE = Color.parseColor("#FFFFF938")
val COLOR_AIP_TRANSPARENT = Color.parseColor("#00EA49FF")
}
}
@@ -53,7 +59,10 @@ object RouteStrategy {
private var index = 0
// 默认颜色映射表
private val sorted: NavigableMap<Double, Int> by lazy { TreeMap() }
// 新增AIP 颜色映射表
private val aipSorted: NavigableMap<Double, Int> by lazy { TreeMap() }
private var endEvaluator: ArgbEvaluator? = null
@@ -61,10 +70,18 @@ object RouteStrategy {
private var hasLessThan0 = false
// 新增:当前是否为 AIP 模式
private var isAipMode = false
// 修改:增加 isAip 参数,默认为 false
fun start() {
if (sorted.isEmpty()) {
start(false)
}
fun start(isAip: Boolean = false) {
if (sorted.isEmpty() || aipSorted.isEmpty()) {
fill()
}
isAipMode = isAip // 记录当前模式
strategy = null
index = 0
startColor = Int.MAX_VALUE
@@ -88,7 +105,9 @@ object RouteStrategy {
if (!isEnable) {
return
}
if (sorted.isEmpty()) {
// 根据模式选择对应的 Map
val currentMap = if (isAipMode) aipSorted else sorted
if (currentMap.isEmpty()) {
return
}
if (acc < 0) {
@@ -96,7 +115,8 @@ object RouteStrategy {
}
val delta = (total * 0.35).toInt()
val last = total - delta
val entry = sorted.floorEntry(acc)
val entry = currentMap.floorEntry(acc)
if (entry != null) {
if (index >= last - 1) {
if (startColor == Int.MAX_VALUE) {
@@ -108,10 +128,12 @@ object RouteStrategy {
} else {
if (endEvaluator != null) {
val fraction = (index - last) * 1.0f / delta
// 根据模式选择对应的透明尾色
val targetTransparent = if (isAipMode) Colors.COLOR_AIP_TRANSPARENT else COLOR_TRANSPARENT
colors += endEvaluator!!.evaluate(
fraction,
startColor,
COLOR_TRANSPARENT
targetTransparent
) as Int
}
}
@@ -126,10 +148,12 @@ object RouteStrategy {
if (!isEnable) {
return emptyList()
}
if (sorted.isEmpty()) {
// 根据模式选择对应的 Map 进行移除操作
val currentMap = if (isAipMode) aipSorted else sorted
if (currentMap.isEmpty()) {
throw AssertionError("sorted map must not be null.")
}
val entry = sorted.floorEntry(acc)
val entry = currentMap.floorEntry(acc)
if (entry != null) {
colors.remove(entry.value)
}
@@ -137,12 +161,15 @@ object RouteStrategy {
}
private fun fill() {
var startValue = -4.0
var endValue = 0.0
val step = 0.01
var current = startValue
val evaluator = ArgbEvaluator()
val interceptor = AccelerateInterpolator()
val step = 0.01
// 1. 填充默认颜色 (sorted)
// 减速段 (-4.0 ~ 0.0): 红 -> 蓝
var startValue = -4.0
var endValue = 0.0
var current = startValue
var total = endValue - startValue
while (current <= endValue) {
val fraction = interceptor.getInterpolation(((current - startValue) / total).toFloat())
@@ -150,17 +177,44 @@ object RouteStrategy {
sorted[current] = colorValue
current += step
}
// 加速段 (0.01 ~ 3.0): 蓝 -> 深蓝
startValue = 0.01
endValue = 3.0
current = startValue
total = endValue - startValue
while (current <= endValue) {
val fraction = (current - startValue) / total
val colorValue =
evaluator.evaluate(fraction.toFloat(), COLOR_BLUE, COLOR_BLUE_DARK) as Int
val colorValue = evaluator.evaluate(fraction.toFloat(), COLOR_BLUE, COLOR_BLUE_DARK) as Int
sorted[current] = colorValue
current += step
}
// 2. 填充 AIP 颜色 (aipSorted)
// 逻辑仿照上方:减速用 橙->绿,加速用 绿->深绿
// AIP 减速段 (-4.0 ~ 0.0): 橙色 -> 绿色
startValue = -4.0
endValue = 0.0
current = startValue
total = endValue - startValue
while (current <= endValue) {
val fraction = interceptor.getInterpolation(((current - startValue) / total).toFloat())
val colorValue = evaluator.evaluate(fraction, Colors.COLOR_AIP_ORANGE, Colors.COLOR_AIP_GREEN) as Int
aipSorted[current] = colorValue
current += step
}
// AIP 加速段 (0.01 ~ 3.0): 绿色 -> 深绿色
startValue = 0.01
endValue = 3.0
current = startValue
total = endValue - startValue
while (current <= endValue) {
val fraction = (current - startValue) / total
val colorValue = evaluator.evaluate(fraction.toFloat(), Colors.COLOR_AIP_GREEN, Colors.COLOR_AIP_GREEN_DARK) as Int
aipSorted[current] = colorValue
current += step
}
}
fun getStrategy(): Strategy = if (isEnable) {