github地址:https://github.com/smileyqp/Apollo_frontEnd-
前臺消息接收方式為:監(jiān)聽端口49923,在webworker接收消息message,并判斷消息的source,消息的source分為三>種map,map_cloud以及realtime,此時給消息type,即realtime為SimWorldUpdate,map為MapData,point_cloud為
接收數(shù)據(jù)message:
---------------------------------realtime接收數(shù)據(jù)部分---------------------------------------------
1.HMIConfig
--------接收的為導(dǎo)航欄部分數(shù)據(jù)------------
dockerImage:字符串文本格式,顯示為彈出框版本信息.EX:apolloauto/apollo:dev-x86_64-20180906_2002
modes:模式setup mode的String數(shù)組,是mode的下拉列表菜單
傳輸過去:{type:ChangeMode,mode:value值}
utmZoneId:數(shù)據(jù),其中初始值為10(?I can not find it's function?where?what?)
availableVehicles:string數(shù)組,將其sort().map(name)排序后就是頁面上vehicles的下拉列表
傳輸過去:{type:ChangeVehicle,new_vehicle: vehcile選項的value值}
availableMaps:string數(shù)組,將其sort().map(name)排序后就是頁面上的map的下拉列表
傳輸過去:{type:ChangeMap,new_map: map選項的value值}
---------接收的為左側(cè)為module controller的模塊數(shù)據(jù)-----------------
modules:接收的為對象數(shù)據(jù)結(jié)構(gòu)為 {key1:value1, key2:value2, ...} ,鍵值對結(jié)構(gòu).接收過來的是鍵值對形>式的對象,之后將其傳入到映射中取值
傳輸過去:這邊
{type: "ExecuteModuleCommand",
module: module,//即其中對應(yīng)的相應(yīng)模塊名稱即key
command: command,}//command即其對應(yīng)的狀態(tài)
//備注WS.executeModuleCommand(id, command)======>>>key值,key的value值是一個狀態(tài),即在其中對應(yīng)的某謳
歌時間對應(yīng)的狀態(tài)
//executeModuleCommand(module, command)
hardware:該模塊與上面模塊接收相同都是鍵值對,但是該模塊沒有發(fā)送值只有接收其status在update狀態(tài)的時候
改變其值
2.HMIStatus
主要是上一步的初始化之后的狀態(tài)更新(涉及function有updateStatus()和updateGroundImage())
currentMode:string類型字符串,推測為初始化之后服務(wù)器端穿過來的一系列mode即模式之后前段選擇那種模式>給后端傳過去,再之后后端講這種模式返回來傳給前端即在更新狀態(tài)時候顯示
currentMap:string類型字符串,同上
currentVehicle:同上string類型,以及采取的方式同上
systemStatus:在這個systemstatus中,傳過來的也是一個鍵值對對象,該鍵值對對象中有兩個參數(shù)傳過來的兩個key以及其數(shù)據(jù)格式如下:
modules:modules也是一個鍵值對的格式,將這個鍵值對的值存到moduleStatus,moduleStatus中的key為
其中取出來的key,但是其值就modules[key].processStatus.running;moduleStatus是一個鍵值對結(jié)構(gòu),之前提到
過,存儲了key為Modules這邊的值,然后他的value則是狀態(tài)值
hardware:鍵值對格式,同上實時更新值
passengerMsg:這是一個string類型的消息
3.VehicleParam
json格式數(shù)據(jù)類似于 vehicleParam = {
frontEdgeToCenter: 3.89,
backEdgeToCenter: 1.04,
leftEdgeToCenter: 1.055,
rightEdgeToCenter: 1.055,
height: 1.48,
width: 2.11,
length: 4.933,
steerRatio: 16,
}
這個中是直接傳過來一個鍵值對數(shù)值,將這個鍵值對的值直接傳給vehicleParam參數(shù),之后在store的update(world){}這個function中調(diào)用
4.SimControlStatus
穿過來的值只是觸發(fā)button的enabled
STORE.setOptionStatus('simControlEnabled', message.enabled);
5.SimWorldUpdate
timestamp
world.sequenceNum
autoDrivingCar鍵值對結(jié)構(gòu):
positionX,positionY,heading
navigationPath鍵值對map
laneMarker
planningTrajectory
6.MapElementIds
mapHash,mapElementIds,mapRadius
7.DefaultEndPoint
poi數(shù)組,數(shù)組里面包含map,map包含name和waypoint格式如下:
// Map from POI name to its x,y coordinates,
// e.g. {POI-1: [{x: 1.0, y: 1.2}, {x: 101.0, y: 10.2}]}
8.RoutePath
routingTime,routePath
監(jiān)聽三種傳過來的數(shù)據(jù)source,三種source分別為realtime,map,point_cloud:
reaktime的message type為SimWorldUpdate
map的message type為MapData
point_cloud的message type為?此處沒有寫明
-----------------------------point cloud點云接收數(shù)據(jù)的部分-------------------------------------
type:PointCloudStatus:傳進去的而數(shù)據(jù)為數(shù)組點集合
-------------------------------websocket map數(shù)據(jù)接收部分-----------------------------
傳過來一串map相關(guān)數(shù)據(jù)的數(shù)組
-------------------------offline數(shù)據(jù)接收部分;這個是離線部分咩------------------------------------
GroundMetadata傳過來的數(shù)據(jù)中包含這些,在render的tileground中,初始化使用這些數(shù)據(jù)
this.metadata = {
tileLength: metadata.tile * metadata.mpp,
left: metadata.left,
top: metadata.top,
numCols: metadata.wnum,
numRows: metadata.hnum,
mpp: metadata.mpp,
tile: metadata.tile,
imageUrl: metadata.image_url,
};
FrameCount:傳過來的數(shù)據(jù)為一串string,但是這個string是只含有數(shù)字的,之后會用parseInt將其解析出來使用
RoutePath:
傳過來的數(shù)據(jù)為一個對象有兩個屬性routingTime和rouotePath,分別有值,鍵值對形式
SimWorldUpdate:
傳過來的數(shù)據(jù)用于message的check,含有數(shù)據(jù)為timestamp和world(其中world中還有sequenceNum)
數(shù)據(jù)發(fā)送部分
------------------------------map------------------------------------------
type:RetrieveMapData
傳過去的element是一個對象,對象中每個屬性即key的值即value又是一個數(shù)組
type:RetrieveRelativeMapData
--------------------------------point_cloud----------------------------------
type:TogglePointCloud
傳過去的值enable的值為布爾值
-------------------------------realtime----------------------------------------------
function:clearInterval
type:RequestSimulationWorld
planning : requestPlanningData,
function:requestRoute
type: "SendRoutingRequest",
start: start,
end: end,
waypoint: waypoint,
function:requestDefaultRoutingEndPoint
type:GetDefaultEndPoint,沒有傳其他數(shù)據(jù)
function:resetBackend
type: "Reset",沒有其他數(shù)據(jù)
function:dumpMessages
type:Dump
function:changeSetupMode
type: "ChangeMode",
new_mode: mode,
function:changeMap
type: "ChangeMap",
new_map: map,
function:changeVeicle
type: "ChangeVehicle",
new_vehicle: vehcile,
function:executeModeCommand
type: "ExecuteModeCommand",
command: command,
function:executeModuleCommand
type: "ExecuteModuleCommand",
module: module,
command: command,
function:executeToolCommand
type: "ExecuteToolCommand",
tool: tool,
command: command,
function:changeDrivingMode
type: "ChangeDrivingMode",
new_mode: mode,
function:submitDriveEvent
type: "SubmitDriveEvent",
event_time_ms: eventTimeMs,
event_msg: eventMessage,
event_type: eventTypes,
function:sendAudioPiece
type: "AudioPiece",
data: btoa(String.fromCharCode(...data)),
function:toggleSimControl
type: "ToggleSimControl",
enable: enable,
function:requestRoutePath
type: "RequestRoutePath",
function:publishNavigationInfo
this.websocket.send(data);這個function中沒有type是直接send data過去的
--------------------------------offline傳過去的數(shù)值---------------------------------------
type: "requestRoutePath"
recordId: recordId,
frameId: frameId,
最近在看百度無人駕駛Apollo的dreamview模塊的frontend模塊,開始時候考慮找一下數(shù)據(jù)傳輸模塊相關(guān)資料源碼分析的沒有找到,想自己就稍微邊看邊簡單記載了一下
github:https://github.com/smileyqp/Apollo_frontEnd-/blob/master/apollo_frontend.txt