From 26d3e2c31f966dfe36610f7b81c5c764314b1eac Mon Sep 17 00:00:00 2001 From: liujing Date: Mon, 27 Jun 2022 19:42:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A4=E5=86=85=E6=A8=A1=E6=8B=9F=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E8=B7=AF=E7=BA=BF,=E5=B7=A5=E6=8E=A7=E6=9C=BA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AE=E9=AA=8C=E8=AF=81,?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8D=E7=B2=BE=E7=A1=AE=E5=BE=85=E8=81=94?= =?UTF-8?q?=E8=B0=83,=E6=95=B0=E6=8D=AE=E5=8F=8D=E9=A6=88=E4=B8=8A?= =?UTF-8?q?=E7=BA=BF=E6=97=B6=E9=97=B47=E6=9C=88=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../och/bus/fragment/BaseBusTabFragment.java | 16 +- .../src/main/res/layout/bus_base_fragment.xml | 16 +- .../hmi/ui/setting/DebugSettingView.kt | 2 +- .../core/function/smp/AMapCustomView.java | 187 ++++++++++++------ 4 files changed, 142 insertions(+), 79 deletions(-) diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java index b7fb30a40b..2a672ce3b3 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/BaseBusTabFragment.java @@ -73,6 +73,7 @@ public abstract class BaseBusTabFragment private FrameLayout flStationPanelContainer; private Group groupTestPanel; private FrameLayout flSpeed; + private BusArcView mouduleArc; private TrafficDataView dataView; private ImageView mUpgradeTipIv; // private BusTrafficLightView mTrafficLightView; @@ -119,7 +120,7 @@ public abstract class BaseBusTabFragment tvOperationStatus = findViewById(R.id.module_mogo_och_operation_status); flSpeed = (FrameLayout) findViewById(R.id.fl_speed); - dataView = (TrafficDataView) findViewById(R.id.bus_arc); + mouduleArc = (BusArcView) findViewById(R.id.bus_arc); panelView = LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer); slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener); @@ -147,8 +148,8 @@ public abstract class BaseBusTabFragment }); if (DebugConfig.isDebug()) { - dataView.setLongClickable(true); - dataView.setOnLongClickListener(v -> { + mouduleArc.setLongClickable(true); + mouduleArc.setOnLongClickListener(v -> { CallerLogger.INSTANCE.d(M_BUS + TAG, "长按显示状态工具栏"); Intent intent = new Intent(); intent.putExtra("oper", 52); @@ -479,10 +480,11 @@ public abstract class BaseBusTabFragment */ public void updateSpeedView(float newSpeed) { int speed = (int) (Math.abs(newSpeed) * 3.6F); // 倒车时工控机反馈定位信息中speed为负值 - dataView.showWithSpeedValue(speed); -// mouduleArc.setArcColor(Color.parseColor(speed > 60 ? "#DB3137" : "#3E77F6")); -// mouduleArc.setValues(speed); -// flSpeed.setBackgroundResource(speed > 60 ? R.drawable.bus_yi_biao_pan_bg_speeding : R.drawable.bus_yi_biao_pan_bg_nor); +// dataView.showWithSpeedValue(speed); + + mouduleArc.setArcColor(Color.parseColor(speed > 60 ? "#DB3137" : "#3E77F6")); + mouduleArc.setValues(speed); + flSpeed.setBackgroundResource(speed > 60 ? R.drawable.bus_yi_biao_pan_bg_speeding : R.drawable.bus_yi_biao_pan_bg_nor); } @Override diff --git a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml index 87e3d95737..6cd385a177 100644 --- a/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml +++ b/OCH/mogo-och-bus/src/main/res/layout/bus_base_fragment.xml @@ -17,16 +17,16 @@ app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent"> - - - - - - + + + + + diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 29b3a37abe..4ea05b2f14 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -776,7 +776,7 @@ class DebugSettingView @JvmOverloads constructor( SharedPrefsMgr.getInstance(context) .getString(MoGoConfig.AUTOPILOT_IP, FunctionBuildConfig.adasConnectIP) - etAutopilotIP.setText("172.30.10.10:41102") + etAutopilotIP.setText("192.168.1.") etAutopilotIP.text?.let { etAutopilotIP.setSelection(it.length) } //设置工控机IP btnSetAutopilotIP.setOnClickListener { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java index 2860310db1..f271a51d52 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java @@ -1,12 +1,7 @@ package com.mogo.eagle.core.function.smp; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X; -import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA; - import android.content.Context; import android.graphics.BitmapFactory; -import android.graphics.Color; import android.location.Location; import android.os.Bundle; import android.util.AttributeSet; @@ -18,18 +13,14 @@ import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.Nullable; -import androidx.annotation.UiThread; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdate; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.CoordinateConverter; import com.amap.api.maps.UiSettings; -import com.amap.api.maps.model.CameraPosition; import com.amap.api.maps.model.LatLng; -import com.amap.api.maps.model.LatLngBounds; import com.amap.api.maps.model.Polyline; -import com.amap.api.maps.model.PolylineOptions; import com.amap.api.navi.AMapNavi; import com.amap.api.navi.AMapNaviListener; import com.amap.api.navi.AMapNaviView; @@ -52,23 +43,21 @@ import com.amap.api.navi.model.NaviInfo; import com.amap.api.navi.model.NaviLatLng; import com.amap.api.navi.model.RouteOverlayOptions; import com.autonavi.tbt.TrafficFacilityInfo; -import com.mogo.cloud.commons.utils.CoordinateUtils; -import com.mogo.commons.AbsMogoApplication; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; import com.mogo.eagle.core.function.map.R; import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.eagle.core.widget.RoundLayout; -import com.mogo.map.MogoMarkerManager; -import com.mogo.map.marker.IMogoMarkerManager; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.ThreadUtils; import com.mogo.module.common.utils.DrivingDirectionUtils; +import com.zhidao.support.adas.high.AdasManager; import org.jetbrains.annotations.NotNull; @@ -76,6 +65,9 @@ import java.util.ArrayList; import java.util.List; import mogo.telematics.pad.MessagePad; +import mogo_msg.MogoReportMsg; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P; /** * 小地图的方向View @@ -86,14 +78,16 @@ import mogo.telematics.pad.MessagePad; */ public class AMapCustomView extends RelativeLayout - implements IMoGoMapLocationListener, ISmallMapDirectionView, AMapNaviListener, AMapNaviViewListener, IMoGoAutopilotPlanningListener { + implements IMoGoMapLocationListener, ISmallMapDirectionView, AMapNaviListener, AMapNaviViewListener { public static final String TAG = "SmallMapDirectionView"; private AMapNaviView mAMapNaviView; protected AMapNavi mAMapNavi; private AMap mAMap; + protected NaviLatLng mStartLatlng = new NaviLatLng(); + protected NaviLatLng mEndLatlng = new NaviLatLng(); //328路线测试数据 - protected NaviLatLng mStartLatlng = new NaviLatLng(39.969111, 116.411903); - protected NaviLatLng mEndLatlng = new NaviLatLng(40.037209, 116.314358); +// protected NaviLatLng mStartLatlng = new NaviLatLng(39.969111, 116.411903); +// protected NaviLatLng mEndLatlng = new NaviLatLng(40.037209, 116.314358); //顺义国展测试数据 // mStartLatlng = new NaviLatLng(40.09383,116.51899); // mEndLatlng = new NaviLatLng(40.09964,116.54570); @@ -108,6 +102,7 @@ public class AMapCustomView private Context mContext; private float tilt = 40f; private TextView overLayerView; + private boolean calculate = false; public AMapCustomView(Context context) { this(context, null); @@ -128,8 +123,6 @@ public class AMapCustomView private void initView(Context context) { mContext = context; - sList.add(mStartLatlng); - eList.add(mEndLatlng); //测试代码:路线指定路径328线路 // mWayPointList.add(new NaviLatLng(39.968847, 116.406952)); // mWayPointList.add(new NaviLatLng(39.969058, 116.407346)); @@ -141,6 +134,7 @@ public class AMapCustomView // mWayPointList.add(new NaviLatLng(40.037239, 116.337172)); // mWayPointList.add(new NaviLatLng(40.035897, 116.329582)); // mWayPointList.add(new NaviLatLng(40.036396, 116.322166)); + Log.d(TAG, "initView:" + mWayPointList.toString()); //顺义国展路线 // mWayPointList.add(new NaviLatLng(40.097621,116.526495)); @@ -156,6 +150,8 @@ public class AMapCustomView mAMapNavi = AMapNavi.getInstance(context); mAMapNavi.addAMapNaviListener(this); mAMapNaviView.setAMapNaviViewListener(this); + CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener); + CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); initAMapView(context); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); @@ -165,11 +161,113 @@ public class AMapCustomView }); } + private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() { + + @Override + public void onAutopilotIpcConnectStatusChanged(int status, @org.jetbrains.annotations.Nullable String reason) { + + } + + @Override + public void onAutopilotGuardian(@org.jetbrains.annotations.Nullable MogoReportMsg.MogoReportMessage guardianInfo) { + + } + + @Override + public void onAutopilotSNRequest() { + + } + + @Override + public void onAutopilotArriveAtStation(@org.jetbrains.annotations.Nullable MessagePad.ArrivalNotification arrivalNotification) { + + } + + @Override + public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { + ThreadUtils.runOnUiThread(new Runnable() { + @Override + public void run() { + if (autoPilotStatusInfo == null) return; + int state = autoPilotStatusInfo.getState(); + //0 不能自动驾驶 1 可以自动驾驶,但是在人工干预 2 自动驾驶中 + if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + Log.d(TAG, "自动驾驶中= %s" + String.valueOf(state)); + if (sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { + Log.d(TAG, "sendGlobalPathReq"); + AdasManager.getInstance().sendGlobalPathReq(); + } + } else { + int type = mAMapNavi.getNaviType(); + Log.d(TAG, "非自动驾驶状态,导航类型==" + String.valueOf(type)); + if (type == NaviType.GPS || type == NaviType.EMULATOR) { + mAMapNavi.stopNavi(); + } + } + } + }); + } + }; + + private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener() { + + @Override + public void onAutopilotTrajectory(@NotNull List trajectoryInfos) { + Log.d(TAG, "onAutopilotTrajectory"); + } + + /** + * 根据全路径获取起始点和经停点进行导航路线绘制 + * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 + * 室内某个bag包自动驾驶启动8s后返回 + */ + @Override + public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) { + if (calculate == true) { + return; + } + calculate = true; + Log.d(TAG, "onAutopilotRotting"); + List list = globalPathResp.getWayPointsList(); + int minCount = 2; + if (list.size() >= minCount && sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { + calculate = true; + MessagePad.Location sLocation = (MessagePad.Location) list.get(0); + MessagePad.Location eLocation = (MessagePad.Location) list.get(list.size() - 1); + mStartLatlng = new NaviLatLng(sLocation.getLatitude(), sLocation.getLongitude()); + mEndLatlng = new NaviLatLng(eLocation.getLatitude(), eLocation.getLongitude()); + sList.clear(); + eList.clear(); + sList.add(mStartLatlng); + eList.add(mEndLatlng); + + mWayPointList.clear(); + for (int i = 1; i < list.size() - minCount; i++) { + MessagePad.Location wayLoc = (MessagePad.Location) list.get(i); + NaviLatLng way = new NaviLatLng(wayLoc.getLatitude(), wayLoc.getLongitude()); + mWayPointList.add(way); + } + } + int strategy = 0; + try { + //再次强调,最后一个参数为true时代表多路径,否则代表单路径 + strategy = mAMapNavi.strategyConvert(true, false, false, false, false); + } catch (Exception e) { + e.printStackTrace(); + } + Log.d(TAG, "全局路径" + list.size() + ",起点:" + sList.toString() + ",终点:" + eList.toString() + ",经点:" + mWayPointList.toString()); + //指定路径绘制导航路线 + mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy); + } + }; + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.removeListener(TAG); + CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(TAG); + CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); } private void initAMapView(Context context) { @@ -243,7 +341,7 @@ public class AMapCustomView @Override public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) { - Log.d(TAG, "高精定位onLocationChanged" + location.toString()); + } private void removeLocation(Location latLng) { @@ -349,6 +447,7 @@ public class AMapCustomView @Override public void onInitNaviFailure() { + calculate = false; Log.d(TAG, "onInitNaviFailure"); } @@ -371,7 +470,7 @@ public class AMapCustomView @Override public void onLocationChange(AMapNaviLocation aMapNaviLocation) { - Log.d(TAG, "高德地图经纬度:" + aMapNaviLocation.getCoord().getLongitude() + "," + aMapNaviLocation.getCoord().getLatitude()); +// Log.d(TAG, "高德地图经纬度:" + aMapNaviLocation.getCoord().getLongitude() + "," + aMapNaviLocation.getCoord().getLatitude()); } @@ -595,42 +694,4 @@ public class AMapCustomView } - @Override - public void onAutopilotTrajectory(@NotNull List trajectoryInfos) { - - } - - /** - * 根据全路径获取起始点和经停点进行导航路线绘制 - * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 - * 室内某个bag包自动驾驶启动8s后返回 - */ - @Override - public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) { - List list = globalPathResp.getWayPointsList(); - int minCount = 2; - if (list.size() >= minCount) { - Location sLocation = (Location) list.get(0); - Location eLocation = (Location) list.get(list.size() - 1); - mStartLatlng = new NaviLatLng(sLocation.getLongitude(), sLocation.getLatitude()); - mEndLatlng = new NaviLatLng(eLocation.getLongitude(), eLocation.getLatitude()); - sList.add(mStartLatlng); - eList.add(mEndLatlng); - for (int i = 1; i < list.size() - minCount; i++) { - Location wayLoc = (Location) list.get(i); - NaviLatLng way = new NaviLatLng(wayLoc.getLongitude(), wayLoc.getLatitude()); - mWayPointList.add(way); - } - } - int strategy = 0; - try { - //再次强调,最后一个参数为true时代表多路径,否则代表单路径 - strategy = mAMapNavi.strategyConvert(true, false, false, false, false); - } catch (Exception e) { - e.printStackTrace(); - } - Log.d(TAG, "calculateDriveRoute ADAS全局路径坐标:" + list.size() + "," + sList.toString() + "," + eList.toString() + "," + mWayPointList.toString()); - //指定路径绘制导航路线 - mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy); - } }