Merge branch 'dev_robotaxi-d-app-module_290_220715_2.9.0' into 'test_robotaxi-d-app-module_290_220715_2.9.0.1'

Dev robotaxi d app module 290 220715 2.9.0

See merge request zhjt/AndroidApp/MoGoEagleEye!107
This commit is contained in:
wangmingjun
2022-08-03 09:03:32 +00:00
12 changed files with 129 additions and 65 deletions

View File

@@ -12,6 +12,8 @@ public class BusPassengerStation {
private String cityCode;
private double lon; //高精坐标
private double lat; //高精坐标
private double gcjLon; //高德坐标
private double gcjLat; //高德坐标
private int businessType; //站点类型9:taxi10:bus
private int status;
private int siteId;
@@ -72,6 +74,13 @@ public class BusPassengerStation {
return cityCode;
}
public double getGcjLon() {
return gcjLon;
}
public double getGcjLat() {
return gcjLat;
}
public int getBusinessType() {
return businessType;

View File

@@ -84,6 +84,10 @@ public class BusPassengerModel {
private double mLongitude, mLatitude;
List<BusPassengerStation> mStations = new ArrayList<>();
private int mNextStationIndex = 0;// 要到达站的index
private List<LatLng> mTwoStationsRouts = new ArrayList<>();
private BusPassengerModel() {
}
@@ -147,12 +151,21 @@ public class BusPassengerModel {
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
if (result.getSites() != null){
List<BusPassengerStation> stations = result.getSites();
mStations.clear();
mStations.addAll(stations);
for (int i = 0; i< stations.size(); i++){
BusPassengerStation station = stations.get(i);
if (station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving() && i+1 < stations.size()){
mRouteLineInfoCallback.updateStationsInfo(stations,i+1,false);
if(mNextStationIndex != i+1){
startRemainRouteInfo();
}
mNextStationIndex = i+1;
return;
}else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){
if (i == 0){
startOrStopRouteAndWipe(false);
}
startOrStopCalculateRouteInfo(false);
mRouteLineInfoCallback.updateStationsInfo(stations,i,true);
return;
@@ -354,7 +367,6 @@ public class BusPassengerModel {
List<MessagePad.Location> routePoints = routeList.getWayPointsList();
if (null != routePoints && routePoints.size() > 0){
updateRoutePoints(routePoints);
startRemainRouteInfo();
setRouteLineMarker();
startToRouteAndWipe();
}
@@ -366,31 +378,55 @@ public class BusPassengerModel {
List<LatLng> latLngModels = CoordinateCalculateRouteUtil
.coordinateConverterWgsToGcjListCommon(mContext,routePoints);
mRoutePoints.addAll(latLngModels);
calculateTwoStationsRoute();
}
float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mRoutePoints);
SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength);
private void calculateTwoStationsRoute(){
//找出前往站对应的轨迹点,拿出两站点的集合
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size());
if (mRoutePoints.size() > 0) {
if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex - 1 >=0){
mTwoStationsRouts.clear();
BusPassengerStation stationNext = mStations.get(mNextStationIndex);
BusPassengerStation stationCur = mStations.get(mNextStationIndex - 1);
//当前站在轨迹中对应的点
int currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints
,stationCur.getGcjLon(),stationCur.getGcjLat());
//要前往的站在轨迹中对应的点
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints
,stationNext.getGcjLon(),stationNext.getGcjLat());
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mTwoStationsRouts);
SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength);
if (mAutopilotPlanningCallback != null){
mAutopilotPlanningCallback.updateTotalDistance();
if (mAutopilotPlanningCallback != null){
mAutopilotPlanningCallback.updateTotalDistance();
}
}
}
}
public void dynamicCalculateRouteInfo() {
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
.getRemainPointListByCompare(mRoutePoints,mLongitude,mLatitude);
//计算当前位置和下一站的剩余点集合
//计算剩余点总里程和时间
calculateTwoStationsRoute();
if (mTwoStationsRouts.size() > 0){
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
.getRemainPointListByCompare(mTwoStationsRouts,mLongitude,mLatitude);
float lastSumLength = 0;
if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离
lastSumLength = CoordinateUtils.calculateLineDistance(
lastPoints.get(0).longitude, lastPoints.get(0).latitude,
mLongitude, mLatitude);
}else {
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
}
double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒
if (mAutopilotPlanningCallback != null){
mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime);
float lastSumLength = 0;
if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离
lastSumLength = CoordinateUtils.calculateLineDistance(
lastPoints.get(0).longitude, lastPoints.get(0).latitude,
mLongitude, mLatitude);
}else {
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
}
double lastTime = lastSumLength / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 ; //秒
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "lastSumLength = " + lastSumLength);
if (mAutopilotPlanningCallback != null){
mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime);
}
}
}
@@ -441,7 +477,7 @@ public class BusPassengerModel {
* @param isStart
*/
public void startOrStopCalculateRouteInfo(boolean isStart) {
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopOrderLoop() " + isStart);
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopCalculateRouteInfo() " + isStart);
if (isStart) {
BusPassengerModelLoopManager.getInstance().startCalculateRouteInfoLoop();
} else {

View File

@@ -139,7 +139,7 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
public void routeResult(List<LatLng> models, int haveArrivedIndex) {
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + models.size()
+ " haveArrivedIndex = "+haveArrivedIndex);
mView.routeResult(models,haveArrivedIndex);
runOnUIThread(() ->mView.routeResult(models,haveArrivedIndex));
}
@Override

View File

@@ -125,7 +125,6 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
public void updateRoutePlanningToNextStation(long meters, long timeInSecond){
//更新进度条
updateProgressBar(meters);
String dis = "0";
String disUnit = "公里";
if (meters > 0){

View File

@@ -298,6 +298,8 @@ public class BusPassengerMapDirectionView
}
public void clearCoordinatesLatLng(){
textureList.clear();
texIndexList.clear();
mCoordinatesLatLng.clear();
mLinePointsLatLng.clear();
}

View File

@@ -248,8 +248,8 @@ public class BusPassengerRouteFragment extends
if (currentStationIndex == 0 && isArrived){ //到达始发站且并未出发, 恢复站点marker 清楚路径 清空路径点
SharedPrefsMgr.getInstance(getContext())
.remove(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS);
clearPolyline();
if (mMapDirectionView != null) mMapDirectionView.clearCoordinatesLatLng();
clearPolyline();
}
if (stations.size() > 0){

View File

@@ -7,7 +7,7 @@
<com.mogo.och.common.module.wigets.OCHBorderShadowLayout
android:id="@+id/edge_view"
android:layout_width="720px"
android:layout_width="725px"
android:layout_height="match_parent"
app:shadowColor="@color/bus_p_route_view_left_edge_shadow"
app:xOffset="0px"

View File

@@ -79,7 +79,7 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
if (models == null) return;
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "routeResultByServer:" + models.size()
+ " haveArrivedIndex = " + haveArrivedIndex);
mView.routeResultByServer(models,haveArrivedIndex);
runOnUIThread(() ->mView.routeResultByServer(models,haveArrivedIndex));
}
@@ -94,9 +94,9 @@ public class TaxiPassengerServingOrderPresenter extends Presenter<TaxiPassengerS
TaxiPassengerModel.getInstance().queryOrderRouteList();
}
mView.updateOrderStatusView(order);
runOnUIThread(() ->mView.updateOrderStatusView(order));
}else if (mCurrentPassengerOrder.orderStatus != order.orderStatus) {
mView.updateOrderStatusView(order);
runOnUIThread(() ->mView.updateOrderStatusView(order));
if (TaxiPassengerOrderStatusEnum.OnTheWayToEnd.getCode() == order.orderStatus){
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "-----OnTheWayToEndStation----");

View File

@@ -1287,30 +1287,32 @@ public class TaxiModel {
* 实时计算当前剩余里程和时间
*/
public void dynamicCalculateRouteInfo() {
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
.getRemainPointListByCompare(mRoutePoints, mLongitude, mLatitude);
if (mRoutePoints.size() > 0){
List<LatLng> lastPoints = CoordinateCalculateRouteUtil
.getRemainPointListByCompare(mRoutePoints, mLongitude, mLatitude);
float lastSumLength = 0;
float lastSumLength = 0;
if (lastPoints.size() == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
lastSumLength = CoordinateUtils.calculateLineDistance(
lastPoints.get(0).longitude, lastPoints.get(0).latitude,
mLongitude, mLatitude);
} else {
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
if (lastPoints.size() == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
lastSumLength = CoordinateUtils.calculateLineDistance(
lastPoints.get(0).longitude, lastPoints.get(0).latitude,
mLongitude, mLatitude);
} else {
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
}
double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒
Logger.d(M_TAXI + "dynamicCalculateRouteInfo"
, "---lastSumLength: " + lastSumLength + "----lastTime : " + lastTime
+ " thread = "+ Thread.currentThread().getName());
mCurrentOCHOrder.decreaseTravelDistance(lastSumLength);
if (mOrderStatusCallback != null) {
mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime);
}
reportOrderRemain((long) lastSumLength, (long) lastTime);
}
double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒
Logger.d(M_TAXI + "dynamicCalculateRouteInfo"
, "---lastSumLength: " + lastSumLength + "----lastTime : " + lastTime
+ " thread = "+ Thread.currentThread().getName());
mCurrentOCHOrder.decreaseTravelDistance(lastSumLength);
if (mOrderStatusCallback != null) {
mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime);
}
reportOrderRemain((long) lastSumLength, (long) lastTime);
}
/**

View File

@@ -1,8 +1,10 @@
package com.mogo.eagle.core.function.hmi.ui.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
@@ -11,20 +13,16 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import mogo.telematics.pad.MessagePad;
/**
* @author Jing
@@ -42,6 +40,22 @@ public class TrafficDataView extends ConstraintLayout {
//圆弧颜色
private int mArcColor;
private static final int MSG_SEND_UPDATE = 1;
private volatile double acceleration;
@SuppressLint("HandlerLeak")
private final Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_SEND_UPDATE) {
java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.00");
String accStr = mFormat.format(acceleration);
accTextView.setText("a: " + accStr);
}
}
};
public TrafficDataView(@NonNull Context context) {
super(context);
}
@@ -64,12 +78,10 @@ public class TrafficDataView extends ConstraintLayout {
super.onAttachedToWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, gnssInfo -> {
CallerLogger.INSTANCE.d(TAG, "司机屏加速度:" + gnssInfo.getAcceleration());
ThreadUtils.runOnUiThread(() -> {
java.text.DecimalFormat mFormat = new java.text.DecimalFormat("0.00");
String accStr = mFormat.format(gnssInfo.getAcceleration());
accTextView.setText("a: " + accStr);
});
if (gnssInfo != null) {
acceleration = gnssInfo.getAcceleration();
}
handler.sendEmptyMessageDelayed(MSG_SEND_UPDATE, 1000L);
});
}
@@ -96,7 +108,7 @@ public class TrafficDataView extends ConstraintLayout {
*/
@Override
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
if(lightSwitch != null){
if (lightSwitch != null) {
CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString());
}
}

View File

@@ -308,7 +308,7 @@ public class AMapCustomView
Log.d(TAG, "onAutopilotRotting");
List list = globalPathResp.getWayPointsList();
int minCount = 2;
if (list.size() >= minCount && sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) {
if (list.size() >= minCount) {
calculate = true;
MessagePad.Location sLocation = (MessagePad.Location) list.get(0);
MessagePad.Location eLocation = (MessagePad.Location) list.get(list.size() - 1);

View File

@@ -40,6 +40,7 @@ class ColorfulStrategy(private val colors: List<Int> = emptyList(), var isLightO
object RouteStrategy {
@Volatile
private var isEnable = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) && !AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
private var strategy: Strategy? = null
@@ -65,6 +66,9 @@ object RouteStrategy {
}
fun start() {
if (sorted.isEmpty()) {
fill()
}
strategy = null
index = 0
startColor = Int.MAX_VALUE
@@ -89,10 +93,7 @@ object RouteStrategy {
return
}
if (sorted.isEmpty()) {
fill()
}
if (sorted.isEmpty()) {
throw AssertionError("sorted map must not be null.")
return
}
if (acc < 0) {
hasLessThan0 = true
@@ -122,6 +123,9 @@ object RouteStrategy {
}
fun remove(acc: Double): List<Int> {
if (!isEnable) {
return emptyList()
}
if (sorted.isEmpty()) {
throw AssertionError("sorted map must not be null.")
}