[add]添加新接口 工控机发送感知红绿灯
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
compileSdkVersion 31
|
||||
defaultConfig {
|
||||
applicationId "com.zhidao.adas.client"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 22
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 31
|
||||
multiDexEnabled true
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.zhidao.adas.client.bean;
|
||||
|
||||
import com.google.protobuf.TextFormat;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import perception.TrafficLightOuterClass;
|
||||
|
||||
public class PerceptionTrafficLight extends Base {
|
||||
public final TrafficLightOuterClass.TrafficLights bean;
|
||||
|
||||
public PerceptionTrafficLight(MessagePad.Header header, TrafficLightOuterClass.TrafficLights bean) {
|
||||
super(bean.getSerializedSize(), header);
|
||||
this.bean = bean;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + TextFormat.printer().escapingNonAscii(false).printToString(bean);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.zhidao.adas.client.bean.ErrorData;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
@@ -271,7 +272,14 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onPerceptionTrafficLightEvent(PerceptionTrafficLight info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT)) {
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.zhidao.adas.client.bean.ErrorData;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
@@ -86,6 +87,7 @@ import chassis.VehicleStateOuterClass;
|
||||
import io.netty.channel.Channel;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
import perception.TrafficLightOuterClass;
|
||||
import record_cache.RecordPanelOuterClass;
|
||||
|
||||
public class MainActivity extends BaseActivity implements OnAdasListener, OnAdasConnectStatusListener, BaseAdapter.OnItemClickListener<String> {
|
||||
@@ -127,6 +129,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
private InfoFragment badcseFragment;
|
||||
private InfoFragment errorFragment;
|
||||
private InfoFragment reportMessageFragment;
|
||||
private InfoFragment perceptionTrafficLightFragment;
|
||||
private VersionFragment versionFragment;
|
||||
private FragmentManager manager;
|
||||
private FragmentTransaction transaction;
|
||||
@@ -144,6 +147,8 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
String RECEIVE_VEHICLE_STATE = "底盘信息";
|
||||
String RECEIVE_AUTOPILOT_STATE = "自动驾驶状态";
|
||||
String RECEIVE_REPORT_MESSAGE = "监控事件";
|
||||
String RECEIVE_PERCEPTION_TRAFFIC_LIGHT = "感知红绿灯";
|
||||
|
||||
// String RECEIVE_BASIC_INFO_REQ = "自动驾驶设备基础信息请求";
|
||||
String RECEIVE_CAR_CONFIG_RESP = "信息与配置";
|
||||
String RECEIVE_RECORD_RESULT = "数据采集结果";
|
||||
@@ -332,6 +337,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
titleFragmentData.add(TITLE.RECEIVE_VEHICLE_STATE);
|
||||
titleFragmentData.add(TITLE.RECEIVE_AUTOPILOT_STATE);
|
||||
titleFragmentData.add(TITLE.RECEIVE_REPORT_MESSAGE);
|
||||
titleFragmentData.add(TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT);
|
||||
titleFragmentData.add(TITLE.RECEIVE_CAR_CONFIG_RESP);
|
||||
titleFragmentData.add(TITLE.RECEIVE_RECORD_RESULT);
|
||||
titleFragmentData.add(TITLE.RECEIVE_GLOBAL_PATH_RESP);
|
||||
@@ -481,6 +487,14 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT:
|
||||
if (perceptionTrafficLightFragment == null)
|
||||
perceptionTrafficLightFragment = new InfoFragment(data);
|
||||
if (!perceptionTrafficLightFragment.isVisible()) {
|
||||
transaction.replace(R.id.fl_info, perceptionTrafficLightFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_CAR_CONFIG_RESP:
|
||||
AdasManager.getInstance().sendCarConfigReq();
|
||||
if (versionFragment == null)
|
||||
@@ -618,6 +632,11 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
EventBus.getDefault().postSticky(new MogoReportMessage(header, mogoReportMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPerceptionTrafficLight(MessagePad.Header header, TrafficLightOuterClass.TrafficLights trafficLights) {
|
||||
EventBus.getDefault().postSticky(new PerceptionTrafficLight(header, trafficLights));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq) {
|
||||
BasicInfoReq info = new BasicInfoReq(header, basicInfoReq);
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo_msg.MogoReportMsg
|
||||
import perception.TrafficLightOuterClass
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.util.*
|
||||
|
||||
@@ -209,6 +210,13 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
invokeAutopilotGuardian(mogoReportMessage)
|
||||
}
|
||||
}
|
||||
//感知红绿灯
|
||||
override fun onPerceptionTrafficLight(
|
||||
header: MessagePad.Header?,
|
||||
trafficLights: TrafficLightOuterClass.TrafficLights?
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onBasicInfoReq(
|
||||
header: MessagePad.Header,
|
||||
|
||||
15
libraries/mogo-adas-data/README.md
Normal file
15
libraries/mogo-adas-data/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# 工控机PB文件 用于生成Java Bean
|
||||
|
||||
## 1. studio中*.proto文件中如果出现“Cannot resolve symbol 'xxxx'”提示
|
||||
**不影响正常编译,只影响美观以及无法在proto文件中跳转**
|
||||
~~~
|
||||
1. setting> Languages & Frameworks>Protocol Buffers 取消选中Configure automatically
|
||||
2. 点击加号选择proto文件所在路径(例如:\MoGoEagleEye\libraries\mogo-adas-data\src\main\proto) 点击OK
|
||||
~~~
|
||||
|
||||
## 2. 遇到例如 MessagePad.Header 提示找不到的情况
|
||||
**不影响正常编译,只影响美观以及无法点击跳转**
|
||||
~~~
|
||||
1. 选中mogo-adas-data
|
||||
2. 点击Build> Make Moudle 'MoGoEagleEye.libraries.mogo-adas-data'
|
||||
~~~
|
||||
@@ -16,6 +16,7 @@ enum MessageType
|
||||
MsgTypeVehicleState = 0x10003; //底盘信息, 透传底盘状态,pb参考底盘
|
||||
MsgTypeAutopilotState = 0x10004; //自动驾驶状态
|
||||
MsgTypeReportMessage = 0x10005; //监控事件报告
|
||||
MsgTypePerceptionTrafficLight = 0x10006; //感知红绿灯
|
||||
|
||||
MsgTypeBasicInfoReq = 0x10100; //自动驾驶设备基础信息请求
|
||||
MsgTypeBasicInfoResp = 0x10101; //自动驾驶设备基础信息应答
|
||||
@@ -120,6 +121,9 @@ message AutopilotState
|
||||
// message definition for MessageType: MsgTypeReportMessage
|
||||
// refer to mogo_report_msg.proto
|
||||
|
||||
// message definition for MessageType: MsgTypePerceptionTrafficLight
|
||||
// refer to traffic_light.proto
|
||||
|
||||
// message definition for MessageType: MsgTypeBasicInfoReq
|
||||
message BasicInfoReq
|
||||
{
|
||||
|
||||
36
libraries/mogo-adas-data/src/main/proto/traffic_light.proto
Normal file
36
libraries/mogo-adas-data/src/main/proto/traffic_light.proto
Normal file
@@ -0,0 +1,36 @@
|
||||
syntax = "proto2";
|
||||
package perception;
|
||||
|
||||
import "header.proto";
|
||||
|
||||
enum LightType {
|
||||
TYPE_DEFAULT = 0;
|
||||
TYPE_VEHICLE = 1;
|
||||
TYPE_BICYLE = 2;
|
||||
TYPE_PEDSTRIAN = 3;
|
||||
TYPE_LANE = 5;
|
||||
}
|
||||
|
||||
enum LightState {
|
||||
STATE_OFF = 0;
|
||||
STATE_RED = 1;
|
||||
STATE_YELLOW = 2;
|
||||
STATE_GREEN = 3;
|
||||
STATE_FLASH = 4;
|
||||
}
|
||||
|
||||
message TrafficLight {
|
||||
optional int64 id = 1;
|
||||
optional LightType type = 2 [default = TYPE_DEFAULT];
|
||||
optional LightState state = 3 [default = STATE_OFF];
|
||||
optional float duration = 4; // seconds since the last state changed
|
||||
}
|
||||
|
||||
message TrafficLights {
|
||||
optional common.Header header = 1;
|
||||
|
||||
optional TrafficLight straight = 2;
|
||||
optional TrafficLight left = 3;
|
||||
optional TrafficLight right = 4;
|
||||
optional TrafficLight u_turn = 5;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import chassis.VehicleStateOuterClass;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
import perception.TrafficLightOuterClass;
|
||||
import record_cache.RecordPanelOuterClass;
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,14 @@ public interface OnAdasListener {
|
||||
*/
|
||||
void onReportMessage(MessagePad.Header header, MogoReportMsg.MogoReportMessage mogoReportMessage);
|
||||
|
||||
/**
|
||||
* 感知红绿灯
|
||||
*
|
||||
* @param header 头
|
||||
* @param trafficLights 感知红绿灯
|
||||
*/
|
||||
void onPerceptionTrafficLight(MessagePad.Header header, TrafficLightOuterClass.TrafficLights trafficLights);
|
||||
|
||||
/**
|
||||
* 自动驾驶设备基础信息请求
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ public enum MessageType {
|
||||
TYPE_RECEIVE_VEHICLE_STATE(MessagePad.MessageType.MsgTypeVehicleState, "底盘信息, 透传底盘状态,pb参考底盘"),
|
||||
TYPE_RECEIVE_AUTOPILOT_STATE(MessagePad.MessageType.MsgTypeAutopilotState, "自动驾驶状态"),
|
||||
TYPE_RECEIVE_REPORT_MESSAGE(MessagePad.MessageType.MsgTypeReportMessage, "监控事件报告"),
|
||||
TYPE_RECEIVE_PERCEPTION_TRAFFIC_LIGHT(MessagePad.MessageType.MsgTypePerceptionTrafficLight, "感知红绿灯"),
|
||||
|
||||
TYPE_RECEIVE_BASIC_INFO_REQ(MessagePad.MessageType.MsgTypeBasicInfoReq, "自动驾驶设备基础信息请求"),
|
||||
TYPE_SEND_BASIC_INFO_RESP(MessagePad.MessageType.MsgTypeBasicInfoResp, "自动驾驶设备基础信息应答"),
|
||||
|
||||
@@ -17,6 +17,7 @@ public class MyMessageFactory implements IMyMessageFactory {
|
||||
private IMsg vehicleStateMessage;//底盘信息, 透传底盘状态,pb参考底盘
|
||||
private IMsg autopilotStateMessage;//自动驾驶状态
|
||||
private IMsg reportMessage;//监控事件报告
|
||||
private IMsg perceptionTrafficLightMessage;//感知红绿灯
|
||||
|
||||
private IMsg basicInfoReqMessage;//自动驾驶设备基础信息请求
|
||||
private IMsg carConfigRespMessage;//车机基础信息应答
|
||||
@@ -84,6 +85,12 @@ public class MyMessageFactory implements IMyMessageFactory {
|
||||
reportMessage = new ReportMessage();
|
||||
}
|
||||
return reportMessage;
|
||||
} else if (messageType == MessageType.TYPE_RECEIVE_PERCEPTION_TRAFFIC_LIGHT.typeCode) {
|
||||
//感知红绿灯
|
||||
if (perceptionTrafficLightMessage == null) {
|
||||
perceptionTrafficLightMessage = new PerceptionTrafficLightMessage();
|
||||
}
|
||||
return perceptionTrafficLightMessage;
|
||||
} else if (messageType == MessageType.TYPE_RECEIVE_BASIC_INFO_REQ.typeCode) {
|
||||
//自动驾驶设备基础信息请求
|
||||
if (basicInfoReqMessage == null) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import perception.TrafficLightOuterClass;
|
||||
|
||||
/**
|
||||
* 感知红绿灯
|
||||
*/
|
||||
public class PerceptionTrafficLightMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException {
|
||||
TrafficLightOuterClass.TrafficLights trafficLights = TrafficLightOuterClass.TrafficLights.parseFrom(msg);
|
||||
if (adasListener != null) {
|
||||
adasListener.onPerceptionTrafficLight(header, trafficLights);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user