From bee353503e93896d70fa097cd10d1307e40972f2 Mon Sep 17 00:00:00 2001 From: Daniel Lovell Date: Sat, 14 Sep 2024 15:37:45 -0700 Subject: [PATCH] Fix bug in visualize_telemetry --- Assets/Scenes/MainScene.unity | 2 +- Assets/Scripts/Monitor.cs | 3 + ...fig.asset => SimulationConfigSimple.asset} | 110 +++++++++--------- ...meta => SimulationConfigSimple.asset.meta} | 2 +- Telemetry/visualize_telemetry.py | 7 +- 5 files changed, 62 insertions(+), 62 deletions(-) rename Assets/{SimulationConfig.asset => SimulationConfigSimple.asset} (74%) rename Assets/{SimulationConfig.asset.meta => SimulationConfigSimple.asset.meta} (79%) diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index dca0110..13b7237 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -725,7 +725,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 84f2990fd69b0284ca96912cbe968b62, type: 3} m_Name: m_EditorClassIdentifier: - simulationConfig: {fileID: 11400000, guid: 6d7c61b7d025c9b49b3410fd1195a525, type: 2} + simulationConfig: {fileID: 11400000, guid: f95ae714d3d58b64aaea2fb7b009af9f, type: 2} --- !u!4 &253946927 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Monitor.cs b/Assets/Scripts/Monitor.cs index f6ce5d3..0ca5cf8 100644 --- a/Assets/Scripts/Monitor.cs +++ b/Assets/Scripts/Monitor.cs @@ -44,6 +44,9 @@ public class SimMonitor : MonoBehaviour foreach (var agent in SimManager.Instance.GetActiveTargets().Cast().Concat(SimManager.Instance.GetActiveMissiles().Cast())) { Vector3 pos = agent.transform.position; + if(pos == Vector3.zero) { + continue; + } Vector3 vel = agent.GetComponent().velocity; string type = agent is Target ? "T" : "M"; writer.WriteLine($"{time:F2},{agent.name},{pos.x:F2},{pos.y:F2},{pos.z:F2},{vel.x:F2},{vel.y:F2},{vel.z:F2},{(int)agent.GetFlightPhase()},{type}"); diff --git a/Assets/SimulationConfig.asset b/Assets/SimulationConfigSimple.asset similarity index 74% rename from Assets/SimulationConfig.asset rename to Assets/SimulationConfigSimple.asset index 13c2cff..552288a 100644 --- a/Assets/SimulationConfig.asset +++ b/Assets/SimulationConfigSimple.asset @@ -10,68 +10,66 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 79f1fe138866d6a40b209a4edcf2ee06, type: 3} - m_Name: SimulationConfig + m_Name: SimulationConfigSimple m_EditorClassIdentifier: - timeScale: 0.1 + timeScale: 1 missile_swarm_configs: - - num_agents: 4 - agent_config: - missile_type: 1 - target_type: 0 - initial_state: - position: {x: 0, y: 600, z: -500} - rotation: {x: 0, y: 0, z: 0} - velocity: {x: 0.001, y: 0, z: 0.002} - standard_deviation: - position: {x: 200, y: 10, z: 200} - velocity: {x: 0, y: 0, z: 0} - dynamic_config: - launch_config: - launch_time: 0 - sensor_config: - type: 0 - frequency: 0 - plotting_config: - color: {r: 0, g: 0, b: 0, a: 0} - linestyle: 0 - marker: 0 - submunitions_config: - num_submunitions: 0 - launch_config: - launch_time: 0 - agent_config: - missile_type: 0 - initial_state: - position: {x: 0, y: 0, z: 0} - rotation: {x: 0, y: 0, z: 0} - velocity: {x: 0, y: 0, z: 0} - standard_deviation: - position: {x: 0, y: 0, z: 0} - velocity: {x: 0, y: 0, z: 0} - dynamic_config: - launch_config: - launch_time: 0 - sensor_config: - type: 0 - frequency: 0 - plotting_config: - color: {r: 0, g: 0, b: 0, a: 0} - linestyle: 0 - marker: 0 - prefabName: - prefabName: Micromissile - target_swarm_configs: - - num_agents: 8 + - num_agents: 1 agent_config: missile_type: 0 target_type: 0 initial_state: - position: {x: 0, y: 200, z: 500} - rotation: {x: 0, y: 0, z: 0} - velocity: {x: 300, y: 0, z: 0} + position: {x: 0, y: 20, z: 0} + rotation: {x: -45, y: 0, z: 0} + velocity: {x: 0, y: 10, z: 10} standard_deviation: - position: {x: 100, y: 50, z: 100} - velocity: {x: 50, y: 0, z: 10} + position: {x: 10, y: 0, z: 10} + velocity: {x: 5, y: 0, z: 1} + dynamic_config: + launch_config: + launch_time: 0 + sensor_config: + type: 0 + frequency: 100 + plotting_config: + color: {r: 0, g: 0, b: 0, a: 0} + linestyle: 0 + marker: 0 + submunitions_config: + num_submunitions: 7 + launch_config: + launch_time: 4 + agent_config: + missile_type: 1 + initial_state: + position: {x: 0, y: 0, z: 0} + rotation: {x: 0, y: 0, z: 0} + velocity: {x: 0, y: 0, z: 0} + standard_deviation: + position: {x: 5, y: 5, z: 5} + velocity: {x: 0, y: 0, z: 0} + dynamic_config: + launch_config: + launch_time: 0 + sensor_config: + type: 0 + frequency: 100 + plotting_config: + color: {r: 0, g: 0, b: 0, a: 0} + linestyle: 0 + marker: 0 + target_swarm_configs: + - num_agents: 7 + agent_config: + missile_type: 0 + target_type: 0 + initial_state: + position: {x: 0, y: 600, z: 6000} + rotation: {x: 90, y: 0, z: 0} + velocity: {x: 0, y: 0, z: -50} + standard_deviation: + position: {x: 1000, y: 200, z: 100} + velocity: {x: 0, y: 0, z: 25} dynamic_config: launch_config: launch_time: 0 @@ -105,5 +103,3 @@ MonoBehaviour: color: {r: 0, g: 0, b: 0, a: 0} linestyle: 0 marker: 0 - prefabName: - prefabName: DroneTarget diff --git a/Assets/SimulationConfig.asset.meta b/Assets/SimulationConfigSimple.asset.meta similarity index 79% rename from Assets/SimulationConfig.asset.meta rename to Assets/SimulationConfigSimple.asset.meta index 159f7f4..4dc46f8 100644 --- a/Assets/SimulationConfig.asset.meta +++ b/Assets/SimulationConfigSimple.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 81fed29b611ef7041a9db3e4513885ca +guid: f95ae714d3d58b64aaea2fb7b009af9f NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Telemetry/visualize_telemetry.py b/Telemetry/visualize_telemetry.py index 972a368..00fb0fd 100644 --- a/Telemetry/visualize_telemetry.py +++ b/Telemetry/visualize_telemetry.py @@ -28,10 +28,11 @@ def plot_telemetry(file_path): colors = {'T': 'red', 'M': 'blue'} # Group data by AgentID - for agent_type, type_data in df.groupby('AgentType'): + for agent_id, agent_data in df.groupby('AgentID'): + agent_type = agent_data['AgentType'].iloc[0] color = colors.get(agent_type, 'black') - downsampled = type_data.groupby('AgentID').apply(lambda x: x.iloc[::10], include_groups=False) - + downsampled = agent_data.iloc[::10] + ax.plot( downsampled['AgentX'], downsampled['AgentZ'],