修改机器人驾驶的停车制动操作
This commit is contained in:
parent
d77e70c126
commit
b8768e6052
|
@ -602,101 +602,8 @@ public class SimulationRobotService {
|
|||
.forEach(station -> atsStationService.doOperationModeSwitch(station));
|
||||
}
|
||||
|
||||
private void doControlBySpeedCurve(Simulation simulation, VirtualRealityTrain train,
|
||||
SpeedCurve speedCurve, float remainDistance) {
|
||||
if (speedCurve.equals(SpeedCurve.ZERO)) {
|
||||
this.doBreakMax(simulation, train);
|
||||
return;
|
||||
}
|
||||
SpeedCurve.SpeedCalculator calculator = speedCurve.getCalculatorOf(remainDistance);
|
||||
if (calculator.getVt() == 0
|
||||
&& remainDistance <= SimulationConstants.PARK_POINT_MAX_OFFSET) { //末速度为0且当前距终点距离在停车误差内
|
||||
this.doBreakMax(simulation, train);
|
||||
return;
|
||||
}
|
||||
float speed = train.getSpeed();
|
||||
if (speed == 0) {
|
||||
this.doStart(simulation, train);
|
||||
return;
|
||||
}
|
||||
float atoSpeed = train.getAtoSpeed();
|
||||
float acceleration = calculator.getAcceleration();
|
||||
float diff = speed - atoSpeed;
|
||||
if (acceleration == 0) { //匀速段
|
||||
if (diff <= -0.1) { //当前速度远小于目标速度
|
||||
this.doAccelerateMax(simulation, train);
|
||||
} else if (diff < 0) { //当前速度略小于目标速度
|
||||
this.doAccelerate(simulation, train, 0.1f);
|
||||
} else if (0 == diff) {
|
||||
this.doIdle(simulation, train);
|
||||
} else if (diff < 0.1) { //当前速度略大于目标速度
|
||||
this.doBreak(simulation, train, -0.1f);
|
||||
} else {
|
||||
this.doBreakMax(simulation, train); //当前速度远大于目标速度
|
||||
}
|
||||
} else { //减速段
|
||||
if (diff <= -0.1) { //当前速度远小于目标速度
|
||||
this.doAccelerateMax(simulation, train);
|
||||
} else if (diff < 0) { //当前速度略小于目标速度
|
||||
this.doBreak(simulation, train, Math.abs(acceleration) - 0.1f);
|
||||
} else if (0 == diff) {
|
||||
this.doBreak(simulation, train, Math.abs(acceleration));
|
||||
} else if (diff < 0.1) { //当前速度略大于目标速度
|
||||
this.doBreak(simulation, train, Math.abs(acceleration) + 0.1f);
|
||||
} else {
|
||||
this.doBreakMax(simulation, train); //当前速度远大于目标速度
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车启动
|
||||
*
|
||||
* @param simulation
|
||||
* @param train
|
||||
*/
|
||||
private void doStart(Simulation simulation, VirtualRealityTrain train) {
|
||||
driverOperateHandler.changeTrainForce(simulation, train.getGroupNumber(), 1f);
|
||||
}
|
||||
|
||||
/**
|
||||
* 惰行(不牵引,不制动)
|
||||
*
|
||||
* @param simulation
|
||||
* @param train
|
||||
*/
|
||||
private void doIdle(Simulation simulation, VirtualRealityTrain train) {
|
||||
driverOperateHandler.changeTrainForce(simulation, train.getGroupNumber(), 0f);
|
||||
}
|
||||
|
||||
private void doAccelerateMax(Simulation simulation, VirtualRealityTrain train) {
|
||||
this.doAccelerate(simulation, train, VirtualRealityTrain.Stable_Acceleration);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车加速
|
||||
*/
|
||||
private void doAccelerate(Simulation simulation, VirtualRealityTrain train, float a) {
|
||||
float fk = a * train.getMass();
|
||||
float fkMax = train.getCurrentFkMax();
|
||||
fk = Math.min(fk, fkMax);
|
||||
driverOperateHandler.changeTrainForce(simulation, train.getGroupNumber(),
|
||||
Math.min(fk / fkMax, 1));
|
||||
}
|
||||
|
||||
private void doBreakMax(Simulation simulation, VirtualRealityTrain train) {
|
||||
driverOperateHandler.changeTrainForce(simulation, train.getGroupNumber(), -1f);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车制动
|
||||
*/
|
||||
private void doBreak(Simulation simulation, VirtualRealityTrain train, float a) {
|
||||
a = -Math.abs(a);
|
||||
float fb = train.getMass() * a;
|
||||
float fbMax = train.getCurrentFbMax();
|
||||
driverOperateHandler.changeTrainForce(simulation, train.getGroupNumber(),
|
||||
Math.max(fb / fbMax, -1));
|
||||
atpService.changeTrainForce(train, -1f);
|
||||
}
|
||||
|
||||
public void addJobs(Simulation simulation) {
|
||||
|
|
Loading…
Reference in New Issue