Radar: tweaks

This commit is contained in:
Sidi Liang 2020-08-10 19:49:49 +08:00
parent 865a4bc730
commit 3aa32b3ee3
No known key found for this signature in database
GPG Key ID: 79F0A6B20B72F42F
2 changed files with 6 additions and 4 deletions

View File

@ -5,6 +5,7 @@ var Radar = {
#//Class for any Parking Radar (currently only support terrain detection) which scans in a sector
#//height: height of installation above ground;installCoordX: X coord of installation; installCoordY: Y coord of installation; maxRange: max radar range; maxWidth: width of the sector
#//orientationMode 0:towards back, 180:towards front, 90: towards left, 270:towards right, custom values are accepted(in degrees)
#//updateInterval: update interval of the radar timer, defaults to 0.25
#//Note that 0 degrees is the backward(180 degrees heading of the vehicle), which is a little weird because I forgot about it when designing the system
#//and the support of other install orientations are added afterwards
#//For a typical parking radar, set orientationMode=0(or leave it as default)
@ -13,7 +14,8 @@ var Radar = {
#//For follow me EV: height 0.3m; installCoordX:0m; installCoordY:3.8m; maxRange:3m;maxWidth:3m
#//To start scanning: myRadar.init();
#//To Stop: myRadar.stop();
new: func(height, installCoordX, installCoordY, maxRange, maxWidth, orientationMode=0, warnEnabled=1, debug=0) {
new: func(height, installCoordX, installCoordY, maxRange, maxWidth, orientationMode=0, warnEnabled=1,
updateInterval=0.25, debug=0) {
return { parents:[Radar, Appliance.new()], height: height, installCoordX:installCoordX, installCoordY:installCoordY, maxRange:maxRange, maxWidth:maxWidth, orientationMode:orientationMode, warnEnabled:warnEnabled, debug:debug, radarOutput:10000};
},
@ -201,5 +203,3 @@ var Radar = {
else me.radarOutput = 10000;
},
};
var parkingRadar = Radar.new(0.3, 0, 3.8, 3, 3);

View File

@ -496,12 +496,14 @@ var brakesABS = func(){
}
}
var parkingRadar = Radar.new(0.3, 0, 3.8, 3, 3);
var Safety = {
new: func(airbagAccelerationLimit=140, sideAirbagAccelerationLimit=75){
var newSafety = { parents:[Safety] };
newSafety.airbagAccelerationLimit = airbagAccelerationLimit;
newSafety.sideAirbagAccelerationLimit = sideAirbagAccelerationLimit;
newSafety.frontRadar = Radar.new(0.3, 0, 0, 9, 0.1, 180, 0, 0);#For AEB
newSafety.frontRadar = Radar.new(0.3, 0, 0, 9, 0.1, 180, 0, 0.1);#For AEB
newSafety.absTimer = maketimer(0.001, brakesABS);
return newSafety;
},