Commit 05ef1a62 authored by Jean Meurice's avatar Jean Meurice
Browse files

Collisions Updates

parent 56b88f2e
{
"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
}
]
}
]
}
{
"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
}
]
}
]
}
......@@ -9,13 +9,13 @@
<groupId>montisim</groupId>
<artifactId>basic-simulator</artifactId>
<version>2.1.10</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.11</montisim.hardware_emulator.version>
<montisim.hardware_emulator.version>2.0.13</montisim.hardware_emulator.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -5,30 +5,41 @@ 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.pathfinding.PathfindingImpl;
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;
public class App
{
static {
public static void main( String[] args ) throws Exception
{
TypedHardwareEmu.registerTypedHardwareEmu();
initUISettings();
CppBridge.init("{\"softwares_folder\": \"autopilots\"}");
if (args.length > 0){
// CLI Mode (no UI)
String scenario_name = args[0];
System.out.println("Starting simulation with scenario: " + scenario_name);
SimulationCLI.runSimulationFromFile(scenario_name);
} else {
FileSystem fileSystem = new FileSystem(LibraryService.getWorkingDirectory());
new Browser(fileSystem);
fileSystem.check_updates(); //Infinite loop until gui calls System.exit()
}
}
public static void main( String[] args )
{
static void initUISettings() {
UIInfo.antialiasing = true;
/* System.out.println("Looks and Feels:");
UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels();
......@@ -53,55 +64,8 @@ public class App
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
try {
CppBridge.init("{\"softwares_folder\": \"autopilots\"}");
FileSystem fileSystem = new FileSystem(LibraryService.getWorkingDirectory());
if (args.length > 0){
String scenario_name = args[0];
System.out.println("Starting simulation with scenario: " + scenario_name);
runSimulation(scenario_name);
return;
}
new Browser(fileSystem);
fileSystem.check_updates(); //Infinite loop until gui calls System.exit()
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
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 ImageIcon createImageIcon(String path) {
java.net.URL imgURL = App.class.getResource(path);
......
......@@ -80,8 +80,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());
......@@ -105,16 +107,43 @@ public class Browser extends JFrame implements TreeSelectionListener {
checkBox1.setBackground(Color.WHITE);
interm.add(checkBox1);
JCheckBox checkBox2 = new JCheckBox("Show Road Segments", UIInfo.showSegments);
JCheckBox checkBox2 = new JCheckBox("Road Segments", UIInfo.showSegments);
checkBox2.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
UIInfo.showSegments = e.getStateChange() == 1;
scenarioVis.viewer.setDirty();
mapVis.viewer.setDirty();
repaint();
}
});
checkBox2.setBackground(Color.WHITE);
interm.add(checkBox2);
JCheckBox checkBox3 = new JCheckBox("Building Debug", UIInfo.showBuildingDebug);
checkBox3.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
UIInfo.showBuildingDebug = e.getStateChange() == 1;
scenarioVis.viewer.setDirty();
mapVis.viewer.setDirty();
repaint();
}
});
checkBox3.setBackground(Color.WHITE);
interm.add(checkBox3);
JCheckBox checkBox4 = new JCheckBox("AABBs", UIInfo.showAABBs);
checkBox4.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
UIInfo.showAABBs = e.getStateChange() == 1;
scenarioVis.viewer.setDirty();
mapVis.viewer.setDirty();
repaint();
}
});
checkBox4.setBackground(Color.WHITE);
interm.add(checkBox4);
interm.setBackground(Color.WHITE);
JPanel optionPanel = new JPanel();
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
......
......@@ -5,7 +5,7 @@ package de.rwth.montisim.basic_simulator.gui;
import de.rwth.montisim.basic_simulator.filesystem.FileSystem;
import de.rwth.montisim.commons.map.Pathfinding;
import de.rwth.montisim.commons.simulation.TaskStatus;
import de.rwth.montisim.simulation.commons.TaskStatus;
import de.rwth.montisim.commons.simulation.TimeUpdate;
import de.rwth.montisim.commons.utils.IPM;
import de.rwth.montisim.commons.utils.Vec2;
......@@ -35,6 +35,7 @@ import java.time.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
public class ScenarioVis extends SimVis implements SimulationRunner {
private static final long serialVersionUID = 7903217594061845406L;
......@@ -104,7 +105,7 @@ public class ScenarioVis extends SimVis implements SimulationRunner {
viewer.addRenderer(new PathfinderRenderer(pathfinding));
// Init CarRenderers and find view for all Vehicles
Collection<Vehicle> vehicles = simulator.getVehicles();
Collection<Vehicle> vehicles = simulator.getVehicles().collect(Collectors.toCollection(ArrayList::new));
setView(vehicles);
for (Vehicle v : vehicles) {
......
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