Commit 2a69beb0 authored by Theresa Täuber's avatar Theresa Täuber
Browse files

viel geändert

parent 249d7ec4
Pipeline #97280 failed with stage
in 1 minute and 45 seconds
#
#
# ******************************************************************************
# MontiCAR Modeling Family, www.se-rwth.de
# Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
......
......@@ -86,7 +86,7 @@ public class EnvironmentContainerConverter {
intersections.add(new Intersection2D(mX, mY, mZ, osmId));
}
meterStreets.add(new Street2D(nodes, longLatStreet.getSpeedLimit(), intersections, longLatStreet.getOsmId(), longLatStreet.isOneWay(), longLatStreet.getStreetType()));
meterStreets.add(new Street2D(nodes, longLatStreet.getSpeedLimit(), intersections, longLatStreet.getOsmId(), longLatStreet.isOneWay(), longLatStreet.getStreetType(), longLatStreet.getStreetPavement()));
}
computeMinMax(meterStreets);
containerMeters = new EnvironmentContainer2D(bounds, meterStreets, new ArrayList<>());
......
......@@ -374,7 +374,7 @@ public class Parser2D implements IParser {
nodes.add(new Node2D(node.getLongitude(), node.getLatitude(), 0, way.getNodeId(i)));
}
this.streets.add(new Street2D(nodes, 50.d, mapper.getIntersectionsForWay(way), way.getId(), isOneWay, parseStreetType(highway)));
this.streets.add(new Street2D(nodes, 50.d, mapper.getIntersectionsForWay(way), way.getId(), isOneWay, parseStreetType(highway), parseStreetPavement(highway)));
}
@Override
......@@ -412,4 +412,26 @@ public class Parser2D implements IParser {
return EnvStreet.StreetTypes.A_ROAD; //Default
}
}
/**
* converts String streetpavement in enum
* @param s as streetpavement
*/
public EnvStreet.StreetPavements parseStreetPavement(String s) {
if (s.equals("paved")) {
return EnvStreet.StreetPavements.PAVED;
} else if (s.equals("unpaved")) {
return EnvStreet.StreetPavements.UNPAVED;
} else if (s.equals("asphalt") || s.equals("concrete")) {
return EnvStreet.StreetPavements.QUALITY;
} else if (s.equals("cobblestone") || s.equals("sett") || s.equals("paving_stone")) {
return EnvStreet.StreetPavements.STONE;
} else if (s.equals("compacted") || s.equals("gravel") || s.equals("dirt")) {
return EnvStreet.StreetPavements.DIRT;
} else {
return EnvStreet.StreetPavements.GRASS; //als default gut wählbar?
}
}
}
\ No newline at end of file
......@@ -39,6 +39,9 @@ public class Street2D extends EnvObject2D implements EnvStreet {
private Number speedLimit;
private ArrayList<EnvNode> intersections;
private StreetTypes streetType;
private StreetPavements streetPavements;
public Street2D(List<EnvNode> nodes, Number speedLimit, Collection<EnvIntersection> intersections, boolean isOneWay) {
super(nodes, EnvTag.STREET);
......@@ -50,9 +53,9 @@ public class Street2D extends EnvObject2D implements EnvStreet {
init(speedLimit, intersections, isOneWay);
}
public Street2D(List<EnvNode> nodes, Number speedLimit, Collection<EnvIntersection> intersections, long osmId, boolean isOneWay, StreetTypes streetType) {
public Street2D(List<EnvNode> nodes, Number speedLimit, Collection<EnvIntersection> intersections, long osmId, boolean isOneWay, StreetTypes streetType, StreetPavements streetPavements) {
super(nodes, EnvTag.STREET, osmId);
init(speedLimit, intersections, isOneWay, streetType);
init(speedLimit, intersections, isOneWay, streetType, streetPavements);
}
private void init(Number speedLimit, Collection<EnvIntersection> intersections, boolean isOneWay) {
......@@ -65,10 +68,11 @@ public class Street2D extends EnvObject2D implements EnvStreet {
}
}
private void init(Number speedLimit, Collection<EnvIntersection> intersections, boolean isOneWay, StreetTypes streetType) {
private void init(Number speedLimit, Collection<EnvIntersection> intersections, boolean isOneWay, StreetTypes streetType, StreetPavements streetPavements) {
this.speedLimit = speedLimit;
this.isOneWay = isOneWay;
this.streetType = streetType;
this.streetPavements = streetPavements;
if (intersections == null) {
this.intersections = new ArrayList<>();
} else {
......@@ -102,4 +106,8 @@ public class Street2D extends EnvObject2D implements EnvStreet {
@Override
public StreetTypes getStreetType(){ return streetType; }
@Override
public StreetPavements getStreetPavement() { return streetPavements; }
}
\ No newline at end of file
......@@ -40,6 +40,12 @@ public interface EnvStreet extends EnvObject {
*/
public final double STREET_WIDTH = 6;
/**
* Lists Pavements of Streets
*/
public enum StreetPavements {PAVED, UNPAVED, QUALITY, STONE, DIRT, GRASS};
/**
*
* @return the speedlimit on this street
......@@ -69,4 +75,10 @@ public interface EnvStreet extends EnvObject {
* @return The Type of the Street
*/
public abstract StreetTypes getStreetType();
/**
*
* @return The Pavement of the Street
*/
public abstract StreetPavements getStreetPavement();
}
\ No newline at end of file
package sensors;
import commons.controller.commons.BusEntry;
import commons.simulation.Sensor;
import sensors.abstractsensors.AbstractSensor;
import simulation.environment.World;
import simulation.environment.WorldModel;
import simulation.environment.geometry.osmadapter.GeomStreet;
import simulation.environment.visualisationadapter.implementation.Street2D;
import simulation.environment.visualisationadapter.interfaces.EnvStreet;
import sensors.factory.SensorFactory;
import simulation.vehicle.PhysicalVehicle;
import simulation.vehicle.Vehicle;
import static commons.controller.commons.BusEntry.SENSOR_STREETPAVEMENT;
import java.util.Optional;
/**
* Created by Theresa on 08.01.2019.
*/
public class StreetPavementSensor extends AbstractSensor {
private String value;
public StreetPavementSensor(PhysicalVehicle physicalVehicle) {
super(physicalVehicle);
}
@Override
public BusEntry getType() {
return BusEntry.SENSOR_STREETPAVEMENT;
}
@Override
public String getTypeName() {
return String.class.getTypeName();
}
@Override
protected void calculateValue() {
World world = WorldModel.getInstance();
GeomStreet geom = world.getStreet(getPhysicalVehicle());
EnvStreet env = (EnvStreet) geom.getObject();
Street2D s2d = (Street2D) env;
this.value = s2d.getStreetPavement().toString();
}
public double getfrictionceofficient() {
Optional<Sensor> streetPavementSensor = this.getPhysicalVehicle().getSimulationVehicle().getSensorByType(getType());
double frictioncoefficient = 1;
if (streetPavementSensor.isPresent()) {
String streetPavement = (String) (streetPavementSensor.get().getValue());
switch (streetPavement) {
case "PAVED":
frictioncoefficient = 1;
break;
case "UNPAVED":
frictioncoefficient = 0.5;
break;
case "QUALITY":
frictioncoefficient = 1;
break;
case "STONE":
frictioncoefficient = 0.8;
break;
case "DIRT":
frictioncoefficient = 0.5;
break;
case "GRASS":
frictioncoefficient = 0.3;
break;
default:
frictioncoefficient = 0.3;
break;
}
}
return frictioncoefficient;
}
@Override
public String getValue() {
return this.value;
}
}
\ No newline at end of file
......@@ -49,4 +49,6 @@ public abstract class AbstractSensor implements Sensor {
*/
protected abstract void calculateValue();
}
\ No newline at end of file
......@@ -63,6 +63,8 @@ public class SensorFactory {
return new RightBackWheelDistanceToStreetSensor(this.physicalVehicle);
case SENSOR_STREETTYPE:
return new StreetTypeSensor(this.physicalVehicle);
case SENSOR_STREETPAVEMENT:
return new StreetPavementSensor(this.physicalVehicle);
case SENSOR_DAYNIGHT:
return new DayNightSensor(this.physicalVehicle);
case SENSOR_LEFT_FRONT_DISTANCE:
......
......@@ -44,6 +44,7 @@ public class SensorUtil {
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_RIGHT_BACK_WHEEL_DISTANCE_TO_STREET_SENSOR));
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_LEFT_BACK_WHEEL_DISTANCE_TO_STREET_SENSOR));
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_STREETTYPE));
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_STREETPAVEMENT));
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_DAYNIGHT));
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_LEFT_FRONT_DISTANCE));
physicalVehicle.getSimulationVehicle().addSensor(sensorFactory.getSensor(BusEntry.SENSOR_RIGHT_FRONT_DISTANCE));
......
......@@ -26,6 +26,8 @@ import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;
import org.apache.commons.math3.linear.*;
import simulation.environment.WorldModel;
import simulation.util.MathHelper;
//import sensors.abstractsensors.AbstractSensor;
import sensors.abstractsensors.*;
import java.util.AbstractMap;
import java.util.LinkedList;
import java.util.List;
......@@ -591,6 +593,7 @@ public class ModelicaPhysicalVehicle extends PhysicalVehicle{
// Take the wheel positions and get the frictions coefficients
//TODO: Let the physical vehicle look up the ground type and not only the weather
double frictionCoefficient = ((WorldModel.getInstance().isItRaining()) ? PhysicsEngine.ROAD_FRICTION_WET : PhysicsEngine.ROAD_FRICTION_DRY);
//frictionCoefficient = ;
vehicleDynamicsModel.setInput("mu_1", frictionCoefficient);
vehicleDynamicsModel.setInput("mu_2", frictionCoefficient);
vehicleDynamicsModel.setInput("mu_3", frictionCoefficient);
......
......@@ -24,6 +24,7 @@ import commons.simulation.PhysicalObject;
import commons.simulation.PhysicalObjectType;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.RealVector;
import simulation.environment.visualisationadapter.interfaces.EnvStreet;
import simulation.util.MathHelper;
import java.util.List;
import java.util.Map;
......@@ -41,6 +42,8 @@ public class PhysicsEngine{
/** Average road friction coefficient for wet roads (no unit) */
public static final double ROAD_FRICTION_WET = 0.4;
public static double ROAD_FRICTION = 1;//StreetPavementSensor.getfrictioncoefficient();//1; //simulation.vehicle.//EnvStreet.StreetPavements.DIRT; //this.getfrictioncoefficient();
private PhysicsEngine(){
// Private constructor to hide the implicit public one
}
......
Supports Markdown
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