opt mogoobu

This commit is contained in:
lixiaopeng
2021-06-21 18:21:20 +08:00
parent ada2cb1c16
commit a9b8067d5d
2 changed files with 77 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XObuEventEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
@@ -29,6 +30,8 @@ import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.ObuConfig;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.adas.entity.ADASRecognizedResult;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
@@ -46,6 +49,7 @@ import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo;
import com.zhidao.support.obu.MogoObuManager;
import com.zhidao.support.obu.OnMogoObuListener;
import com.zhidao.support.obu.constants.ObuConstants;
import com.zhidao.support.obu.model.CvxAppInitIndInfo;
import com.zhidao.support.obu.model.CvxHvCarIndInfo;
import com.zhidao.support.obu.model.CvxHvInfoIndInfo;
@@ -56,6 +60,7 @@ import com.zhidao.support.obu.model.CvxV2vThreatIndInfo;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -94,6 +99,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
private final Handler handler = new Handler(this);
private final ObuTypeExchangeReceiver obuTypeExchangeReceiver = new ObuTypeExchangeReceiver();
private ObuManager obuManager;
final String icw_data = "02000114010000000000001effd7892b11a4440af70100142a03000907e506100e2917019000005662010a45000b0000220847162c000037970010000a17f6215c459478b6010347ac045000090a0006012c01f4009600080073007300730073000b000000000000000000000000000000002b000037780000247300003261000000000000426c827f47001200100000000000000000000021220000349a006c0010000a17f63ecb45947ba301030000332c0010000a17f642e945947bea010300004d580010000a17f6435545947e4e0103000054c40010000a17f6413a45947f96010300005c300010000a17f62c2845947d140103000070e40010000a17f5fdb14594786001030000992000060004ffec2710";
public void init(Context context) {
Logger.d(MODULE_NAME, "obuManager初始化--");
@@ -111,10 +117,11 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
MogoObuManager.getInstance().init(context);
MogoObuManager.getInstance().connect();
MogoObuManager.getInstance().registerListener(mogoObuListener);
MogoObuManager.getInstance().unregisterListener();
//TODO 测试
// MogoObuManager.getInstance().test(icw_data);
// UiThreadHandler.postDelayed( () -> {
// //TODO 测试
// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(3, MogoReceiver.ACTION_V2X_FRONT_WARNING);
// handleSdkObu(1);
//
@@ -191,19 +198,66 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
@Override
public void onCvxV2vThreatIndInfo(CvxV2vThreatIndInfo info) {
//预警信息
Logger.e("liyz", "onCvxRvInfoIndInfo ------> " + info.toString());
Logger.e("liyz", "onCvxV2vThreatIndInfo ------> " + info.toString());
//预警类型 threat_level 3
if (info != null) {
if (info.getThreat_info() != null && info.getControl() != null &&
info.getThreat_info().getThreat_level() == 3) { //看看2的情况
//预警方位
int direction = V2XUtils.getDirection((float) info.getExt_info().getAzimuth());
Log.d("liyz", "direction = " + direction + "---azimuth = " + (float) info.getExt_info().getAzimuth());
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING);
//预警数据的组装,车辆实时移动和变色。
//预警方位
//预警类型
//处理预警类型
int appId = info.getThreat_info().getApp_id();
handleSdkObu(getEventType(appId));
}
//预警数据的组装,车辆实时移动和变色 TODO 这里需要obu提供他车列表
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(getResultList(info));
} else {
Log.e("liyz", "info == null ");
}
}
};
private int getEventType(int appid) {
if (appid == ObuConstants.USE_CASE_ID.EBW) {
return ObuConstant.TYPE_URGENCY_COLLISION_WARNING;
} else if (appid == ObuConstants.USE_CASE_ID.ICW) {
return ObuConstant.TYPE_CROSS_COLLISION_WARNING;
}
return 0;
}
private List<ADASRecognizedResult> resultList = null;
private List<ADASRecognizedResult> getResultList(CvxV2vThreatIndInfo info) {
if (resultList == null) {
resultList = new ArrayList<>();
}
ADASRecognizedResult adasRecognizedResult = new ADASRecognizedResult();
adasRecognizedResult.uuid = info.getVehicle_id();
if (info.getBasic_info() != null && info.getBasic_info().getPosition() != null) {
adasRecognizedResult.lat = info.getBasic_info().getPosition().getLatitude();
adasRecognizedResult.lon = info.getBasic_info().getPosition().getLongitude();
}
adasRecognizedResult.type = 3; //小轿车
adasRecognizedResult.heading = info.getBasic_info().getHeading();
adasRecognizedResult.speed = info.getBasic_info().getSpeed();
resultList.add(adasRecognizedResult);
return resultList;
}
// public void release() {
// NebulaObuClient.getInstance().unregisterObu();
// NebulaObuClient.getInstance().unregisterObuListener();
// MogoObuManager.getInstance().unregisterListener();
// }
/**
@@ -216,7 +270,6 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
//
// @Override
// public void onConnectFail(boolean isNeedReconnect) {
// Logger.d("liyz", "onConnectFail ------> ");
// }
//
// @Override
@@ -225,7 +278,6 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
//
// @Override
// public void onObuInfo(ObuInfo info) {
// Logger.d("liyz", "onObuInfo ------> " + info.toString());
// }
//
// @Override
@@ -243,22 +295,20 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
// }
// }
// };
private void handleSdkObu(int type) {
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
if (type == 1) { //交叉路口碰撞预警 TODO
if (type == ObuConstant.TYPE_CROSS_COLLISION_WARNING) { //交叉路口碰撞预警
urgencyEvent.setType(ObuConstant.TYPE_CROSS_COLLISION_WARNING);
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_CROING_WARN_TEXT);
} else if (type == 2) { // 前车紧急制动预警
} else if (type == ObuConstant.TYPE_URGENCY_COLLISION_WARNING) { // 前车紧急制动预警
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
} else {
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
// urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
// urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
}
messageEntity.setContent(urgencyEvent);
@@ -457,7 +507,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
// 暂无设计图,先简单显示
V2XObuEventEntity tmpEvent = new V2XObuEventEntity();
tmpEvent.setType(eventType);
tmpEvent.setDesc(info.getType()+"--"+info.getDescribe());
tmpEvent.setDesc(info.getType() + "--" + info.getDescribe());
messageEntity.setContent(tmpEvent);
V2XObuEventScenario.getInstance().init(messageEntity);
break;

View File

@@ -779,4 +779,16 @@ public class V2XUtils {
return flag;
}
public static int getDirection(float degree) {
if (degree > 45 && degree < 135) {
return 1; //前方
} else if (degree > 135 && degree < 225) {
return 4; //右方
} else if ((degree < 45 && degree > 0) || degree < 360 && degree > 315) {
return 3; //左方
}
return 1;
}
}