Commit 999bb38a authored by Frederik's avatar Frederik
Browse files

created docs directory and README

parent 3f7b6daf
# Bus
This part of the project includes the classes for the simulation of diffrent buses.
# An exaple of a bussystem
This picture shows an example bus system with the buses A,B,C , the actuator 1-6 and the bridges ab and bc. The times, shown in red, describes the delay by using the specific component, the arrows describe which actuator sends or want to recieve the message Mes1 (green), send by actuator one, and Mess2 (blue), send by actuator five.
![Alt-Text](/docs/BusExample.jpg)
# How does the bus is used
This sequence diagram describes the function calls to transmit Mes2 from actuator five to actuator two. Actuator act5 creates an event of type busMessage and register it at the simulator by using the function `addEvent()` of the simulator. In regular time steps, the simulator got the function call `simualteFor(time)`. The simulator will start to process all registered events with an event time lower than the argument `time`. For processing, the simulator uses the function `processEvent()` of the target component saved in the busMessage. This function will process the event individually, depending on the target component type.
Bridges create new events with a new target bus.
Actuators use the information send in the busMessage.
Buses create new keepAlive events for themselves with the event time when the incoming busMessage will be transmitted completely. KeepAlive events will be processed by the bus by sending the original busMessage to all next receivers.
![Alt-Text](/docs/SequenceDiagram.jpg)
# How does the event queue of the simulator works
This diagram describes how the event queue of the simulator develops over a time period after the actuators one and five have added their messages and the simulator have gotten the `simulateFor()` call. The arrows show which event is created based on the actual event. The red dashed lines mark the events that are not processed this time, depending on the time of the events.
For example, at the beginning, the fist entry of the event queue ist the message 1 with target bus A at the time 0. The simulator will use the function `processEvent(Mes1)` of the bus A. In the following bus A will create a KeepAlive event with target bus A and time 2. The time of this keepAlive event is the time when the bus would have transmitted the whole message Mes1 to the next components. In the next step, the simulator will choose the first event again. It will call `processEvent(KeepAlive)` of the bus and the bus will create two new busMessages to each component, wich want to receive the message 1.
![Alt-Text](/docs/EventQueue.jpg)
\ No newline at end of file
......@@ -80,6 +80,7 @@ public class EEVehicleBuilder {
* @return
*/
public EEVehicle buildEEVehicle(Vehicle vehicle, File data) {
components.clear();
List<Bus> busList = new LinkedList<>();
//set busAndParameter, sensor, actuator and bridge lists
ParsableBusStructureProperties busStructure;
......@@ -87,6 +88,9 @@ public class EEVehicleBuilder {
try {
busStructure = loadFromFile(data);
for (ParsableBusStructureProperties.Tupel comp : busStructure.getActuators()) {
System.out.println("comp type: " + comp.eeComponent);
}
//create buses
for (ParsableBusStructureProperties.Tupel component : busStructure.getBuses()) {
if (component.eeComponent.equals("flexRay")) {
......@@ -105,6 +109,9 @@ public class EEVehicleBuilder {
//create sensors, actuator and bridges
for (ParsableBusStructureProperties.Tupel sensor : busStructure.getSensors()) {
try {
System.out.println("create sensor");
System.out.println(sensor.busIds[0]);
System.out.println(busList.get(sensor.busIds[0]));
Class<? extends AbstractSensor> sensorClass = (Class<? extends AbstractSensor>) Class.forName(sensor.eeComponent);
AbstractSensor newSensor = SensorFactory.createSensor(sensorClass, vehicle.getPhysicalVehicle(), busList.get(sensor.busIds[0])).get();
components.add(newSensor);
......@@ -115,17 +122,20 @@ public class EEVehicleBuilder {
}
for (ParsableBusStructureProperties.Tupel actuator : busStructure.getActuators()) {
System.out.println("create actuator");
VehicleActuator newActuator = VehicleActuator.createVehicleActuator(VehicleActuatorType.valueOf(actuator.eeComponent), Double.parseDouble(actuator.parameter[0]), Double.parseDouble(actuator.parameter[1]), Double.parseDouble(actuator.parameter[2]), busList.get(actuator.busIds[0]));
components.add(newActuator);
// busList.get(actuator.busIds[0]).registerComponent(newActuator);
}
for (ParsableBusStructureProperties.Tupel bridge : busStructure.getBridges()) {
Bridge newBridge = new Bridge(Pair.of(busList.get((bridge.busIds[0])), busList.get(Integer.parseInt(bridge.parameter[1]))), Duration.ofMillis(Long.parseLong(bridge.parameter[2])));
System.out.println("create bridge");
Bridge newBridge = new Bridge(Pair.of(busList.get((bridge.busIds[0])), busList.get(Integer.parseInt(bridge.parameter[0]))), Duration.ofMillis(Long.parseLong(bridge.parameter[1])));
components.add(newBridge);
}
if (busStructure.getNavigation() != null && busStructure.getNavigation().busIds != null) {
System.out.println("create navigation");
NavigationBlockAsEEComponent navigation;
navigation = NavigationBlockAsEEComponent.createNavigationBlockAsEEComponent(busList.get(busStructure.getNavigation().busIds[0]));
vehicle.initNavigation(navigation);
......@@ -134,6 +144,7 @@ public class EEVehicleBuilder {
}
if (!busStructure.getController().isEmpty()) {
System.out.println("create controller");
for (ParsableBusStructureProperties.Tupel controller : busStructure.getController()) {
DirectModelAsEEComponent newController = DirectModelAsEEComponent.createDirectModelAsEEComponent(busList.get(controller.busIds[0]));
newController.setCycleTime(Duration.parse(controller.parameter[0]));
......@@ -147,6 +158,12 @@ public class EEVehicleBuilder {
throw new IllegalArgumentException("Can not create EEVehicle. Failed to read file: " + data);
}
for (EEComponent comp : components) {
System.out.println("comp type in list: " + comp.getComponentType());
if (comp.getComponentType() == EEComponentType.ACTUATOR) {
System.out.println("actuator comp type in list: " + ((VehicleActuator) comp).getActuatorType());
}
}
return new EEVehicle(vehicle, eeSimulator, new HashSet<>(busList), components);
}
......@@ -353,10 +370,10 @@ class ParsableBusStructureProperties {
break;
case FLEXRAY:
String[] param = {((FlexRay) bus).getMode().toString()};
buses.add(new Tupel(bus.getBusType().toString(), busIdArr, param));
buses.add(new Tupel("flexRay", busIdArr, param));
break;
case INSTANT_BUS:
buses.add(new Tupel(bus.getBusType().toString(), busIdArr, null));
buses.add(new Tupel("instantBus", busIdArr, null));
break;
default:
throw new IllegalStateException("connected Bus has unknown type. Type was " + bus.getBusType());
......
......@@ -34,9 +34,9 @@ public class ControllerTest {
//hardcoded config
private final String AUTOPILOT_CONFIG = "autopilot=AutopilotAdapter\n"+
"os=windows\n" +
"os=windows\n" +
"no_time=true";
@Test
public void testController() throws Exception {
HardwareEmulatorInterface modelServer = new HardwareEmulatorInterface("autopilots_folder=autopilots", "");
......@@ -48,7 +48,7 @@ public class ControllerTest {
DirectModelAsEEComponent ecu = eeVehicleBuilder.createController(modelServer, AUTOPILOT_CONFIG, bus);
Vehicle vehicle = new Vehicle(physicalVehicleBuilder, eeVehicleBuilder);
EEVehicle eeVehicle = vehicle.getEEVehicle();
//get actuators
VehicleActuator steering = vehicle.getEEVehicle().getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_STEERING).get();
VehicleActuator brakeBL = vehicle.getEEVehicle().getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_BACK_LEFT).get();
......@@ -56,7 +56,7 @@ public class ControllerTest {
VehicleActuator brakeFL = vehicle.getEEVehicle().getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_FRONT_LEFT).get();
VehicleActuator brakeFR = vehicle.getEEVehicle().getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_FRONT_RIGHT).get();
VehicleActuator motor = vehicle.getEEVehicle().getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_MOTOR).get();
HashMap<VehicleActuator, Double> initialValuesByActuator = new HashMap<VehicleActuator, Double>();
initialValuesByActuator.put(steering, steering.getActuatorValueTarget());
initialValuesByActuator.put(brakeBL, brakeBL.getActuatorValueTarget());
......@@ -66,7 +66,7 @@ public class ControllerTest {
initialValuesByActuator.put(motor, motor.getActuatorValueTarget());
vehicle.executeLoopIteration(Duration.ofMillis(30));
//ecu emits 3 messages
int controllerMessagesCount = 0;
for(EEDiscreteEvent event : eeVehicle.getEESimulator().getEventList()) {
......@@ -77,18 +77,18 @@ public class ControllerTest {
}
}
}
assertEquals(3, controllerMessagesCount);
vehicle.executeLoopIteration(Duration.ofMillis(30));
boolean initialValuesChanged = false;
for(Map.Entry<VehicleActuator, Double> initialValueByActuator : initialValuesByActuator.entrySet()) {
if(Math.abs(initialValueByActuator.getKey().getActuatorValueTarget()-initialValueByActuator.getValue()) > 0.001) {
initialValuesChanged = true;
}
}
Assert.isTrue(initialValuesChanged);
}
......
......@@ -12,11 +12,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import org.junit.Assert;
import org.junit.Test;
......@@ -24,7 +20,11 @@ import org.junit.Test;
import com.google.common.collect.Sets;
import de.rwth.monticore.EmbeddedMontiArc.simulators.commons.controller.commons.BusEntry;
import sensors.CameraSensor;
import sensors.LocationSensor;
import sensors.ObstacleSensor;
import sensors.abstractsensors.AbstractSensor;
import sensors.factory.SensorFactory;
import simulation.EESimulator.Bridge;
import simulation.EESimulator.EEComponent;
import simulation.EESimulator.EEComponentType;
......@@ -45,6 +45,7 @@ public class EEVehicleBuilderTest {
Set<Bus> buses = new HashSet<>();
List<EEComponent> componentList = new LinkedList<>();
List<VehicleActuator> actuatorCompareList = new LinkedList<>();
List<AbstractSensor> sensorCompoareList = new LinkedList<>();
List<Bus> busCompareList = new LinkedList<>();
List<EEComponent> bridgeCompareList = new LinkedList<>();
List<EEComponent> busOneCompareList = new LinkedList<>();
......@@ -130,7 +131,6 @@ public class EEVehicleBuilderTest {
busThreeCompareList.add(bridgeTwoThree);
System.out.println("Test create EEVehicle by using Lists");
//set up EEVehicle
Vehicle vehicle = new Vehicle(physicalVehicleBuilder, eeVehicleBuilder);
EEVehicle eeVehicle = vehicle.getEEVehicle();
......@@ -181,33 +181,34 @@ public class EEVehicleBuilderTest {
assertEquals(1, symDiffComps.size());
Assert.assertTrue(symDiffComps.contains(obstacle));
// System.out.println("Test create EEVehicle by using JSON File");
// //store and load from JSON file
// File file = new File("C:/Users/Freddy/Desktop/SWP/EEVehicle Testordner/test.txt");
// eeVehicleBuilder.storeInFile(file, vehicle.getEEVehicle());
//
// Vehicle vehicleJSON = new Vehicle(new MassPointPhysicalVehicleBuilder(), eeVehicleBuilder, file);
//
// //search and collect all created bridges
// HashSet<Bridge> createdBridgesJSON = new HashSet<>();
// for (Bus bus : eeVehicle.getBusList()) {
// for (EEComponent comp : bus.getConnectedComponents()) {
// if (comp.getComponentType() == EEComponentType.BRIDGE) {
// createdBridges.add((Bridge) comp);
// }
// }
// }
//
// //tests
// assertTrue(componentIsConnected(new LinkedList<EEComponent>(busCompareList), new LinkedList<EEComponent>(vehicleJSON.getEEVehicle().getBusList())));
// assertTrue(componentIsConnected(new LinkedList<EEComponent>(actuatorCompareList), new LinkedList<EEComponent>(vehicleJSON.getEEVehicle().getActuatorList())));
// assertTrue(componentIsConnected(new LinkedList<EEComponent>(bridgeCompareList), new LinkedList<EEComponent>(createdBridgesJSON)));
// assertTrue(allSensorsConnected(vehicleJSON.getEEVehicle().getSensorList()));
// assertTrue(componentIsConnected(busOneCompareList, busOne.getConnectedComponents()));
// assertTrue(componentIsConnected(busTwoCompareList, busTwo.getConnectedComponents()));
// assertTrue(componentIsConnected(busThreeCompareList, busThree.getConnectedComponents()));
//
//
//store and load from JSON file
File file = new File("C:/Users/Freddy/Desktop/SWP/EEVehicle Testordner/test.txt");
eeVehicleBuilder.storeInFile(file, vehicle.getEEVehicle());
Vehicle vehicleJSON = new Vehicle(new MassPointPhysicalVehicleBuilder(), eeVehicleBuilder, file);
//search and collect all created bridges
HashSet<Bridge> createdBridgesJSON = new HashSet<>();
//List<UUID> processedBridges = new LinkedList<>();
for (Bus bus : eeVehicle.getBusList()) {
for (EEComponent comp : bus.getConnectedComponents()) {
if (comp.getComponentType() == EEComponentType.BRIDGE && !createdBridgesJSON.contains(comp)) {
//processedBridges.add(comp.getId());
createdBridgesJSON.add((Bridge) comp);
}
}
}
//tests
assertTrue(componentIsConnected(new LinkedList<EEComponent>(busCompareList), new LinkedList<EEComponent>(vehicleJSON.getEEVehicle().getBusList())));
assertTrue(componentIsConnected(new LinkedList<EEComponent>(actuatorCompareList), new LinkedList<EEComponent>(vehicleJSON.getEEVehicle().getActuatorList())));
assertTrue(componentIsConnected(new LinkedList<EEComponent>(bridgeCompareList), new LinkedList<EEComponent>(createdBridgesJSON)));
assertTrue(correctSensors(vehicleJSON.getEEVehicle().getSensorList()));
assertTrue(componentIsConnected(busOneCompareList, busOne.getConnectedComponents()));
assertTrue(componentIsConnected(busTwoCompareList, busTwo.getConnectedComponents()));
assertTrue(componentIsConnected(busThreeCompareList, busThree.getConnectedComponents()));
}
@Test
......@@ -264,23 +265,24 @@ public class EEVehicleBuilderTest {
return true;
}
private boolean allSensorsConnected(List<AbstractSensor> isConnected) {
private boolean correctSensors(List<AbstractSensor> isConnected) {
boolean notFound = false;
for (BusEntry entry : BusEntry.values()) {
for (AbstractSensor is : isConnected) {
if (notFound) {
return false;
}
notFound = true;
if (entry.toString().contains("SENSOR_")){
for (AbstractSensor sensor : isConnected) {
if (sensor.getType() == entry) {
notFound = false;
break;
}
}
if (is.getType() == BusEntry.SENSOR_CAMERA) {
notFound = false;
} else if (is.getType() == BusEntry.SENSOR_GPS_COORDINATES) {
notFound = false;
} else if (is.getType() == BusEntry.SENSOR_OBSTACLE) {
notFound = false;
}
}
return true;
}
}
......@@ -64,13 +64,13 @@ public class EEVehicleTest {
eeVehicle.getSensorList().add(sensor1);
eeVehicle.getSensorList().add(sensor2);
eeVehicle.getSensorList().add(sensor3);
eeVehicle.setConstantBusData();
EESimulator sim = eeVehicle.getEESimulator();
assertEquals(sim.getEventList().size(), EEVehicle.constantMessages.size() - 1 + 2 +3);
}
@Test
public void testMessageToActuator(){
......@@ -89,7 +89,7 @@ public class EEVehicleTest {
VehicleActuator brakeReference = new VehicleActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_BACK_LEFT, Vehicle.VEHICLE_DEFAULT_BRAKES_ACCELERATION_MIN, Vehicle.VEHICLE_DEFAULT_BRAKES_ACCELERATION_MAX, Vehicle.VEHICLE_DEFAULT_BRAKES_ACCELERATION_RATE, vehicle.getEEVehicle().getEESimulator(), Collections.emptyList(), emptyMap);
VehicleActuator steering = eeVehicle.getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_STEERING).get();
VehicleActuator brake = eeVehicle.getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_BACK_LEFT).get();
//set to same inital value
steeringReference.setActuatorValueCurrent(0);
brakeReference.setActuatorValueCurrent(0);
......@@ -116,7 +116,7 @@ public class EEVehicleTest {
assertEquals(brakeReference.getActuatorValueCurrent(), vehicle.getEEVehicle().getActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_BACK_LEFT).get().getActuatorValueCurrent());
}
@Test
public void notifySensorsTest() {
PhysicalVehicleBuilder physicalVehicleBuilder = new MassPointPhysicalVehicleBuilder();
......@@ -126,7 +126,7 @@ public class EEVehicleTest {
eeVehicleBuilder.createAllSensorsNActuators(bus);
Vehicle vehicle = new Vehicle(physicalVehicleBuilder, eeVehicleBuilder);
EEVehicle eeVehicle = vehicle.getEEVehicle();
eeVehicle.notifySensors(Instant.EPOCH.plusMillis(30));
List<EEDiscreteEvent> events = new ArrayList<EEDiscreteEvent>(eeVehicle.getEESimulator().getEventList());
assertEquals(eeVehicle.getSensorList().size(), events.size());
......@@ -134,7 +134,7 @@ public class EEVehicleTest {
assertEquals(eeVehicle.getEESimulator().getSimulationTime(), event.getEventTime());
}
}
@Test
public void notifyActuatorsTest() {
PhysicalVehicleBuilder physicalVehicleBuilder = new MassPointPhysicalVehicleBuilder();
......@@ -144,7 +144,7 @@ public class EEVehicleTest {
eeVehicleBuilder.createAllSensorsNActuators(bus);
Vehicle vehicle = new Vehicle(physicalVehicleBuilder, eeVehicleBuilder);
EEVehicle eeVehicle = vehicle.getEEVehicle();
Instant endTime = eeVehicle.getEESimulator().getSimulationTime().plusMillis(30);
eeVehicle.notifyActuator(endTime);
List<EEDiscreteEvent> events = new ArrayList<EEDiscreteEvent>(eeVehicle.getEESimulator().getEventList());
......
......@@ -58,11 +58,11 @@ public class FrictionTest {
EEVehicleBuilder eeVehicleBuilder1 = new EEVehicleBuilder(eeSimulator);
InstantBus bus1 = new InstantBus(eeSimulator);
eeVehicleBuilder1.createAllSensorsNActuators(bus1);
PhysicalVehicleBuilder physicalVehicleBuilder1 = new ModelicaPhysicalVehicleBuilder();
Vehicle vehicle1 = new Vehicle(physicalVehicleBuilder1, eeVehicleBuilder1);
ModelicaPhysicalVehicle physicalVehicle1 = (ModelicaPhysicalVehicle) vehicle1.getPhysicalVehicle();
EEVehicleBuilder eeVehicleBuilder2 = new EEVehicleBuilder(eeSimulator);
InstantBus bus2 = new InstantBus(eeSimulator);
eeVehicleBuilder2.createAllSensorsNActuators(bus2);
......@@ -96,7 +96,7 @@ public class FrictionTest {
physicalVehicleBuilder.setPosition(expectedPosition);
physicalVehicleBuilder.setVelocity(setVelocity);
physicalVehicleBuilder.setAngularVelocity(setAngularVelocity);
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
InstantBus bus = new InstantBus(eeSimulator);
......
......@@ -91,7 +91,7 @@ public class MassPointBuilderTest {
assertEquals(expectedWheelDistLeftRightBackSide, physicalVehicle.getWheelDistLeftRightBackSide(), 0);
assertEquals(expectedWheelDistToFront, physicalVehicle.getWheelDistToFront(), 0);
assertEquals(expectedWheelDistToBack, physicalVehicle.getWheelDistToBack(), 0);
// Test internal values
assertEquals(PhysicalObjectType.PHYSICAL_OBJECT_TYPE_CAR, physicalVehicle.getPhysicalObjectType());
assertFalse(physicalVehicle.getError());
......@@ -144,7 +144,7 @@ public class MassPointBuilderTest {
builder.setWheelDistLeftRightBackSide(expectedWheelDistLeftRightBackSide);
builder.setWheelDistToFront(expectedWheelDistToFront);
builder.setWheelDistToBack(expectedWheelDistToBack);
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
InstantBus bus = new InstantBus(eeSimulator);
......
......@@ -55,7 +55,7 @@ public class MassPointPhysicalVehicleTest {
public void setHeightFail(){
MassPointPhysicalVehicleBuilder massPointBuilder = new MassPointPhysicalVehicleBuilder();
Vehicle vehicle = createStandardVehicle(massPointBuilder);
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
physicalVehicle.setHeight(1.0);
}
......@@ -63,12 +63,12 @@ public class MassPointPhysicalVehicleTest {
public void executeLoopIterationNoFlags(){
EESimulator simulator = new EESimulator(Instant.EPOCH);
HashMap<BusEntry, List<EEComponent>> targetsByMessageId = new HashMap<>();
// Set up normal vehicle
MassPointPhysicalVehicleBuilder massPointBuilder = new MassPointPhysicalVehicleBuilder();
Vehicle vehicle = createStandardVehicle(massPointBuilder);
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
// Set values for vehicle actuators
VehicleActuator motor = physicalVehicle.getVehicleActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_MOTOR);
motor.setActuatorValueTarget(Vehicle.VEHICLE_DEFAULT_MOTOR_ACCELERATION_MAX);
......@@ -150,7 +150,7 @@ public class MassPointPhysicalVehicleTest {
public void executeLoopIterationCollisionFlag(){
EESimulator simulator = new EESimulator(Instant.EPOCH);
HashMap<BusEntry, List<EEComponent>> targetsByMessageId = new HashMap<>();
// Set up vehicle with collision
MassPointPhysicalVehicleBuilder massPointBuilder = new MassPointPhysicalVehicleBuilder();
Vehicle vehicle = createStandardVehicle(massPointBuilder);
......@@ -280,7 +280,7 @@ public class MassPointPhysicalVehicleTest {
MassPointPhysicalVehicleBuilder massPointBuilder = new MassPointPhysicalVehicleBuilder();
Vehicle vehicle = createStandardVehicle(massPointBuilder);
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
Rotation rot = new Rotation(RotationOrder.XYZ, RotationConvention.VECTOR_OPERATOR, 1.0, 2.0, 3.0);
RealMatrix rotation = new BlockRealMatrix(rot.getMatrix());
physicalVehicle.setRotation(rotation);
......@@ -394,7 +394,7 @@ public class MassPointPhysicalVehicleTest {
physicalVehicleBuilder.setVelocity(new ArrayRealVector(new double[]{0.0, 14.0, 0.0}));
Vehicle vehicle = createStandardVehicle(physicalVehicleBuilder);
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
// Put physical vehicle on the surface
physicalVehicle.putOnSurface(0.0, 0.0, 0.0);
......@@ -425,7 +425,7 @@ public class MassPointPhysicalVehicleTest {
MassPointPhysicalVehicleBuilder massPointBuilder = new MassPointPhysicalVehicleBuilder();
Vehicle vehicle = createStandardVehicle(massPointBuilder);
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
// Add physicalVehicle to simulation
physicalVehicle.putOnSurface(0.0, 0.0, 0.0);
......@@ -452,7 +452,7 @@ public class MassPointPhysicalVehicleTest {
physicalVehicleBuilder.setVelocity(new ArrayRealVector(new double[]{0.0, 0.01, 0.0}));
Vehicle vehicle = createStandardVehicle(physicalVehicleBuilder);
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
// Add physicalVehicle to simulation
physicalVehicle.putOnSurface(0.0, 0.0, 0.0);
......@@ -482,7 +482,7 @@ public class MassPointPhysicalVehicleTest {
physicalVehicle.getVehicleActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_BRAKES_BACK_RIGHT).update(Instant.EPOCH.plusMillis(timeDiffMs));
physicalVehicle.getVehicleActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_MOTOR).update(Instant.EPOCH.plusMillis(timeDiffMs));
}
private Vehicle createStandardVehicle(PhysicalVehicleBuilder physicalVehicleBuilder) {
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
......
......@@ -192,7 +192,7 @@ public class ModelicaBuilderTest {
Assert.assertEquals(expectedWheelRotationRate, physicalVehicle.getVDM().getValue("omega_wheel_3"), 0);
Assert.assertEquals(expectedWheelRotationRate, physicalVehicle.getVDM().getValue("omega_wheel_4"), 0);
}
private Vehicle createStandardVehicle(PhysicalVehicleBuilder physicalVehicleBuilder) {
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
......
......@@ -63,7 +63,7 @@ public class ModelicaPhysicalVehicleTest {
// Set up normal vehicle
Vehicle vehicle = createStandardVehicle(new ModelicaPhysicalVehicleBuilder());
ModelicaPhysicalVehicle physicalVehicle = (ModelicaPhysicalVehicle) vehicle.getPhysicalVehicle();
// Set values for vehicle actuators
VehicleActuator throttle = physicalVehicle.getVehicleActuator(VehicleActuatorType.VEHICLE_ACTUATOR_TYPE_THROTTLE);
throttle.setActuatorValueCurrent(Vehicle.VEHICLE_DEFAULT_THROTTLE_POSITION_MIN);
......@@ -332,7 +332,7 @@ public class ModelicaPhysicalVehicleTest {
ModelicaPhysicalVehicle physicalVehicle = (ModelicaPhysicalVehicle) vehicle.getPhysicalVehicle();
physicalVehicle.initPhysics();
}
private Vehicle createStandardVehicle(PhysicalVehicleBuilder physicalVehicleBuilder) {
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
......
......@@ -243,7 +243,7 @@ public class PhysicalVehicleTest {
@Test(expected = IllegalStateException.class)
public void setWheelDistToBackMassPoint(){
Vehicle vehicle = createStandardVehicle(new MassPointPhysicalVehicleBuilder());
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
physicalVehicle.setWheelDistToBack(1.0);
}
......@@ -253,7 +253,7 @@ public class PhysicalVehicleTest {
PhysicalVehicle physicalVehicle = vehicle.getPhysicalVehicle();
physicalVehicle.setWheelDistToBack(1.0);
}
private Vehicle createStandardVehicle(PhysicalVehicleBuilder physicalVehicleBuilder) {
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
......
......@@ -64,7 +64,7 @@ public class VehicleTest {
PhysicsEngine.computePhysics(vehicle1, physicalObjects, timeDiff);
assertTrue(vehicle1.getCollision() && !vehicle2.getCollision());
}
private Vehicle createStandardVehicle(PhysicalVehicleBuilder physicalVehicleBuilder) {
EESimulator eeSimulator = new EESimulator(Instant.EPOCH);
EEVehicleBuilder eeVehicleBuilder = new EEVehicleBuilder(eeSimulator);
......
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