Commit 90bd9710 authored by Ebru Cam's avatar Ebru Cam

Update Mapbox and Threebox Version, bug fix

parent 9d2441ab
This diff is collapsed.
This diff is collapsed.
'use strict';
function CarObject() {
this.modelScale = 1;
this.type = null;
this.id = null;
this.modelName = null;
this.model = null;
this.speed = 0;
this.acceleration = 0;
this.position = (0,0,0);
this.rotation = (0,0,0);
// this.wheelOrientation = 0;
// this.carOrientation = 0;
this.MAX_SPEED = 2200;
this.MAX_REVERSE_SPEED = -1500;
this.MAX_WHEEL_ROTATION = 0.6;
this.FRONT_ACCELERATION = 1250;
this.BACK_ACCELERATION = 1500;
this.WHEEL_ANGULAR_ACCELERATION = 1.5;
this.FRONT_DECCELERATION = 750;
this.WHEEL_ANGULAR_DECCELERATION = 1.0;
this.STEERING_RADIUS_RATIO = 0.0023;
this.MAX_TILT_SIDES = 0.05;
this.MAX_TILT_FRONTBACK = 0.015;
}
......@@ -6,24 +6,21 @@ function setCars() {
"porsche": {
name: "Porsche",
file: "porsche.glb",
scale: 5
scale: 0.20
},
"lfa": {
name: "LFA",
file: "lfa.glb",
scale: 1
}
};
return {
build: function (id, carType, carPosition, carSteering){
var carConfig = DEF_CARS[carType];
var car = Object.assign(carConfig);
var car = Object.assign(new CarObject(), carConfig);
car.modelScale = carConfig.scale;
car.type = carType;
car.modelName = carConfig.name;
......@@ -33,22 +30,23 @@ function setCars() {
car.dataBuffer = null;
car.targetStatus = {};
car.speed = 0;
car.acceleration = 0;
car.acceleration = 0;
/*
// configure the car
if (carType == 'porsche') {
this.configPorsche(car);
}else if (carType == 'lfa') {
this.configLfa(car);
}
*/
return car;
},
/*
* Configuration of porsche - TODO werte anpassen
*/
/*
//Configuration of porsche - TODO Werte anpassen
configPorsche: function (porsche) {
porsche.MAX_SPEED = 400;
porsche.MAX_REVERSE_SPEED = -600;
......@@ -67,9 +65,9 @@ function setCars() {
},
/*
* Configuration of lfa - TODO werte anpassen
*/
//Configuration of lfa
configLfa: function (lfa) {
lfa.backWheelOffset = 6.5;
......@@ -88,5 +86,6 @@ function setCars() {
lfa.STEERING_RADIUS_RATIO = 0.0083;
}
*/
};
}
var infoBox = {
showInfoBox: function (clickedCarId) {
document.getElementById("myInfoBox").style.width = "250px";
if (!infoBoxCreated) {
infoBox.createInfoBox();
var gau = infoBox.createGauge();
}
gau.draw();
infoBox.updateInfoBox(clickedCarId);
......@@ -82,7 +84,7 @@ var infoBox = {
var infoElements = {
"0": {
attributeId: "attributeIden",
attributeId: "attributeIden",
pElement: "attributeIden",
text: "ID: ",
content: " ",
......@@ -96,14 +98,14 @@ var infoBox = {
unit: "" ,
},
"2": {
attributeId: "attributeVelocity",
attributeId: "attributeVelocity",
pElement: "attributeVelocity",
text: "Velocity: ",
content: "0",
unit: "Km/h",
},
"3": {
attributeId: "attributePosition",
attributeId: "attributePosition",
pElement: "attributePosition",
text: "Position (Lat, Lon): ",
content: " ",
......@@ -119,7 +121,6 @@ var infoBox = {
updateInfoBox: function (clickedCarId) {
var newCarInfo = infoBox.getCarInfo(clickedCarId);
//console.log(clickedCarId);
let model = newCarInfo.carModel;
let velo = newCarInfo.velocity;
let pos = newCarInfo.position[0] +"<br />"+ newCarInfo.position[1] ;
......@@ -135,7 +136,6 @@ var infoBox = {
var updateElement = infoBox.setInfoBoxElements();
for(var m=0; m < updateData.length ;m++) {
var attributeId = updateElement[m].attributeId;
var attributeText = updateElement[m].text;
updateElement[m].content = updateData[m];
......
......@@ -7,40 +7,10 @@ function MapboxEnvironment(mapCenter){
style: 'mapbox://styles/ebruca/cjz8v0zmc40nw1co2qjiqmh85',
zoom: 18,
center: mapCenter,
pitch: 60,
bearing:0
pitch: 0,
bearing:0,
antialias: true
});
/*map.on('load', function() {
map.addLayer({
'id': '3d-buildings',
'source': 'composite',
'source-layer': 'building',
'filter': ['==', 'extrude', 'true'],
'type': 'fill-extrusion',
'minzoom': 15,
'paint': {
'fill-extrusion-color': '#aaa',
// use an 'interpolate' expression to add a smooth transition effect to the
// buildings as the user zooms in
'fill-extrusion-height': [
"interpolate", ["linear"], ["zoom"],
15, 0,
15.05, ["get", "height"]
],
'fill-extrusion-base': [
"interpolate", ["linear"], ["zoom"],
15, 0,
15.05, ["get", "min_height"]
],
'fill-extrusion-opacity': 1
}
});
});*/
return map;
}
\ No newline at end of file
......@@ -178,8 +178,10 @@ function CarController(mapbox) {
* received from server.
*/
self.correctCarAttitude = function (carID, mapbox) {
if (CARS[carID].targetStatus.destination == undefined) return;
if(mapbox){
if (CARS[carID].targetStatus.destination == undefined) return;
CARS[carID].speed = CARS[carID].targetStatus.velocityAtDestination;
CARS[carID].acceleration = CARS[carID].targetStatus.accAtDestination;
CARS[carID].model.rotation.set(Math.PI/2, CARS[carID].targetStatus.rotationAroundYAxis,0);
......@@ -188,6 +190,7 @@ function CarController(mapbox) {
CARS[carID].position[1] = CARS[carID].targetStatus.destination[1];
}
else {
if (CARS[carID].targetStatus.destination == undefined) return;
var car = CARS[carID];
car.model.speed = car.targetStatus.velocityAtDestination;
......
......@@ -58,8 +58,7 @@ var Server = {
if (this.status == 200 && JSON.parse(this.responseText).result == true) {
console.log("simulation finished");
onSimulationFinished(id);
self.fetchAllFrames(id);
//self.fetchAllFrames(2);
self.fetchAllFrames(id);
self.simulationDoneCallback(1000);
} else {
console.log("simulation not finished");
......@@ -89,6 +88,7 @@ var Server = {
allFrames.push(frame);
}
}
console.log(allFrames);
allFrames.sort(function (a, b) {
return a.totalTime < b.totalTime ? -1 : (a.totalTime > b.totalTime ? 1 : 0)
});
......@@ -117,6 +117,8 @@ var Server = {
}
return 0;
})
console.log(self.simulationDataframes);
}
req.open('get', this.baseUrl + '/simulation/' + simulationID + '/result');
req.send();
......@@ -184,13 +186,13 @@ var Server = {
console.log("no more dataframes left");
return;
}
console.log(this.nextFrameIdx);
console.log(this.simulationDataframes.length);
//console.log(this.nextFrameIdx);
//console.log(this.simulationDataframes.length);
var isInit = this.nextFrameIdx == 0 ? true : false;
var cars = this.simulationDataframes[this.nextFrameIdx++];
console.log(this.simulationDataframes);
console.log(cars);
//console.log(this.simulationDataframes);
//console.log(cars);
var carObjs = [];
for (var i = 0; i < cars.length; i++) {
var car = {};
......@@ -201,7 +203,7 @@ var Server = {
car.steeringAngle = car.steering;
carObjs.push(car);
}
console.log(cars);
//console.log(cars);
/*switch (true) {
case car.errorFlags[0]: handleErrorinProgressbar(this.nextFrameIdx,0,self.errorFlagID,car.id);
self.errorFlagID++;
......
......@@ -129,14 +129,22 @@ var lib = {
});
},
animate: function () {
//TODO
if (DataModel.simulationTimeDeltaMs > 0) {
setTimeout(function() {requestAnimationFrame(lib.animate);}, DataModel.simulationTimeDeltaMs);
} else {
requestAnimationFrame( lib.animate );
}
},
onSimulationFinished: function (simulationId) {
//start animation after the environment is ready is processed
//attach DataModel to WebSocket connection
WebService.WS_attachListener(DataModel.onData);
for (var i = 0; i < NUM_MAP_SECTOR; i++) {
DataModel.onDataProcessed = animate;
DataModel.onDataProcessed = lib.animate;
WebService.WS_loadMapSector(simulationId, i, lib.onMapLoaded)
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment