Commit 3fda084f authored by Jean Meurice's avatar Jean Meurice
Browse files

Merge branch 'sim_dev' into 'master'

Sim dev

See merge request !10
parents 2609de0c 9cf958c3
Pipeline #571284 passed with stage
in 1 minute and 58 seconds
{
"name": "java_autopilot",
"map_name": "aachen",
"cars": [
{
"name": "Car1",
"start_pos": [ -117.54, 67.15 ],
"start_orientation": 30.0,
"task": {
"goals": [
{
"type": "path",
"ltl_operator": "eventually",
"path": [ [-70.16, 105.11] ],
"range": 5
}
]
},
"components": [
{
"type": "constant_bus",
"connected_to": [
"SteeringActuator",
"BrakingActuator",
"GasActuator",
"TrueVelocitySensor",
"TruePositionSensor",
"TrueCompassSensor",
"Navigation",
"JavaAutopilot"
]
},
{
"type": "actuator",
"name": "SteeringActuator",
"physical_value_name": "steering",
"change_rate": 60.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "BrakingActuator",
"physical_value_name": "braking",
"change_rate": 10.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "GasActuator",
"physical_value_name": "gas",
"sensor": { "type": "sensor" }
},
{
"type": "sensor",
"name": "TrueVelocitySensor",
"physical_value_name": "true_velocity"
},
{
"type": "sensor",
"name": "TruePositionSensor",
"physical_value_name": "true_position"
},
{
"type": "sensor",
"name": "TrueCompassSensor",
"physical_value_name": "true_compass"
},
{ "type": "navigation" },
{
"type": "java_autopilot",
"name": "JavaAutopilot",
"maxVehicleAccel": 7.460690450979396
}
]
},
{
"name": "Car2",
"start_pos": [ -70.16, 105.11 ],
"start_orientation": -120.0,
"task": {
"goals": [
{
"type": "path",
"ltl_operator": "eventually",
"path": [ [-117.54, 67.15] ],
"range": 5
}
]
},
"components": [
{
"type": "constant_bus",
"connected_to": [
"SteeringActuator",
"BrakingActuator",
"GasActuator",
"TrueVelocitySensor",
"TruePositionSensor",
"TrueCompassSensor",
"Navigation",
"JavaAutopilot"
]
},
{
"type": "actuator",
"name": "SteeringActuator",
"physical_value_name": "steering",
"change_rate": 60.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "BrakingActuator",
"physical_value_name": "braking",
"change_rate": 10.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "GasActuator",
"physical_value_name": "gas",
"sensor": { "type": "sensor" }
},
{
"type": "sensor",
"name": "TrueVelocitySensor",
"physical_value_name": "true_velocity"
},
{
"type": "sensor",
"name": "TruePositionSensor",
"physical_value_name": "true_position"
},
{
"type": "sensor",
"name": "TrueCompassSensor",
"physical_value_name": "true_compass"
},
{ "type": "navigation" },
{
"type": "java_autopilot",
"name": "JavaAutopilot",
"maxVehicleAccel": 7.460690450979396
}
]
}
]
}
\ No newline at end of file
{
"name": "java_autopilot",
"map_name": "aachen",
"max_duration": [60,0],
"tick_duration": [0,10000000],
"cars": [
{
"start_pos": [ -56.74, 16.01 ],
"start_orientation": -30.0,
"task": {
"goals": [
{
"type": "path",
"ltl_operator": "eventually",
"path": [ [-63.83, -171.96] ],
"range": 5
}
]
},
"components": [
{
"type": "constant_bus",
"connected_to": [
"SteeringActuator",
"BrakingActuator",
"GasActuator",
"TrueVelocitySensor",
"TruePositionSensor",
"TrueCompassSensor",
"BatterySensor",
"Navigation",
"Lidar",
"SpeedLimit",
"JavaAutopilot"
]
},
{
"type": "actuator",
"name": "SteeringActuator",
"physical_value_name": "steering",
"change_rate": 60.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "BrakingActuator",
"physical_value_name": "braking",
"change_rate": 10.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "GasActuator",
"physical_value_name": "gas",
"sensor": { "type": "sensor" }
},
{
"type": "sensor",
"name": "TrueVelocitySensor",
"physical_value_name": "true_velocity"
},
{
"type": "sensor",
"name": "TruePositionSensor",
"physical_value_name": "true_position"
},
{
"type": "sensor",
"name": "TrueCompassSensor",
"physical_value_name": "true_compass"
},
{
"type": "sensor",
"name": "BatterySensor",
"physical_value_name": "battery_level"
},
{ "type": "navigation" },
{ "type": "lidar" },
{ "type": "speed_limit" },
{
"type": "java_autopilot",
"name": "JavaAutopilot",
"maxVehicleAccel": 7.460690450979396
}
]
}
]
}
File mode changed from 100644 to 100755
{
"name": "TC-1.1.1",
"map_name": "aachen",
"modules": [
{
"type": "simple_network",
"transmission_time": [0, 100000000]
}
],
"cars": [
{
"name": "Vehicle1",
"start_pos": [ -443, -170 ],
"task": {
"goals": [
{
"type": "path",
"ltl_operator": "eventually",
"path": [ [-81, -150.32] ],
"range": 5
}
]
},
"components": [
{
"type": "constant_bus",
"connected_to": [
"SteeringActuator",
"BrakingActuator",
"GasActuator",
"TrueVelocitySensor",
"TruePositionSensor",
"TrueCompassSensor",
"Navigation",
"SimpleCommunicationGateway",
"Computer",
"Lidar",
"SpeedLimit"
]
},
{
"type": "actuator",
"name": "SteeringActuator",
"physical_value_name": "steering",
"change_rate": 100.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "BrakingActuator",
"physical_value_name": "braking",
"change_rate": 10.0,
"sensor": { "type": "sensor" }
},
{
"type": "actuator",
"name": "GasActuator",
"physical_value_name": "gas",
"sensor": { "type": "sensor" }
},
{
"type": "sensor",
"name": "TrueVelocitySensor",
"physical_value_name": "true_velocity"
},
{
"type": "sensor",
"name": "TruePositionSensor",
"physical_value_name": "true_position"
},
{
"type": "sensor",
"name": "TrueCompassSensor",
"physical_value_name": "true_compass"
},
{ "type": "navigation" },
{ "type": "speed_limit" },
{ "type": "lidar" },
{ "type": "simple_communication_gateway" },
{
"type": "computer",
"name": "Computer",
"software_name": "ema_autopilot_lib",
"backend": {
"type": "direct",
"remote": {
"type": "tcp",
"host": "::1",
"port": 4567
}
},
"time_model": {
"type": "constant"
},
"cycle_duration": [0,100000000],
"json_data_exchange": true
}
]
}
]
}
......@@ -35,7 +35,7 @@
"type": "actuator",
"name": "SteeringActuator",
"physical_value_name": "steering",
"change_rate": 60.0,
"change_rate": 100.0,
"sensor": { "type": "sensor" }
},
{
......@@ -67,6 +67,9 @@
"physical_value_name": "true_compass"
},
{ "type": "navigation" },
{ "type": "speed_limit" },
{ "type": "lidar" },
{ "type": "simple_communication_gateway" },
{
"type": "rl_autopilot",
"name": "RLAutopilot",
......
......@@ -13,7 +13,7 @@
{
"type": "path",
"ltl_operator": "eventually",
"path": [ [-63.83, -171.96] ],
"path": [ [-70.16, 105.11] ],
"range": 5
}
]
......@@ -84,7 +84,7 @@
{
"type": "path",
"ltl_operator": "eventually",
"path": [ [-63.83, -171.96] ],
"path": [ [-117.54, 67.15] ],
"range": 5
}
]
......
......@@ -27,6 +27,7 @@
"TrueVelocitySensor",
"TruePositionSensor",
"TrueCompassSensor",
"BatterySensor",
"Navigation",
"RLAutopilot"
]
......@@ -66,7 +67,14 @@
"name": "TrueCompassSensor",
"physical_value_name": "true_compass"
},
{
"type": "sensor",
"name": "BatterySensor",
"physical_value_name": "battery_level"
},
{ "type": "navigation" },
{ "type": "lidar" },
{ "type": "speed_limit" },
{
"type": "rl_autopilot",
"name": "RLAutopilot",
......
......@@ -9,13 +9,13 @@
<groupId>montisim</groupId>
<artifactId>basic-simulator</artifactId>
<version>2.1.11</version>
<version>2.2.0</version>
<name>basic-simulator</name>
<properties>
<!-- USE THESE TO SET THE VERSIONS OF THE DEPENDENCIES FOR ALL THE SUB-PROJECTS -->
<montisim.hardware_emulator.version>2.0.12</montisim.hardware_emulator.version>
<montisim.hardware_emulator.version>2.0.13</montisim.hardware_emulator.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -6,54 +6,28 @@ package de.rwth.montisim.basic_simulator;
import de.rwth.montisim.basic_simulator.filesystem.FileSystem;
import de.rwth.montisim.basic_simulator.gui.Browser;
import de.rwth.montisim.commons.map.Pathfinding;
import de.rwth.montisim.commons.simulation.TaskStatus;
import de.rwth.montisim.commons.utils.LibraryService;
import de.rwth.montisim.hardware_emulator.CppBridge;
import de.rwth.montisim.hardware_emulator.TypedHardwareEmu;
import de.rwth.montisim.simulation.environment.world.World;
import de.rwth.montisim.simulation.environment.osmmap.*;
import de.rwth.montisim.simulation.environment.osmmap.OsmMap;
import de.rwth.montisim.simulation.environment.osmmap.OsmToWorldLoader;
import de.rwth.montisim.simulation.environment.pathfinding.PathfindingImpl;
import de.rwth.montisim.simulation.environment.world.World;
import de.rwth.montisim.simulation.simulator.*;
import de.rwth.montisim.simulation.simulator.visualization.ui.UIInfo;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
public class App
{
static {
TypedHardwareEmu.registerTypedHardwareEmu();
}
public static void main( String[] args )
public static void main( String[] args ) throws Exception
{
UIInfo.antialiasing = true;
/* System.out.println("Looks and Feels:");
UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo look : looks) {
System.out.println(look.getClassName());
} */
try {
/*
javax.swing.plaf.metal.MetalLookAndFeel
javax.swing.plaf.nimbus.NimbusLookAndFeel
com.sun.java.swing.plaf.motif.MotifLookAndFeel
com.sun.java.swing.plaf.gtk.GTKLookAndFeel
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
*/
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
} catch (IllegalAccessException ex) {
ex.printStackTrace();
} catch (InstantiationException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
TypedHardwareEmu.registerTypedHardwareEmu();
initUISettings();
try {
......@@ -142,7 +116,7 @@ public class App
}
else{
System.out.println("Starting simulation with scenario: " + scenario_name);
runSimulation(scenario_name);
SimulationCLI.runSimulationFromFile(scenario_name);
}
return;
}
......@@ -157,31 +131,8 @@ public class App
}
protected static void runSimulation(String path){
try {
// Create simulator from scenario file
File scenarioFile = new File(path);
SimulationConfig config = SimulationConfig.fromFile(scenarioFile);
File mapPath = new File(config.map_name + ".osm");
OsmMap map = new OsmMap(config.map_name, mapPath);
World world = new OsmToWorldLoader(map).getWorld();
Pathfinding pathfinding = new PathfindingImpl(world);
Simulator simulator = config.build(world, pathfinding, map);
// Run simulation
SimulationLoop simLoop = new SimulationLoop(simulator, config);
TaskStatus res = simLoop.run();
if (res == TaskStatus.SUCCEEDED) {
System.out.println("Simulation SUCCEEDED.");
} else {
System.out.println("Simulation FAILED.");
System.exit(-1);
}
} catch (Exception e1) {
e1.printStackTrace();
return;
}
}
protected static void runRLSimulation(String path, boolean distributed, boolean randomize, boolean play){
try {
......@@ -203,6 +154,35 @@ public class App
}
}
static void initUISettings() {
UIInfo.antialiasing = true;
/* System.out.println("Looks and Feels:");
UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo look : looks) {
System.out.println(look.getClassName());
} */
try {
/*
javax.swing.plaf.metal.MetalLookAndFeel
javax.swing.plaf.nimbus.NimbusLookAndFeel
com.sun.java.swing.plaf.motif.MotifLookAndFeel
com.sun.java.swing.plaf.gtk.GTKLookAndFeel
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
*/
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
} catch (IllegalAccessException ex) {
ex.printStackTrace();
} catch (InstantiationException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = App.class.getResource(path);
......
......@@ -83,8 +83,10 @@ public class Browser extends JFrame implements TreeSelectionListener {
current_vis = null;
default_category = new_category(Category.CategoryType.NONE, new DefaultVis());
new_category(Category.CategoryType.AUTOPILOTS, null);
new_category(Category.CategoryType.MAPS, new MapVis(file_system));
new_category(Category.CategoryType.SCENARIOS, new ScenarioVis(file_system));
MapVis mapVis = new MapVis(file_system);
new_category(Category.CategoryType.MAPS, mapVis);
ScenarioVis scenarioVis = new ScenarioVis(file_system);
new_category(Category.CategoryType.SCENARIOS, scenarioVis);
new_category(Category.CategoryType.RESULTS, new ResultVis(file_system));
new_category(Category.CategoryType.SIMULATIONS, new SimulationVis());
......@@ -99,55 +101,39 @@ public class Browser extends JFrame implements TreeSelectionListener {
JPanel interm = new JPanel();
Box box = Box.createVerticalBox();
JCheckBox checkBox1 = new JCheckBox("Antialiasing", UIInfo.antialiasing);
checkBox1.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
UIInfo.antialiasing = e.getStateChange() == 1;
repaint();
}
addOption(box, "Antialiasing", UIInfo.antialiasing, e -> {
UIInfo.antialiasing = e.getStateChange() == 1;