Fix dep. warning in visualize_telemetry, add legend
parent
d152c8a559
commit
e583b2c126
|
@ -77,6 +77,7 @@ public class SimManager : MonoBehaviour {
|
||||||
for (int i = 0; i < swarmConfig.num_agents; i++) {
|
for (int i = 0; i < swarmConfig.num_agents; i++) {
|
||||||
var missile = CreateMissile(swarmConfig.agent_config);
|
var missile = CreateMissile(swarmConfig.agent_config);
|
||||||
missile.OnAgentHit += RegisterMissileHit;
|
missile.OnAgentHit += RegisterMissileHit;
|
||||||
|
missile.OnAgentMiss += RegisterMissileMiss;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +104,12 @@ public class SimManager : MonoBehaviour {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterMissileMiss(Agent missile) {
|
||||||
|
if (missile is Missile missileComponent) {
|
||||||
|
_activeMissiles.Remove(missileComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void RegisterTargetHit(Agent target) {
|
public void RegisterTargetHit(Agent target) {
|
||||||
if (target is Target targetComponent) {
|
if (target is Target targetComponent) {
|
||||||
_activeTargets.Remove(targetComponent);
|
_activeTargets.Remove(targetComponent);
|
||||||
|
|
|
@ -19,6 +19,7 @@ def plot_telemetry(file_path):
|
||||||
# Read the telemetry CSV file
|
# Read the telemetry CSV file
|
||||||
df = pd.read_csv(file_path)
|
df = pd.read_csv(file_path)
|
||||||
|
|
||||||
|
|
||||||
# Create a 3D plot
|
# Create a 3D plot
|
||||||
fig = plt.figure(figsize=(12, 8))
|
fig = plt.figure(figsize=(12, 8))
|
||||||
ax = fig.add_subplot(111, projection='3d')
|
ax = fig.add_subplot(111, projection='3d')
|
||||||
|
@ -29,7 +30,7 @@ def plot_telemetry(file_path):
|
||||||
# Group data by AgentID
|
# Group data by AgentID
|
||||||
for agent_type, type_data in df.groupby('AgentType'):
|
for agent_type, type_data in df.groupby('AgentType'):
|
||||||
color = colors.get(agent_type, 'black')
|
color = colors.get(agent_type, 'black')
|
||||||
downsampled = type_data.groupby('AgentID').apply(lambda x: x.iloc[::10])
|
downsampled = type_data.groupby('AgentID').apply(lambda x: x.iloc[::10], include_groups=False)
|
||||||
|
|
||||||
ax.plot(
|
ax.plot(
|
||||||
downsampled['AgentX'],
|
downsampled['AgentX'],
|
||||||
|
@ -41,9 +42,11 @@ def plot_telemetry(file_path):
|
||||||
label=f"{agent_type}"
|
label=f"{agent_type}"
|
||||||
)
|
)
|
||||||
|
|
||||||
ax.set_xlabel('X (Right)')
|
|
||||||
ax.set_ylabel('Z (Forward)')
|
ax.set_xlabel('X (m)')
|
||||||
ax.set_zlabel('Y (Up)')
|
ax.set_ylabel('Z (m)')
|
||||||
|
ax.set_zlabel('Y (m)')
|
||||||
|
|
||||||
|
|
||||||
ax.view_init(elev=20, azim=45)
|
ax.view_init(elev=20, azim=45)
|
||||||
|
|
||||||
|
@ -55,7 +58,11 @@ def plot_telemetry(file_path):
|
||||||
ax.plot_surface(xx, zz, yy, alpha=0.2, color='green')
|
ax.plot_surface(xx, zz, yy, alpha=0.2, color='green')
|
||||||
|
|
||||||
plt.title('Agents Trajectories (X: Right, Z: Forward, Y: Up)')
|
plt.title('Agents Trajectories (X: Right, Z: Forward, Y: Up)')
|
||||||
plt.legend()
|
legend = [
|
||||||
|
plt.Line2D([0], [0], color='red', lw=2, label='Target'),
|
||||||
|
plt.Line2D([0], [0], color='blue', lw=2, label='Missile')
|
||||||
|
]
|
||||||
|
plt.legend(handles=legend)
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue