Commit d494fa09 authored by Jean Meurice's avatar Jean Meurice
Browse files

Mat2 & Documentation & TaskRunner

parent 7ace069b
Pipeline #292303 passed with stage
in 39 seconds
......@@ -8,7 +8,7 @@
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<properties>
......
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.commons.controller.commons;
/**
* This enum is used to administrate the entries of the Bus.
*
* Created by Christoph Grüne on 13.01.2017.
*/
public enum BusEntry {
//***************************************************************************
// Navigation *
//***************************************************************************
NAVIGATION_DETAILED_PATH_WITH_MAX_STEERING_ANGLE("NAVIGATION_DETAILED_PATH_WITH_MAX_STEERING_ANGLE"),
// x coordinates of the planned trajectory, List<Double>
PLANNED_TRAJECTORY_X("PLANNED_TRAJECTORY_X"),
// y coordinates of the planned trajectory, List<Double>
PLANNED_TRAJECTORY_Y("PLANNED_TRAJECTORY_Y"),
//***************************************************************************
// Constants *
//***************************************************************************
CONSTANT_MAXIMUM_TOTAL_VELOCITY("CONSTANT_MAXIMUM_TOTAL_VELOCITY"),
CONSTANT_NUMBER_OF_GEARS("CONSTANT_NUMBER_OF_GEARS"),
CONSTANT_WHEELBASE("CONSTANT_WHEELBASE"),
CONSTANT_MAP_ADJACENCY_LIST("CONSTANT_MAP_ADJACENCY_LIST"),
CONSTANT_MOTOR_MAX_ACCELERATION("CONSTANT_MOTOR_MAX_ACCELERATION"),
CONSTANT_MOTOR_MIN_ACCELERATION("CONSTANT_MOTOR_MIN_ACCELERATION"),
CONSTANT_BRAKES_MAX_ACCELERATION("CONSTANT_BRAKES_MAX_ACCELERATION"),
CONSTANT_BRAKES_MIN_ACCELERATION("CONSTANT_BRAKES_MIN_ACCELERATION"),
CONSTANT_STEERING_MAX_ANGLE("CONSTANT_STEERING_MAX_ANGLE"),
CONSTANT_STEERING_MIN_ANGLE("CONSTANT_STEERING_MIN_ANGLE"),
CONSTANT_TRAJECTORY_ERROR("CONSTANT_TRAJECTORY_ERROR"),
//***************************************************************************
// Sensor Entries *
//***************************************************************************
SENSOR_VELOCITY("SENSOR_VELOCITY"),
SENSOR_STEERING("SENSOR_STEERING"),
SENSOR_DISTANCE_TO_RIGHT("SENSOR_DISTANCE_TO_RIGHT"),
SENSOR_DISTANCE_TO_LEFT("SENSOR_DISTANCE_TO_LEFT"),
SENSOR_LEFT_FRONT_WHEEL_DISTANCE_TO_STREET_SENSOR("SENSOR_LEFT_FRONT_WHEEL_DISTANCE_TO_STREET_SENSOR"),
SENSOR_RIGHT_FRONT_WHEEL_DISTANCE_TO_STREET_SENSOR("SENSOR_RIGHT_FRONT_WHEEL_DISTANCE_TO_STREET_SENSOR"),
SENSOR_LEFT_BACK_WHEEL_DISTANCE_TO_STREET_SENSOR("SENSOR_LEFT_BACK_WHEEL_DISTANCE_TO_STREET_SENSOR"),
SENSOR_RIGHT_BACK_WHEEL_DISTANCE_TO_STREET_SENSOR("SENSOR_RIGHT_BACK_WHEEL_DISTANCE_TO_STREET_SENSOR"),
SENSOR_GPS_COORDINATES("SENSOR_GPS_COORDINATES"),
SENSOR_CURRENT_SURFACE("SENSOR_CURRENT_SURFACE"),
SENSOR_WEATHER("SENSOR_WEATHER"),
SENSOR_CAMERA("SENSOR_CAMERA"),
SENSOR_COMPASS("SENSOR_COMPASS"),
SENSOR_OBSTACLE("SENSOR_OBSTACLE"),
SENSOR_VANISHINGPOINT("SENSOR_VANISHING"),
SENSOR_LANE("SENSOR_LANE"),
SENSOR_STREETTYPE("SENSOR_STREETTYPE"),
SENSOR_DAYNIGHT("SENSOR_DAYNIGHT"),
SENSOR_LEFT_FRONT_DISTANCE("SENSOR_LEFT_FRONT_DISTANCE"),
SENSOR_RIGHT_FRONT_DISTANCE("SENSOR_RIGHT_FRONT_DISTANCE"),
//***************************************************************************
//* Actuator Entries *
//***************************************************************************
//Target Value
ACTUATOR_ENGINE("ACTUATOR_ENGINE"),
//Current Value
ACTUATOR_ENGINE_CURRENT("ACTUATOR_ENGINE_CURRENT"),
//Target Value
ACTUATOR_BRAKE("ACTUATOR_BRAKE"),
//Current Value
ACTUATOR_BRAKE_CURRENT("ACTUATOR_BRAKE_CURRENT"),
//Target Value
ACTUATOR_STEERING("ACTUATOR_STEERING"),
//Current Value
ACTUATOR_STEERING_CURRENT("ACTUATOR_STEERING_CURRENT"),
//Target Value
ACTUATOR_GEAR("ACTUATOR_GEAR"),
//Current Value
ACTUATOR_GEAR_CURRENT("ACTUATOR_GEAR_CURRENT"),
//Target Value
ACTUATOR_CLUTCH("ACTUATOR_CLUTCH"),
//Current Value
ACTUATOR_CLUTCH_CURRENT("ACTUATOR_CLUTCH_CURRENT"),
//Target Value
ACTUATOR_THROTTLE("ACTUATOR_THROTTLE"),
//Current Value
ACTUATOR_THROTTLE_CURRENT("ACTUATOR_THROTTLE_CURRENT"),
//***************************************************************************
//* Computervision Entries *
//***************************************************************************
COMPUTERVISION_VANISHING_POINT("COMPUTERVISION_VANISHING_POINT"),
COMPUTERVISION_DETECTED_CARS("COMPUTERVISION_DETECTED_CARS"),
COMPUTERVISION_TRACKED_CARS("COMPUTERVISION_TRACKED_CARS"),
COMPUTERVISION_TRACKED_PEDESTRIANS("COMPUTERVISION_DETECTED_PEDESTRIANS"),
COMPUTERVISION_DETECTED_PEDESTRIANS("COMPUTERVISION_DETECTED_PEDESTRIANS"),
COMPUTERVISION_DETECTED_LANES("COMPUTERVISION_DETECTED_LANES"),
COMPUTERVISION_DETECTED_SIGNS("COMPUTERVISION_DETECTED_SIGNS"),
VEHICLE_MAX_TEMPORARY_ALLOWED_VELOCITY("VEHICLE_MAX_TEMPORARY_ALLOWED_VELOCITY"),
SIMULATION_DELTA_TIME("SIMULATION_DELTA_TIME"),
ENVIRONMENT("ENVIRONMENT");
/**
* this variable contains the name of the entry
*/
private final String name;
/**
* constructor for a bus entry
*
* @param name the name of the entry
*/
private BusEntry(String name) {
this.name = name;
}
/**
* Getter of the name attribute
*
* @return the name of the entry
*/
public String toString() {
return this.name;
}
}
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.commons.controller.commons;
/**
* This enum is used to administrate the entries of the NavgationBlock.
*
* Created by Christoph on 04.03.2017.
*/
public enum NavigationEntry {
//***************************************************************************
//* Navigation Entries *
//***************************************************************************
MAP_ADJACENCY_LIST("MAP_ADJACENCY_LIST"),
TARGET_NODE("TARGET_NODE"),
GPS_COORDINATES("GPS_COORDINATES"),
CONSTANT_WHEELBASE("CONSTANT_WHEELBASE"),
DETAILED_PATH_WITH_MAX_STEERING_ANGLE("DETAILED_PATH_WITH_MAX_STEERING_ANGLE");
/**
* this variable contains the name of the entry
*/
private final String name;
/**
* constructor for a navigation entry
*
* @param name the name of the entry
*/
private NavigationEntry(String name) {
this.name = name;
}
/**
* Getter of the name attribute
*
* @return the name of the entry
*/
public String toString() {
return this.name;
}
}
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.commons.controller.commons;
/**
* This enum administrates all surfaces
*
* Created by Christoph Grüne on 14.01.2017.
*/
public enum Surface {
//Asphalt(15.0, -10.0, 2.0);
Asphalt(2.0, 0.0, 0.0);
/**
*
*/
private Double parameterA;
private Double parameterB;
private Double parameterC;
Surface(Double parameterA, Double parameterB, Double parameterC) {
this.parameterA = parameterA;
this.parameterB = parameterB;
this.parameterC = parameterC;
}
public Double getParameterA() {
return parameterA.doubleValue();
}
public Double getParameterB(double rainCoefficient) {
switch(this) {
case Asphalt : parameterBAsphalt(rainCoefficient); break;
}
return parameterB.doubleValue();
}
public Double getParameterC() {
return parameterC.doubleValue();
}
private Double parameterBAsphalt(double rainCoefficient) {
if(rainCoefficient < 0.5) {
return parameterB.doubleValue();
} else {
return 2 * parameterB.doubleValue();
}
}
}
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.commons.controller.commons;
import org.apache.commons.math3.linear.RealVector;
/**
* this class provides all information for a vertex data structur for a general graph.
* It is widely used in this function block setting.
*
* Created by Christoph Grüne on 22.12.2016.
*/
public class Vertex {
private Long id;
private Long osmId;
private Double maximumSteeringAngle;
private RealVector position;
private boolean intersectionNode = false;
public Vertex(Long id, Long osmID, RealVector position, Double maximumSteeringAngle) {
this.id = id;
this.osmId = osmID;
this.position = position;
this.maximumSteeringAngle = maximumSteeringAngle;
}
/**
* copy constructor for Vertex
*/
public Vertex copy() {
return new Vertex(this.id.longValue(), this.osmId.longValue(), this.position.copy(), this.maximumSteeringAngle.doubleValue());
}
/**
* Setter for maximumVelocity
*
* @param maximumSteeringAngle the new maximumVelocity
*/
public void setMaximumSteeringAngle(double maximumSteeringAngle) {
this.maximumSteeringAngle = maximumSteeringAngle;
}
/**
* Function that sets intersectionNode
*
* @param intersectionNode New value for intersectionNode
*/
public void setIntersectionNode(boolean intersectionNode) {
this.intersectionNode = intersectionNode;
}
/**
* Function that returns intersectionNode
*
* @return Value for intersectionNode
*/
public boolean isIntersectionNode() {
return intersectionNode;
}
/**
* Getter for the ID of this vertex
*
* @return the ID
*/
public Long getId() {
return new Long(id.longValue());
}
/**
* Setter for vertex ID
*
* @param id
*/
public void setId(long id) {
this.id = id;
}
/**
* Getter for the OSM ID of this vertex
*
* @return the OSM ID
*/
public Long getOsmId() {
return new Long(osmId.longValue());
}
/**
* Getter for the maximal velocity one can drive at this vertex
*
* @return the maximal velocity
*/
public Double getMaximumSteeringAngle() {
return new Double(maximumSteeringAngle.doubleValue());
}
/**
* Getter for the position of this vertex
*
* @return the position
*/
public RealVector getPosition() {
return position.copy();
}
/**
* Test for the equality of two vertices. If all attributes are the same the vertices are considered to be equal.
*
* @param obj the object to test
* @return if the objects are equal
*/
@Override
public boolean equals(Object obj) {
if(obj.getClass() != this.getClass()) {
return false;
}
Vertex otherVertex = (Vertex) obj;
if(!otherVertex.getMaximumSteeringAngle().equals(this.getMaximumSteeringAngle())) {
return false;
} else if(!otherVertex.getOsmId().equals(this.getOsmId())) {
return false;
} else if(!otherVertex.getId().equals(this.getId())) {
return false;
} else if (!otherVertex.getPosition().equals(this.getPosition())) {
return false;
}
return true;
}
}
......@@ -8,6 +8,7 @@ package de.rwth.montisim.commons.controller.commons;
*
* @author Christoph Grüne
*/
@Deprecated
public enum BusEntry {
// // ***************************************************************************
......
......@@ -8,6 +8,7 @@ package de.rwth.montisim.commons.controller.commons;
*
* @author Christoph Grüne
*/
@Deprecated
public enum NavigationEntry {
// // ***************************************************************************
// // * Navigation Entries *
......
......@@ -4,6 +4,7 @@ package de.rwth.montisim.commons.controller.commons;
/**
* This enum administrates all surfaces
*/
@Deprecated
public enum Surface {
// Asphalt(15.0, -10.0, 2.0);
Asphalt(2.0, 0.0, 0.0);
......
......@@ -7,6 +7,7 @@ import de.rwth.montisim.commons.utils.Vec3;
* Provides all information for a vertex data structure for a general graph. It
* is widely used in this function block setting.
*/
@Deprecated
public class Vertex {
public long id;
......
......@@ -5,14 +5,8 @@ import java.util.Map;
/**
* This is an interface for the DataBus.
*
* Created by Christoph Grüne on 30.12.2016.
<<<<<<< HEAD:src/main/java/de/rwth/monticore/EmbeddedMontiArc/simulators/commons/controller/interfaces/Bus.java
=======
*
* @author Christoph Grüne
>>>>>>> ComponentRework:src/main/java/de/rwth/montisim/commons/controller/interfaces/Bus.java
*/
@Deprecated
public interface Bus {
/**
......
......@@ -6,12 +6,6 @@ import java.util.Map;
/**
* This interface provides the basic structures of a function block
*
* Created by Christoph Grüne on 09.12.2016.
<<<<<<< HEAD:src/main/java/de/rwth/monticore/EmbeddedMontiArc/simulators/commons/controller/interfaces/FunctionBlockInterface.java
=======
*
* @author Christoph Grüne
>>>>>>> ComponentRework:src/main/java/de/rwth/montisim/commons/controller/interfaces/FunctionBlockInterface.java
*/
public interface FunctionBlockInterface {
......
......@@ -8,7 +8,7 @@ public class ArrayType extends DataType {
}
public DataType baseType;
public Dimensionality dimension;
///Number of elems for "ARRAY", max size for "DYNAMIC"
/** Number of elems for "ARRAY", max size for "DYNAMIC". */
public int sizeOrMaxSize;
public ArrayType(DataType baseType, Dimensionality dim, int sizeOrMaxSize){
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.commons.dynamicinterface;
/**
* Reflection class for the types of Messages sent in the simulation.
*/
public class DataType {
public static final DataType DOUBLE = new DataType(Type.DOUBLE);
public static final DataType FLOAT = new DataType(Type.FLOAT);
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.commons.dynamicinterface;
public class PortInformation {
public static enum PortDirection {
INPUT,
OUTPUT
}
private String name;
private DataType type;
private PortDirection direction;
public PortInformation(String name, DataType type, PortDirection dir){
this.name = name;
this.type = type;
this.direction = dir;
}
public String getName(){
return name;
}
public DataType getType(){
return type;
}
public PortDirection getDirection() {
return direction;
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.util.HashMap;
// TODO use a vector and index based entries
public class StructType extends DataType {
public String name;
public HashMap<String, DataType> components;
......@@ -14,7 +15,6 @@ public class StructType extends DataType {
/**
* Adds a field to the struct type.
* Note: takes ownership of the name and type.
*/
public void addComponent(String fieldName, DataType fieldType){
components.put(fieldName, fieldType);
......
......@@ -9,13 +9,11 @@ import de.rwth.montisim.commons.simulation.TimeUpdate;
import de.rwth.montisim.commons.simulation.Updatable;
/**
* Abstract class for a discrete event simulation based on scheduled events This
* class implements the SimulationLoopNotifiable interface to be combined with
* vehicle simulator
* Abstract class for a discrete event simulation based on scheduled events.
*/
public abstract class DiscreteEventSimulator<EventType, T extends DiscreteEvent<EventType>> implements Updatable {
/** Comparator for events. Sorts in ascending order of event time*/
/** Comparator for events. Sorts in ascending order of event time. */
private static final DiscreteEvent.DiscreteEventComparator listComparator = new DiscreteEvent.DiscreteEventComparator();
/** point of time of simulation */
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.commons.simulation;
/// Implemented by Simulation objects that need special destruction code (ex: Native Bound code cleanup)
/** Implemented by Simulation objects that need special destruction code (ex: Native Bound code cleanup) */
public interface Destroyable {
void destroy();
}
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.commons.simulation;
/**
* Interface for registering different SimulationObject components by the simulator.
*/
public interface ISimulator {
void registerStaticObject(StaticObject staticObject);
......@@ -11,4 +14,6 @@ public interface ISimulator {
void registerUpdatable(Updatable updatable);
void registerDestroyable(Destroyable destroyable);
void registerTaskRunner(TaskRunner runner);
}
\ No newline at end of file
......@@ -3,6 +3,11 @@ package de.rwth.montisim.commons.simulation;
import de.rwth.montisim.commons.dynamicinterface.DataType;
/**
* Wrapper around an Object that represents a physical value inside
* the simulation. The goal is that multiple users can read and set the value.
* The getter can be overloaded to hide more complex reading mechanisms for the users.
*/
public class PhysicalValue {
protected Object value;
public final String name;
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.commons.simulation;