Fix bug in visualize_telemetry

more-targets
Daniel Lovell 2024-09-14 15:37:45 -07:00
parent e583b2c126
commit bee353503e
5 changed files with 62 additions and 62 deletions

View File

@ -725,7 +725,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84f2990fd69b0284ca96912cbe968b62, type: 3} m_Script: {fileID: 11500000, guid: 84f2990fd69b0284ca96912cbe968b62, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
simulationConfig: {fileID: 11400000, guid: 6d7c61b7d025c9b49b3410fd1195a525, type: 2} simulationConfig: {fileID: 11400000, guid: f95ae714d3d58b64aaea2fb7b009af9f, type: 2}
--- !u!4 &253946927 --- !u!4 &253946927
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -44,6 +44,9 @@ public class SimMonitor : MonoBehaviour
foreach (var agent in SimManager.Instance.GetActiveTargets().Cast<Agent>().Concat(SimManager.Instance.GetActiveMissiles().Cast<Agent>())) foreach (var agent in SimManager.Instance.GetActiveTargets().Cast<Agent>().Concat(SimManager.Instance.GetActiveMissiles().Cast<Agent>()))
{ {
Vector3 pos = agent.transform.position; Vector3 pos = agent.transform.position;
if(pos == Vector3.zero) {
continue;
}
Vector3 vel = agent.GetComponent<Rigidbody>().velocity; Vector3 vel = agent.GetComponent<Rigidbody>().velocity;
string type = agent is Target ? "T" : "M"; 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}"); 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}");

View File

@ -10,68 +10,66 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 79f1fe138866d6a40b209a4edcf2ee06, type: 3} m_Script: {fileID: 11500000, guid: 79f1fe138866d6a40b209a4edcf2ee06, type: 3}
m_Name: SimulationConfig m_Name: SimulationConfigSimple
m_EditorClassIdentifier: m_EditorClassIdentifier:
timeScale: 0.1 timeScale: 1
missile_swarm_configs: missile_swarm_configs:
- num_agents: 4 - num_agents: 1
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
agent_config: agent_config:
missile_type: 0 missile_type: 0
target_type: 0 target_type: 0
initial_state: initial_state:
position: {x: 0, y: 200, z: 500} position: {x: 0, y: 20, z: 0}
rotation: {x: 0, y: 0, z: 0} rotation: {x: -45, y: 0, z: 0}
velocity: {x: 300, y: 0, z: 0} velocity: {x: 0, y: 10, z: 10}
standard_deviation: standard_deviation:
position: {x: 100, y: 50, z: 100} position: {x: 10, y: 0, z: 10}
velocity: {x: 50, 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: dynamic_config:
launch_config: launch_config:
launch_time: 0 launch_time: 0
@ -105,5 +103,3 @@ MonoBehaviour:
color: {r: 0, g: 0, b: 0, a: 0} color: {r: 0, g: 0, b: 0, a: 0}
linestyle: 0 linestyle: 0
marker: 0 marker: 0
prefabName:
prefabName: DroneTarget

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 81fed29b611ef7041a9db3e4513885ca guid: f95ae714d3d58b64aaea2fb7b009af9f
NativeFormatImporter: NativeFormatImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 11400000 mainObjectFileID: 11400000

View File

@ -28,9 +28,10 @@ def plot_telemetry(file_path):
colors = {'T': 'red', 'M': 'blue'} colors = {'T': 'red', 'M': 'blue'}
# Group data by AgentID # 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') 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( ax.plot(
downsampled['AgentX'], downsampled['AgentX'],