Skip to content

Commit

Permalink
fix: decel was missed when creating a vehicle type (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
kschrab authored Aug 1, 2023
1 parent 750a77a commit b184d3f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public VehicleTypeSpawner(CPrototype prototypeConfiguration) {
this.maxSpeed = prototypeConfiguration.maxSpeed;
this.vehicleClass = prototypeConfiguration.vehicleClass;
this.accel = prototypeConfiguration.accel;
this.decel = prototypeConfiguration.decel;
this.emergencyDecel = prototypeConfiguration.emergencyDecel;
this.sigma = prototypeConfiguration.sigma;
this.tau = prototypeConfiguration.tau;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,62 @@
import static org.junit.Assert.assertNull;

import org.eclipse.mosaic.fed.mapping.config.CPrototype;
import org.eclipse.mosaic.lib.enums.LaneChangeMode;
import org.eclipse.mosaic.lib.enums.SpeedMode;
import org.eclipse.mosaic.lib.enums.VehicleClass;
import org.eclipse.mosaic.lib.math.DefaultRandomNumberGenerator;
import org.eclipse.mosaic.lib.math.MathUtils;
import org.eclipse.mosaic.lib.math.RandomNumberGenerator;
import org.eclipse.mosaic.lib.objects.vehicle.VehicleType;

import org.junit.Test;

public class VehicleTypeSpawnerTest {

@Test
public void creationFromCPrototype() {
// SETUP
CPrototype prototype = new CPrototype();
prototype.weight = 0.1;

prototype.length = 5.0;
prototype.width = 2.0;
prototype.height = 1.5;

prototype.minGap = 2.3;
prototype.tau = 1.0;
prototype.sigma = 0.2;

prototype.accel = 2.3;
prototype.decel = 2.5;
prototype.maxSpeed = 30.0;
prototype.emergencyDecel = 7.4;
prototype.speedFactor = 1.2;

prototype.vehicleClass = VehicleClass.AutomatedVehicle;
prototype.speedMode = SpeedMode.SPEEDER;
prototype.laneChangeMode = LaneChangeMode.COOPERATIVE;

// RUN
VehicleType type = new VehicleTypeSpawner(prototype).convertType();

// ASSERT
assertEquals(prototype.length, type.getLength(), MathUtils.EPSILON_D);
assertEquals(prototype.width, type.getWidth(), MathUtils.EPSILON_D);
assertEquals(prototype.height, type.getHeight(), MathUtils.EPSILON_D);
assertEquals(prototype.minGap, type.getMinGap(), MathUtils.EPSILON_D);
assertEquals(prototype.tau, type.getTau(), MathUtils.EPSILON_D);
assertEquals(prototype.sigma, type.getSigma(), MathUtils.EPSILON_D);
assertEquals(prototype.accel, type.getAccel(), MathUtils.EPSILON_D);
assertEquals(prototype.decel, type.getDecel(), MathUtils.EPSILON_D);
assertEquals(prototype.maxSpeed, type.getMaxSpeed(), MathUtils.EPSILON_D);
assertEquals(prototype.emergencyDecel, type.getEmergencyDecel(), MathUtils.EPSILON_D);
assertEquals(prototype.speedFactor, type.getSpeedFactor(), MathUtils.EPSILON_D);
assertEquals(prototype.vehicleClass, type.getVehicleClass());
assertEquals(prototype.speedMode, type.getSpeedMode());
assertEquals(prototype.laneChangeMode, type.getLaneChangeMode());
}

@Test
public void fillInPrototype() {
//SETUP
Expand Down

0 comments on commit b184d3f

Please sign in to comment.