提交 c02efbdd 编写于 作者: U unacao 提交者: Jiangtao Hu

allow loading of reflection background image

上级 a9d78cee
......@@ -718,107 +718,6 @@
}
}
},
"gnss_status": {
"nested": {
"StreamStatus": {
"fields": {
"header": {
"type": "apollo.common.Header",
"id": 1
},
"insStreamType": {
"type": "Type",
"id": 2,
"options": {
"default": "DISCONNECTED"
}
},
"rtkStreamInType": {
"type": "Type",
"id": 3,
"options": {
"default": "DISCONNECTED"
}
},
"rtkStreamOutType": {
"type": "Type",
"id": 4,
"options": {
"default": "DISCONNECTED"
}
}
},
"nested": {
"Type": {
"values": {
"DISCONNECTED": 0,
"CONNECTED": 1
}
}
}
},
"InsStatus": {
"fields": {
"header": {
"type": "apollo.common.Header",
"id": 1
},
"type": {
"type": "Type",
"id": 2,
"options": {
"default": "INVALID"
}
}
},
"nested": {
"Type": {
"values": {
"INVALID": 0,
"CONVERGING": 1,
"GOOD": 2
}
}
}
},
"GnssStatus": {
"fields": {
"header": {
"type": "apollo.common.Header",
"id": 1
},
"solutionCompleted": {
"type": "bool",
"id": 2,
"options": {
"default": false
}
},
"solutionStatus": {
"type": "uint32",
"id": 3,
"options": {
"default": 0
}
},
"positionType": {
"type": "uint32",
"id": 4,
"options": {
"default": 0
}
},
"numSats": {
"type": "int32",
"id": 5,
"options": {
"default": 0
}
}
}
}
}
},
"Header": {
"fields": {
"timestampSec": {
......
......@@ -14,6 +14,7 @@ export default class Coordinates {
x: x,
y: y
};
console.log("Offset is set to x:" + x + ", y:" + y);
}
applyOffset(point, reverse = false) {
......
......@@ -23,20 +23,62 @@ export default class Ground {
return false;
}
const { xres, yres, mpp } = PARAMETERS.ground;
if (!this.render(coordinates)) {
return false;
}
this.initialized = true;
return true;
}
this.mesh.scale.set(xres * mpp / 1000, yres * mpp / 1000, 1);
update(world, coordinates, scene) {
}
updateImage(coordinates, mapName) {
if (!this.mesh) {
return;
}
const dir = this.titleCaseToSnakeCase(mapName);
const server = 'http://' + window.location.hostname + ':8888';
const imgUrl = server + '/assets/map_data/' + dir + '/background.jpg';
loadTexture(imgUrl, texture => {
console.log("updating ground image with " + dir);
this.mesh.material.map = texture;
this.render(coordinates, dir);
}, err => {
console.log("using grid as ground image...");
loadTexture(gridGround, texture => {
this.mesh.material.map = texture;
this.render(coordinates);
});
});
}
render(coordinates, mapName = 'defaults') {
console.log("rendering ground image...");
const { xres, yres, mpp, xorigin, yorigin } = PARAMETERS.ground[mapName];
let position = coordinates.applyOffset({x: xorigin, y: yorigin});
if (position === null) {
console.warn("Cannot find position for ground mesh!");
return false;
}
// NOTE: Setting the position to (0, 0) makes the center of
// the ground image to overlap with the offset point, which
// in this case is the car position on the first received frame.
this.mesh.position.set(0, 0, 0);
// is the car position on the first received frame.
if (mapName === 'defaults') {
position = {x: 0, y: 0};
}
this.mesh.position.set(position.x, position.y, 0);
this.mesh.scale.set(xres * mpp, yres * mpp, 1);
this.mesh.material.needsUpdate = true;
this.mesh.overdraw = false;
this.initialized = true;
return true;
}
update(world, coordinates, scene) {
// Do nothing in the default ground
titleCaseToSnakeCase(str) {
return str.replace(/\s/g, '_').toLowerCase();
}
}
......@@ -336,6 +336,10 @@ class Renderer {
}
}
updateGroundImage(mapName) {
this.ground.updateImage(this.coordinates, mapName);
}
updateGroundMetadata(serverUrl, mapInfo) {
this.ground.initialize(serverUrl, mapInfo);
}
......
......@@ -19,14 +19,22 @@ camera:
laneWidth: 4.5 # original 3.32
laneWidthToViewDistanceRatio: 5
ground:
mpp: 400
xres: 8192
yres: 8192
xorigin: 4096
yorigin: 4096
xyoffset: 0
type: default # default or tile
tileRange: 4
defaults:
mpp: 0.125
xres: 8192
yres: 8192
xorigin: 4096
yorigin: 4096
type: default # default or tile
tileRange: 4
sunnyvale_big_loop:
mpp: 0.125
xres: 24576
yres: 16384
xorigin: 587392
yorigin: 4140800
type: default # default or tile
tileRange: 4
planning:
# The minimum interval between two consecutive
minInterval: 0.1
......
......@@ -14,6 +14,7 @@ export default class RosWebSocketEndpoint {
this.lastSeqNum = -1;
this.currMapRadius = null;
this.updatePOI = true;
this.updateGround = true;
}
initialize() {
......@@ -45,6 +46,10 @@ export default class RosWebSocketEndpoint {
break;
case "HMIStatus":
STORE.hmi.updateStatus(message.data);
if (this.updateGround) {
RENDERER.updateGroundImage(STORE.hmi.currentMap);
this.updateGround = false;
}
break;
case "SimWorldUpdate":
this.checkMessage(message);
......@@ -178,6 +183,7 @@ export default class RosWebSocketEndpoint {
new_map: map,
}));
this.updatePOI = true;
this.updateGround = true;
}
changeVehicle(vehcile) {
......
......@@ -48,6 +48,6 @@ export function loadObject(materialFile, objectFile, scale, callback) {
}
}
export function loadTexture(textureFile, callback) {
textureLoader.load(textureFile, callback);
export function loadTexture(textureFile, onLoadCallback, onErrorCallback) {
textureLoader.load(textureFile, onLoadCallback, undefined, onErrorCallback);
}
......@@ -26,6 +26,8 @@ source "${DIR}/apollo_base.sh"
# Dreamview depends on monitor module to get system runtime status.
bash scripts/monitor.sh "$@"
rm -rf modules/dreamview/frontend/dist/assets/map_data
ln -s /apollo/modules/map/data/ modules/dreamview/frontend/dist/assets/map_data
# run function from apollo_base.sh
# run command_name module_name
run dreamview "$@"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册