diff --git a/install/autopilots/TestEMADLAP.dll b/install/autopilots/TestEMADLAP.dll new file mode 100644 index 0000000000000000000000000000000000000000..0949f0f0d1dcc8937e3fddbca1531252496b9fd8 Binary files /dev/null and b/install/autopilots/TestEMADLAP.dll differ diff --git a/install/autopilots/TestEMAMAP.dll b/install/autopilots/TestEMAMAP.dll new file mode 100644 index 0000000000000000000000000000000000000000..3049bd01497f64db683002fd448f6301d24f63f3 Binary files /dev/null and b/install/autopilots/TestEMAMAP.dll differ diff --git a/install/scenarios/minimal.json b/install/cli_test.json similarity index 75% rename from install/scenarios/minimal.json rename to install/cli_test.json index 528f9c2ac568b66b905852d1da08e71a6a8bd7dc..7b22792cb88f69dd4d444906758226a6d6a88314 100644 --- a/install/scenarios/minimal.json +++ b/install/cli_test.json @@ -1,10 +1,22 @@ { - "name": "new_basic", - "map_name": "aachen", + "name": "cli_test", + "map_name": "maps/aachen", + "max_duration": [60,0], + "tick_duration": [0,10000000], "cars": [ { - "start_coords": [ 0, 0 ], - "end_coords": [ -63.83, -171.96 ], + "start_pos": [ -123.09, 21.64 ], + "start_orientation": -30.0, + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, "components": [ { "type": "constant_bus" }, { diff --git a/install/cli_test_fail.json b/install/cli_test_fail.json new file mode 100644 index 0000000000000000000000000000000000000000..d84e4e0bd7cd62b0b4393640a3f52cf54b873066 --- /dev/null +++ b/install/cli_test_fail.json @@ -0,0 +1,65 @@ +{ + "name": "cli_test_fail", + "map_name": "maps/aachen", + "max_duration": [5,0], + "tick_duration": [0,10000000], + "cars": [ + { + "start_pos": [ -123.09, 21.64 ], + "start_orientation": -30.0, + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, + "components": [ + { "type": "constant_bus" }, + { + "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", + "maxVehicleAccel": 7.460690450979396 + } + ] + } + ] +} \ No newline at end of file diff --git a/install/scenarios/EMA.json b/install/scenarios/EMA.json deleted file mode 100644 index ad966d15d74bc2886e894960825bc5e07500b300..0000000000000000000000000000000000000000 --- a/install/scenarios/EMA.json +++ /dev/null @@ -1,223 +0,0 @@ -{ - "name": "new_basic", - "map_name": "aachen", - "cars": [ - { - "name": "TestVehicle", - "start_coords": [ - 0, - 0 - ], - "end_coords": [ - -63.83, - -171.96 - ], - "body": { - "mass": 1642.0, - "length": 4.971, - "width": 1.87, - "height": 1.383, - "center_of_gravity_height": 0.34575 - }, - "wheels": { - "diameter": 0.6612, - "width": 0.255, - "front_wheel_axis_offset": 1.0, - "max_turning_angle": 30.0, - "front_track_width": 1.57988, - "back_track_dist": 1.60274, - "wheelbase": 2.812, - "wheelbase_offset": 0.0 - }, - "powertrain": { - "type": "electrical", - "traction": "rear", - "braking": "front", - "max_braking_force": 5000.0, - "motor": { - "motor_efficiency": 0.7, - "regen_efficiency": 0.5, - "motor_peek_torque": 450.0 - }, - "battery": { - "type": "infinite", - "capacity": 1.8E8, - "critical_charge": 10.0 - }, - "transmission_ratio": 9.0 - }, - "physics": { - "type": "rigidbody" - }, - "components": [ - { - "type": "actuator", - "name": "SteeringActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "steering", - "change_rate": 60.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } - }, - { - "type": "actuator", - "name": "BrakingActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "braking", - "change_rate": 10.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } - }, - { - "type": "actuator", - "name": "GasActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "gas", - "change_rate": "Infinity", - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } - }, - { - "type": "sensor", - "name": "TrueVelocitySensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_velocity", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "sensor", - "name": "TruePositionSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_position", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "sensor", - "name": "TrueCompassSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_compass", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "navigation", - "name": "Navigation", - "priority": {}, - "buses": [ - "DefaultBus" - ] - }, - { - "type": "constant_bus", - "name": "DefaultBus", - "priority": {}, - "mode": "instant", - "rate": 0.0 - }, - { - "type": "computer", - "software_name": "BasicAutopilot", - "emulator_type": "emu", - "os": "windows", - "time_model": { - "type": "models", - "cpu_frequency": 4000000000, - "memory_frequency": 2500000000, - "caches": [ - {"type": "I", "level": 1, "size": 262144, "read_ticks": 4, "write_ticks": 4}, - {"type": "D", "level": 1, "size": 262144, "read_ticks": 4, "write_ticks": 4}, - {"type": "shared", "level": 2, "size": 2097152, "read_ticks": 6, "write_ticks": 6}, - {"type": "shared", "level": 3, "size": 12582912, "read_ticks": 40, "write_ticks": 40} - ] - } - } - ] - } - ] -} \ No newline at end of file diff --git a/install/scenarios/EMADL_native.json b/install/scenarios/EMADL_native.json new file mode 100644 index 0000000000000000000000000000000000000000..330ec14d4d8832849abc7081ae89a148dae74a30 --- /dev/null +++ b/install/scenarios/EMADL_native.json @@ -0,0 +1,68 @@ +{ + "name": "EMADL_native", + "map_name": "aachen", + "cars": [ + { + "name": "EMADLTestVehicle", + "start_pos": [ 0, 0 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, + "components": [ + { "type": "constant_bus" }, + { + "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": "computer", + "software_name": "TestEMADLAP", + "emulator_type": "direct", + "os": "windows", + "time_model": { + "type": "instant" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/install/scenarios/EMAM_emu.json b/install/scenarios/EMAM_emu.json new file mode 100644 index 0000000000000000000000000000000000000000..135ef548388f480979e2dde1a23df06aeded7c78 --- /dev/null +++ b/install/scenarios/EMAM_emu.json @@ -0,0 +1,76 @@ +{ + "name": "EMAM_emu", + "map_name": "aachen", + "cars": [ + { + "name": "EMAMTestVehicle", + "start_pos": [ 0, 0 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, + "components": [ + { "type": "constant_bus" }, + { + "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": "computer", + "software_name": "TestEMAMAP", + "emulator_type": "emu", + "os": "windows", + "time_model": { + "type": "models", + "cpu_frequency": 4000000000, + "memory_frequency": 2500000000, + "caches": [ + {"type": "I", "level": 1, "size": 262144, "read_ticks": 4, "write_ticks": 4}, + {"type": "D", "level": 1, "size": 262144, "read_ticks": 4, "write_ticks": 4}, + {"type": "shared", "level": 2, "size": 2097152, "read_ticks": 6, "write_ticks": 6}, + {"type": "shared", "level": 3, "size": 12582912, "read_ticks": 40, "write_ticks": 40} + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/install/scenarios/EMAM_native.json b/install/scenarios/EMAM_native.json new file mode 100644 index 0000000000000000000000000000000000000000..33f03775ea681d412d24acf29ae38b24b149be39 --- /dev/null +++ b/install/scenarios/EMAM_native.json @@ -0,0 +1,68 @@ +{ + "name": "EMAM_native", + "map_name": "aachen", + "cars": [ + { + "name": "EMAMTestVehicle", + "start_pos": [ 0, 0 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, + "components": [ + { "type": "constant_bus" }, + { + "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": "computer", + "software_name": "TestEMAMAP", + "emulator_type": "direct", + "os": "windows", + "time_model": { + "type": "instant" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/install/scenarios/cppautopilot.json b/install/scenarios/cppautopilot.json index 3c5b1c379e0e19deed8289190e8a44a836213fc7..3f8e76656102e6c0770d910590f3ac0696d4fae8 100755 --- a/install/scenarios/cppautopilot.json +++ b/install/scenarios/cppautopilot.json @@ -4,202 +4,55 @@ "cars": [ { "name": "TestVehicle", - "start_coords": [ - 0, - 0 - ], - "end_coords": [ - -63.83, - -171.96 - ], - "body": { - "mass": 1642.0, - "length": 4.971, - "width": 1.87, - "height": 1.383, - "center_of_gravity_height": 0.34575 - }, - "wheels": { - "diameter": 0.6612, - "width": 0.255, - "front_wheel_axis_offset": 1.0, - "max_turning_angle": 30.0, - "front_track_width": 1.57988, - "back_track_dist": 1.60274, - "wheelbase": 2.812, - "wheelbase_offset": 0.0 - }, - "powertrain": { - "type": "electrical", - "traction": "rear", - "braking": "front", - "max_braking_force": 5000.0, - "motor": { - "motor_efficiency": 0.7, - "regen_efficiency": 0.5, - "motor_peek_torque": 450.0 - }, - "battery": { - "type": "infinite", - "capacity": 1.8E8, - "critical_charge": 10.0 - }, - "transmission_ratio": 9.0 - }, - "physics": { - "type": "rigidbody" + "start_pos": [ 0, 0 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] }, "components": [ + { "type": "constant_bus" }, { "type": "actuator", "name": "SteeringActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "steering", "change_rate": 60.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "BrakingActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "braking", "change_rate": 10.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "GasActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "gas", - "change_rate": "Infinity", - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "sensor", "name": "TrueVelocitySensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_velocity", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_velocity" }, { "type": "sensor", "name": "TruePositionSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_position", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_position" }, { "type": "sensor", "name": "TrueCompassSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_compass", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "navigation", - "name": "Navigation", - "priority": {}, - "buses": [ - "DefaultBus" - ] - }, - { - "type": "constant_bus", - "name": "DefaultBus", - "priority": {}, - "mode": "instant", - "rate": 0.0 + "physical_value_name": "true_compass" }, + { "type": "navigation" }, { "type": "computer", "software_name": "cppautopilotzigzag", diff --git a/install/scenarios/cppautopilot_native.json b/install/scenarios/cppautopilot_native.json index 3076994f2da2944ade9b9073d847cb63764f9fdd..540bd0fe987b45dc0f43e2dc5aebff2b5aae24e6 100755 --- a/install/scenarios/cppautopilot_native.json +++ b/install/scenarios/cppautopilot_native.json @@ -1,205 +1,58 @@ { - "name": "new_basic", + "name": "cppautopilot_native", "map_name": "aachen", "cars": [ { "name": "TestVehicle", - "start_coords": [ - 0, - 0 - ], - "end_coords": [ - -63.83, - -171.96 - ], - "body": { - "mass": 1642.0, - "length": 4.971, - "width": 1.87, - "height": 1.383, - "center_of_gravity_height": 0.34575 - }, - "wheels": { - "diameter": 0.6612, - "width": 0.255, - "front_wheel_axis_offset": 1.0, - "max_turning_angle": 30.0, - "front_track_width": 1.57988, - "back_track_dist": 1.60274, - "wheelbase": 2.812, - "wheelbase_offset": 0.0 - }, - "powertrain": { - "type": "electrical", - "traction": "rear", - "braking": "front", - "max_braking_force": 5000.0, - "motor": { - "motor_efficiency": 0.7, - "regen_efficiency": 0.5, - "motor_peek_torque": 450.0 - }, - "battery": { - "type": "infinite", - "capacity": 1.8E8, - "critical_charge": 10.0 - }, - "transmission_ratio": 9.0 - }, - "physics": { - "type": "rigidbody" + "start_pos": [ 0, 0 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] }, "components": [ + { "type": "constant_bus" }, { "type": "actuator", "name": "SteeringActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "steering", "change_rate": 60.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "BrakingActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "braking", "change_rate": 10.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "GasActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "gas", - "change_rate": "Infinity", - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "sensor", "name": "TrueVelocitySensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_velocity", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_velocity" }, { "type": "sensor", "name": "TruePositionSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_position", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_position" }, { "type": "sensor", "name": "TrueCompassSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_compass", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "navigation", - "name": "Navigation", - "priority": {}, - "buses": [ - "DefaultBus" - ] - }, - { - "type": "constant_bus", - "name": "DefaultBus", - "priority": {}, - "mode": "instant", - "rate": 0.0 + "physical_value_name": "true_compass" }, + { "type": "navigation" }, { "type": "computer", "software_name": "cppautopilotzigzag", diff --git a/install/scenarios/EMA_native.json b/install/scenarios/explicit.json similarity index 89% rename from install/scenarios/EMA_native.json rename to install/scenarios/explicit.json index bc986515a371c8ba0c06c43a57ecafadd5132cc0..44c635805efa48a6fe7d6acbe499eb1975b1773a 100644 --- a/install/scenarios/EMA_native.json +++ b/install/scenarios/explicit.json @@ -1,17 +1,20 @@ { - "name": "new_basic", + "name": "explicit", "map_name": "aachen", "cars": [ { "name": "TestVehicle", - "start_coords": [ - 0, - 0 - ], - "end_coords": [ - -63.83, - -171.96 - ], + "start_pos": [ -123.09, 21.64 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, "body": { "mass": 1642.0, "length": 4.971, @@ -201,13 +204,17 @@ "rate": 0.0 }, { - "type": "computer", - "software_name": "BasicAutopilot", - "emulator_type": "direct", - "os": "windows", - "time_model": { - "type": "instant" - } + "type": "java_autopilot", + "name": "TestAutopilot", + "priority": {}, + "buses": [ + "DefaultBus" + ], + "compute_time": [ + 0, + 0 + ], + "maxVehicleAccel": 7.460690450979396 } ] } diff --git a/install/scenarios/java_autopilot.json b/install/scenarios/java_autopilot.json index 3eef0a449569ee8c76cf021b651cf115ecee61a7..b0bc2e274942477bdd83ca0b3ca3be5743dec86c 100755 --- a/install/scenarios/java_autopilot.json +++ b/install/scenarios/java_autopilot.json @@ -1,216 +1,62 @@ { - "name": "new_basic", + "name": "java_autopilot", "map_name": "aachen", + "max_duration": [60,0], + "tick_duration": [0,10000000], "cars": [ { - "name": "TestVehicle", - "start_coords": [ - 0, - 0 - ], - "end_coords": [ - -63.83, - -171.96 - ], - "body": { - "mass": 1642.0, - "length": 4.971, - "width": 1.87, - "height": 1.383, - "center_of_gravity_height": 0.34575 - }, - "wheels": { - "diameter": 0.6612, - "width": 0.255, - "front_wheel_axis_offset": 1.0, - "max_turning_angle": 30.0, - "front_track_width": 1.57988, - "back_track_dist": 1.60274, - "wheelbase": 2.812, - "wheelbase_offset": 0.0 - }, - "powertrain": { - "type": "electrical", - "traction": "rear", - "braking": "front", - "max_braking_force": 5000.0, - "motor": { - "motor_efficiency": 0.7, - "regen_efficiency": 0.5, - "motor_peek_torque": 450.0 - }, - "battery": { - "type": "infinite", - "capacity": 1.8E8, - "critical_charge": 10.0 - }, - "transmission_ratio": 9.0 - }, - "physics": { - "type": "rigidbody" + "start_pos": [ -123.09, 21.64 ], + "start_orientation": -30.0, + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] }, "components": [ + { "type": "constant_bus" }, { "type": "actuator", "name": "SteeringActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "steering", "change_rate": 60.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "BrakingActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "braking", "change_rate": 10.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "GasActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "gas", - "change_rate": "Infinity", - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "sensor", "name": "TrueVelocitySensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_velocity", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_velocity" }, { "type": "sensor", "name": "TruePositionSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_position", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_position" }, { "type": "sensor", "name": "TrueCompassSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_compass", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "navigation", - "name": "Navigation", - "priority": {}, - "buses": [ - "DefaultBus" - ] - }, - { - "type": "constant_bus", - "name": "DefaultBus", - "priority": {}, - "mode": "instant", - "rate": 0.0 + "physical_value_name": "true_compass" }, + { "type": "navigation" }, { "type": "java_autopilot", - "name": "TestAutopilot", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "compute_time": [ - 0, - 0 - ], "maxVehicleAccel": 7.460690450979396 } ] diff --git a/install/scenarios/two_cars.json b/install/scenarios/two_cars.json new file mode 100644 index 0000000000000000000000000000000000000000..a4f9f625b8f14c23767a382c56ab7d9c1b0b13db --- /dev/null +++ b/install/scenarios/two_cars.json @@ -0,0 +1,122 @@ +{ + "name": "java_autopilot", + "map_name": "aachen", + "cars": [ + { + "name": "Car1", + "start_pos": [ -123.09, 21.64 ], + "start_orientation": -30.0, + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] + }, + "components": [ + { "type": "constant_bus" }, + { + "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", + "maxVehicleAccel": 7.460690450979396 + } + ] + }, + { + "name": "Car2", + "start_pos": [ -265.85, -56.34 ], + "start_orientation": 40.0, + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-159.65, -48.59] ], + "range": 5 + } + ] + }, + "components": [ + { "type": "constant_bus" }, + { + "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", + "maxVehicleAccel": 7.460690450979396 + } + ] + } + ] +} \ No newline at end of file diff --git a/install/scenarios/vcg.json b/install/scenarios/vcg.json index 8debd4b5d22ec9ab36e3e00a5e081372a5fa069b..feb788dc7b8dcffaae065ed71267359e5bcfd08b 100644 --- a/install/scenarios/vcg.json +++ b/install/scenarios/vcg.json @@ -1,189 +1,58 @@ { - "name": "new_basic", + "name": "vcg", "map_name": "aachen", "cars": [ { "name": "VCGTestVehicle", - "start_coords": [ 0, 0 ], - "end_coords": [ -63.83, -171.96 ], - "body": { - "mass": 1642.0, - "length": 4.971, - "width": 1.87, - "height": 1.383, - "center_of_gravity_height": 0.34575 - }, - "wheels": { - "diameter": 0.6612, - "width": 0.255, - "front_wheel_axis_offset": 1.0, - "max_turning_angle": 30.0, - "front_track_width": 1.57988, - "back_track_dist": 1.60274, - "wheelbase": 2.812, - "wheelbase_offset": 0.0 - }, - "powertrain": { - "type": "electrical", - "traction": "rear", - "braking": "front", - "max_braking_force": 5000.0, - "motor": { - "motor_efficiency": 0.7, - "regen_efficiency": 0.5, - "motor_peek_torque": 450.0 - }, - "battery": { - "type": "infinite", - "capacity": 1.8E8, - "critical_charge": 10.0 - }, - "transmission_ratio": 9.0 - }, - "physics": { - "type": "rigidbody" + "start_pos": [ 0, 0 ], + "task": { + "goals": [ + { + "type": "path", + "ltl_operator": "eventually", + "path": [ [-63.83, -171.96] ], + "range": 5 + } + ] }, "components": [ + { "type": "constant_bus" }, { "type": "actuator", "name": "SteeringActuator", - "priority": {}, - "buses": [ "DefaultBus" ], "physical_value_name": "steering", "change_rate": 60.0, - "sensor": { - "type": "sensor", - "name": "SteeringFeedbackSensor", - "priority": {}, - "buses": [ "DefaultBus" ], - "update_interval": [ 0, 100000000 ], - "read_time": [ 0, 1000000 ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "BrakingActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "braking", "change_rate": 10.0, - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "actuator", "name": "GasActuator", - "priority": {}, - "buses": [ - "DefaultBus" - ], "physical_value_name": "gas", - "change_rate": "Infinity", - "sensor": { - "type": "sensor", - "name": "UnnamedComponent", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 1000000 - ], - "send_only_changed": false - } + "sensor": { "type": "sensor" } }, { "type": "sensor", "name": "TrueVelocitySensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_velocity", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_velocity" }, { "type": "sensor", "name": "TruePositionSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_position", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false + "physical_value_name": "true_position" }, { "type": "sensor", "name": "TrueCompassSensor", - "priority": {}, - "buses": [ - "DefaultBus" - ], - "physical_value_name": "true_compass", - "update_interval": [ - 0, - 100000000 - ], - "read_time": [ - 0, - 10000000 - ], - "send_only_changed": false - }, - { - "type": "navigation", - "name": "Navigation", - "priority": {}, - "buses": [ - "DefaultBus" - ] - }, - { - "type": "constant_bus", - "name": "DefaultBus", - "priority": {}, - "mode": "instant", - "rate": 0.0 + "physical_value_name": "true_compass" }, + { "type": "navigation" }, { "type": "vcg", "name": "VCG", diff --git a/pom.xml b/pom.xml index 9f35aad00cc0ebd2c352b8db23e10f96333410eb..30e9aec9f9b9238cc8d771578d03028537ae1324 100644 --- a/pom.xml +++ b/pom.xml @@ -9,15 +9,15 @@ montisim basic-simulator - 2.0 + 2.1.2 basic-simulator - 2.0.6 - 2.0.1 - 3.0.1 + 2.0.10 + 2.0.3 + 3.1.1 UTF-8 diff --git a/src/main/java/de/rwth/montisim/basic_simulator/App.java b/src/main/java/de/rwth/montisim/basic_simulator/App.java index 205205409c25b5cabe8a68410016d9b8933d370a..05d66bb5992cc46e82348ebe8c8bdaec0ecd1c52 100644 --- a/src/main/java/de/rwth/montisim/basic_simulator/App.java +++ b/src/main/java/de/rwth/montisim/basic_simulator/App.java @@ -6,28 +6,18 @@ 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.commons.utils.json.*; import de.rwth.montisim.hardware_emulator.CppBridge; import de.rwth.montisim.hardware_emulator.computer.ComputerProperties; import de.rwth.montisim.hardware_emulator.vcg.VCGProperties; -import de.rwth.montisim.simulation.eecomponents.autopilots.*; -import de.rwth.montisim.simulation.eecomponents.navigation.NavigationProperties; -import de.rwth.montisim.simulation.eesimulator.actuator.ActuatorProperties; -import de.rwth.montisim.simulation.eesimulator.bridge.BridgeProperties; -import de.rwth.montisim.simulation.eesimulator.bus.can.CANProperties; -import de.rwth.montisim.simulation.eesimulator.bus.constant.ConstantBusProperties; import de.rwth.montisim.simulation.eesimulator.message.MessageTypeManager; -import de.rwth.montisim.simulation.eesimulator.sensor.SensorProperties; -import de.rwth.montisim.simulation.eesimulator.testcomponents.TestCompProperties; 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 de.rwth.montisim.simulation.vehicle.physicsmodel.rigidbody.RigidbodyPhysicsProperties; -import de.rwth.montisim.simulation.vehicle.powertrain.electrical.ElectricalPTProperties; -import de.rwth.montisim.simulation.vehicle.powertrain.fuel.FuelPTProperties; import javax.swing.*; @@ -37,20 +27,9 @@ import java.io.IOException; public class App { static { - Json.registerType(ElectricalPTProperties.class); - Json.registerType(FuelPTProperties.class); - Json.registerType(NavigationProperties.class); - Json.registerType(JavaAutopilotProperties.class); - Json.registerType(TestAutopilotProperties.class); - Json.registerType(RigidbodyPhysicsProperties.class); - Json.registerType(ActuatorProperties.class); - Json.registerType(BridgeProperties.class); - Json.registerType(CANProperties.class); - Json.registerType(ConstantBusProperties.class); - Json.registerType(SensorProperties.class); - Json.registerType(TestCompProperties.class); Json.registerType(ComputerProperties.class); Json.registerType(VCGProperties.class); + Simulator.registerJsonTypes(); } public static void main( String[] args ) @@ -109,14 +88,21 @@ public class App File scenarioFile = new File(path); SimulationConfig config = SimulationConfig.fromFile(scenarioFile); File mapPath = new File(config.map_name + ".osm"); - World world = new OsmToWorldLoader(new OsmMap(config.map_name, mapPath)).getWorld(); + OsmMap map = new OsmMap(config.map_name, mapPath); + World world = new OsmToWorldLoader(map).getWorld(); Pathfinding pathfinding = new PathfindingImpl(world); MessageTypeManager mtManager = new MessageTypeManager(); - Simulator simulator = new Simulator(config, world, pathfinding, mtManager); + Simulator simulator = config.build(world, pathfinding, mtManager, map); // Run simulation SimulationLoop simLoop = new SimulationLoop(simulator, config); - simLoop.run(); + 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; diff --git a/src/main/java/de/rwth/montisim/basic_simulator/gui/Browser.java b/src/main/java/de/rwth/montisim/basic_simulator/gui/Browser.java index c65e43fe2e1df14c609f9a10a20a5ad2b3c0c658..6e5904708284bb970c46649ff08fbaec70b66aa2 100644 --- a/src/main/java/de/rwth/montisim/basic_simulator/gui/Browser.java +++ b/src/main/java/de/rwth/montisim/basic_simulator/gui/Browser.java @@ -4,18 +4,22 @@ package de.rwth.montisim.basic_simulator.gui; import de.rwth.montisim.basic_simulator.filesystem.FileSystem; +import de.rwth.montisim.simulation.simulator.visualization.ui.UIInfo; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; import java.awt.*; +import java.awt.event.*; import java.io.IOException; import java.util.Enumeration; import java.util.HashMap; public class Browser extends JFrame implements TreeSelectionListener { private static final long serialVersionUID = -7491494784879564019L; + public static Border paneBorder; protected static class BrowserTree extends JTree { private static final long serialVersionUID = -3212587123492957572L; @@ -48,7 +52,8 @@ public class Browser extends JFrame implements TreeSelectionListener { public Browser(FileSystem file_system) throws IOException { super("MontiSim basic-simulator"); this.file_system = file_system; - setBackground(new Color(238,238,238)); + //setBackground(new Color(238,238,238)); + //getContentPane().setBackground(Color.WHITE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setSize(1200, 900); @@ -60,6 +65,7 @@ public class Browser extends JFrame implements TreeSelectionListener { //Add browser JScrollPane browser = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + paneBorder = browser.getBorder(); tree_root = new DefaultMutableTreeNode("Categories"); tree_model = new DefaultTreeModel(tree_root); @@ -85,10 +91,46 @@ public class Browser extends JFrame implements TreeSelectionListener { browser.setMinimumSize(new Dimension(300, 200)); browser.setViewportView(tree); - getContentPane().add(BorderLayout.LINE_START, browser); - - - + + + JPanel interm = new JPanel(); + + JCheckBox checkBox1 = new JCheckBox("Antialiasing", UIInfo.antialiasing); + checkBox1.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIInfo.antialiasing = e.getStateChange() == 1; + repaint(); + } + }); + checkBox1.setBackground(Color.WHITE); + interm.add(checkBox1); + + JCheckBox checkBox2 = new JCheckBox("Show Road Segments", UIInfo.showSegments); + checkBox2.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIInfo.showSegments = e.getStateChange() == 1; + repaint(); + } + }); + checkBox2.setBackground(Color.WHITE); + interm.add(checkBox2); + + interm.setBackground(Color.WHITE); + JPanel optionPanel = new JPanel(); + optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); + optionPanel.setBorder(paneBorder); + optionPanel.add(interm); + + + JPanel sidePanel = new JPanel(); + sidePanel.setLayout(new BorderLayout()); + sidePanel.add(browser, BorderLayout.CENTER); + sidePanel.add(optionPanel, BorderLayout.PAGE_END); + + getContentPane().add(BorderLayout.LINE_START, sidePanel); + + + setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); setVisible(true); //making the frame visible } diff --git a/src/main/java/de/rwth/montisim/basic_simulator/gui/MapVis.java b/src/main/java/de/rwth/montisim/basic_simulator/gui/MapVis.java index 8912397a3417a11680e5bbcd30703ff5ee8bf174..177608134d0fbec2af97377fa617c8bd3eb6c894 100644 --- a/src/main/java/de/rwth/montisim/basic_simulator/gui/MapVis.java +++ b/src/main/java/de/rwth/montisim/basic_simulator/gui/MapVis.java @@ -6,7 +6,7 @@ package de.rwth.montisim.basic_simulator.gui; import java.awt.BorderLayout; import java.io.File; -import javax.swing.*; +import java.awt.Color; import de.rwth.montisim.simulation.environment.osmmap.*; import de.rwth.montisim.simulation.environment.pathfinding.PathfindingImpl; @@ -16,7 +16,6 @@ import de.rwth.montisim.simulation.simulator.visualization.map.*; import de.rwth.montisim.simulation.simulator.visualization.ui.Viewer2D; public class MapVis extends SimVis { - public static final boolean SHOW_SEGMENTS = true; Viewer2D viewer; FileSystem fileSystem; @@ -24,8 +23,8 @@ public class MapVis extends SimVis { public MapVis(FileSystem fileSystem){ this.fileSystem = fileSystem; setLayout(new BorderLayout()); - add(new JLabel("Visualization of available maps."), BorderLayout.NORTH); viewer = new Viewer2D(); + viewer.setBackground(Color.WHITE); add( viewer, BorderLayout.CENTER ); } @@ -35,7 +34,7 @@ public class MapVis extends SimVis { File map_path = fileSystem.getPath("maps", elem.name + ".osm"); World world = new OsmToWorldLoader(new OsmMap("aachen", map_path)).getWorld(); viewer.clearRenderers(); - viewer.addRenderer(new WorldRenderer(world, SHOW_SEGMENTS)); + viewer.addRenderer(new WorldRenderer(world)); viewer.addRenderer(new PathfinderRenderer(new PathfindingImpl(world))); viewer.repaint(); } catch (Exception e) { diff --git a/src/main/java/de/rwth/montisim/basic_simulator/gui/ScenarioVis.java b/src/main/java/de/rwth/montisim/basic_simulator/gui/ScenarioVis.java index 45451d0cc69780dcff82ed1f5ef0ec9fea4dac4d..03fa00d0da63eb7aeb1bc531ea50136dbc88f065 100644 --- a/src/main/java/de/rwth/montisim/basic_simulator/gui/ScenarioVis.java +++ b/src/main/java/de/rwth/montisim/basic_simulator/gui/ScenarioVis.java @@ -5,13 +5,11 @@ 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.commons.simulation.TimeUpdate; +import de.rwth.montisim.commons.utils.IPM; import de.rwth.montisim.commons.utils.Vec2; -import de.rwth.montisim.commons.utils.Vec3; import de.rwth.montisim.commons.utils.json.SerializationException; -import de.rwth.montisim.simulation.eecomponents.navigation.Navigation; -import de.rwth.montisim.simulation.eesimulator.exceptions.EEMessageTypeException; -import de.rwth.montisim.simulation.eesimulator.exceptions.EESetupException; import de.rwth.montisim.simulation.eesimulator.message.MessageTypeManager; import de.rwth.montisim.simulation.environment.pathfinding.PathfindingImpl; import de.rwth.montisim.simulation.environment.osmmap.*; @@ -23,32 +21,37 @@ import de.rwth.montisim.simulation.simulator.visualization.map.PathfinderRendere import de.rwth.montisim.simulation.simulator.visualization.map.WorldRenderer; import de.rwth.montisim.simulation.simulator.visualization.ui.Control; import de.rwth.montisim.simulation.simulator.visualization.ui.SimulationRunner; +import de.rwth.montisim.simulation.simulator.visualization.ui.UIInfo; import de.rwth.montisim.simulation.simulator.visualization.ui.Viewer2D; import de.rwth.montisim.simulation.vehicle.Vehicle; -import de.rwth.montisim.simulation.vehicle.VehicleProperties; import javax.swing.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.*; import java.awt.BorderLayout; import java.io.File; import java.time.*; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class ScenarioVis extends SimVis implements SimulationRunner { private static final long serialVersionUID = 7903217594061845406L; - public static final boolean SHOW_SEGMENTS = true; - final FileSystem fileSystem; String current_scenario = ""; JLabel scenario_name; - final Control control; - final Viewer2D viewer; + Control control; + Viewer2D viewer; private List carRenderers = new ArrayList<>(); Simulator simulator; + SimulationConfig simConfig; World world; + OsmMap map; Pathfinding pathfinding; MessageTypeManager mtManager; @@ -58,87 +61,105 @@ public class ScenarioVis extends SimVis implements SimulationRunner { Duration dt = Duration.ofMillis(PHYSICS_TICK_DURATION_MS); public ScenarioVis(FileSystem fileSystem) { + UIInfo.inspectAutopilots = false; + // setBackground(Color.WHITE); this.fileSystem = fileSystem; - viewer = new Viewer2D(); - viewer.setZoom(20); - - control = new Control(Control.Mode.SIMULATION, Instant.EPOCH, this, (int)PHYSICS_TICK_DURATION_MS, 30, 3); - - JPanel topPanel = new JPanel(); - topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); - topPanel.add(control); - topPanel.add(new JSeparator()); - - setLayout(new BorderLayout()); - add(topPanel, BorderLayout.PAGE_START); - add(viewer, BorderLayout.CENTER); - // add(plotter, BorderLayout.PAGE_END); + setupUI(); } - // public void setScenario(String scenario){ - // if (scenario != current_scenario){ - // current_scenario = scenario; - // scenario_name.setText(scenario); - // } - // } - private void setup() { + // Cleanup if a sim is here + if (simulator != null) { + simulator.destroy(); + simulator = null; + viewer.clearRenderers(); + carRenderers.clear(); + } + File scenarioFile = fileSystem.getPath("scenarios", current_scenario + ".json"); - SimulationConfig config; try { - config = SimulationConfig.fromFile(scenarioFile); + simConfig = SimulationConfig.fromFile(scenarioFile); } catch (SerializationException e1) { e1.printStackTrace(); return; } + control.init(simConfig.tick_duration, simConfig.start_time); // Create simulator from scenario file - File map_path = fileSystem.getPath("maps", config.map_name + ".osm"); + File map_path = fileSystem.getPath("maps", simConfig.map_name + ".osm"); World world; try { - world = new OsmToWorldLoader(new OsmMap(config.map_name, map_path)).getWorld(); + map = new OsmMap(simConfig.map_name, map_path); + world = new OsmToWorldLoader(map).getWorld(); pathfinding = new PathfindingImpl(world); } catch (Exception e1) { e1.printStackTrace(); return; } mtManager = new MessageTypeManager(); - simulator = new Simulator(config, world, pathfinding, mtManager); + simulator = simConfig.build(world, pathfinding, mtManager, map); // Setup visualizer - viewer.clearRenderers(); - viewer.addRenderer(new WorldRenderer(world, SHOW_SEGMENTS)); + viewer.addRenderer(new WorldRenderer(world)); viewer.addRenderer(new PathfinderRenderer(pathfinding)); - carRenderers.clear(); - for (VehicleProperties car_config : config.cars) { - Vehicle car; - try { - car = simulator.getVehicleBuilder(car_config).build(); - - simulator.addSimulationObject(car); - - car.physicsModel.setGroundPosition(new Vec3(car_config.start_coords, 0), new Vec2(1,0)); - - Navigation nav = (Navigation) car.eesystem.getComponentManager().getComponent("Navigation").get(); - nav.pushTargetPos(car_config.end_coords); - car.addTarget(car_config.end_coords); - - CarRenderer cr = new CarRenderer(); - cr.setCar(car); - viewer.addRenderer(cr); - carRenderers.add(cr); - } catch (SerializationException | EEMessageTypeException | EESetupException e) { - e.printStackTrace(); - } - + // Init CarRenderers and find view for all Vehicles + Collection vehicles = simulator.getVehicles(); + setView(vehicles); + + for (Vehicle v : vehicles) { + CarRenderer cr = new CarRenderer(); + cr.setCar(v); + viewer.addRenderer(cr); + carRenderers.add(cr); } viewer.repaint(); + } + void setView(Collection vehicles) { + Vec2 avg_pos = new Vec2(0, 0); + int count = 0; + Vec2 min_pos = new Vec2(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + Vec2 max_pos = new Vec2(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY); + Vec2 vpos = new Vec2(); + for (Vehicle v : vehicles) { + vpos.set(v.physicalObject.pos); + IPM.add(avg_pos, vpos); + if (vpos.x < min_pos.x) + min_pos.x = vpos.x; + if (vpos.y < min_pos.y) + min_pos.y = vpos.y; + if (vpos.x > max_pos.x) + max_pos.x = vpos.x; + if (vpos.y > max_pos.y) + max_pos.y = vpos.y; + ++count; + } + if (count == 0) { + viewer.setCenter(avg_pos); + viewer.setZoom(4); + return; + } + + IPM.multiply(avg_pos, 1.0 / (double) count); + viewer.setCenter(avg_pos); + + Vec2 range = new Vec2(); + IPM.subtractTo(range, max_pos, min_pos); + IPM.add(range, new Vec2(16, 16)); // Margin + Dimension d = viewer.getSize(); + double xscale = d.getWidth() / range.x; + double yscale = d.getHeight() / range.y; + double scale = 20; + if (xscale < scale) + scale = xscale; + if (yscale < scale) + scale = yscale; + viewer.setZoom(scale); } @Override @@ -164,4 +185,83 @@ public class ScenarioVis extends SimVis implements SimulationRunner { if (simulator != null) simulator.update(newTime); } + + void setupUI() { + viewer = new Viewer2D(); + viewer.setZoom(20); + + control = new Control(Control.Mode.SIMULATION, Instant.EPOCH, this, Duration.ofMillis(PHYSICS_TICK_DURATION_MS), 30, 3); + control.setBackground(Color.WHITE); + + JPanel topPanel = new JPanel(); + topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS)); + topPanel.setBorder(Browser.paneBorder); + topPanel.add(control); + + setLayout(new BorderLayout()); + add(topPanel, BorderLayout.PAGE_START); + + viewer.setBackground(Color.WHITE); + JPanel viewerContainer = new JPanel(); + viewerContainer.setLayout(new BoxLayout(viewerContainer, BoxLayout.Y_AXIS)); + viewerContainer.setBorder(Browser.paneBorder); + viewerContainer.add(viewer); + add(viewerContainer, BorderLayout.CENTER); + + JPanel interm = new JPanel(); + interm.setLayout(new FlowLayout()); + interm.setBackground(Color.WHITE); + + JCheckBox checkBox1 = new JCheckBox("Inspect Autopilot I/O", UIInfo.inspectAutopilots); + checkBox1.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIInfo.inspectAutopilots = e.getStateChange() == 1; + viewer.repaint(); + } + }); + interm.add(checkBox1); + + JCheckBox checkBox2 = new JCheckBox("Show Planned Path", UIInfo.drawPlannedPath); + checkBox2.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIInfo.drawPlannedPath = e.getStateChange() == 1; + viewer.setDirty(); + viewer.repaint(); + } + }); + interm.add(checkBox2); + + JCheckBox checkBox3 = new JCheckBox("Show Trajectory (Navigation output)", UIInfo.drawPlannedTrajectory); + checkBox3.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIInfo.drawPlannedTrajectory = e.getStateChange() == 1; + viewer.setDirty(); + viewer.repaint(); + } + }); + interm.add(checkBox3); + + JCheckBox checkBox4 = new JCheckBox("Show Actuators", UIInfo.drawActuators); + checkBox4.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIInfo.drawActuators = e.getStateChange() == 1; + viewer.setDirty(); + viewer.repaint(); + } + }); + interm.add(checkBox4); + + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); + bottomPanel.setBorder(Browser.paneBorder); + bottomPanel.add(interm); + add(bottomPanel, BorderLayout.PAGE_END); + + // add(plotter, BorderLayout.PAGE_END); + } + + @Override + public TaskStatus status() { + return simulator.status(); + } }