"target_type" -> "threat_type", truncate sim config JSON

more-targets
Daniel Lovell 2024-09-24 20:04:27 -07:00
parent a29efbb4ca
commit 523d97ec85
6 changed files with 18 additions and 58 deletions

View File

@ -66,7 +66,7 @@ public static class ConfigLoader {
{ {
Debug.Log(" Agent Configuration:"); Debug.Log(" Agent Configuration:");
Debug.Log($" Interceptor Type: {agentConfig.interceptor_type}"); Debug.Log($" Interceptor Type: {agentConfig.interceptor_type}");
Debug.Log($" Threat Type: {agentConfig.target_type}"); Debug.Log($" Threat Type: {agentConfig.threat_type}");
PrintInitialState(agentConfig.initial_state); PrintInitialState(agentConfig.initial_state);
PrintStandardDeviation(agentConfig.standard_deviation); PrintStandardDeviation(agentConfig.standard_deviation);
PrintDynamicConfig(agentConfig.dynamic_config); PrintDynamicConfig(agentConfig.dynamic_config);

View File

@ -32,7 +32,7 @@ public class SwarmConfig {
[Serializable] [Serializable]
public class AgentConfig { public class AgentConfig {
public InterceptorType interceptor_type; public InterceptorType interceptor_type;
public ThreatType target_type; public ThreatType threat_type;
public InitialState initial_state; public InitialState initial_state;
public StandardDeviation standard_deviation; public StandardDeviation standard_deviation;
public DynamicConfig dynamic_config; public DynamicConfig dynamic_config;
@ -47,7 +47,7 @@ public class AgentConfig {
dynamic_config = submunitionConfig.dynamic_config, dynamic_config = submunitionConfig.dynamic_config,
plotting_config = submunitionConfig.plotting_config, plotting_config = submunitionConfig.plotting_config,
// Set other fields as needed, using default values if not present in SubmunitionAgentConfig // Set other fields as needed, using default values if not present in SubmunitionAgentConfig
target_type = ThreatType.DRONE, // Or another default value threat_type = ThreatType.DRONE, // Or another default value
submunitions_config = null // Or a default value if needed submunitions_config = null // Or a default value if needed
}; };
} }
@ -102,7 +102,7 @@ public class SensorConfig {
[Serializable] [Serializable]
public class TargetConfig { public class TargetConfig {
public ThreatType target_type; public ThreatType threat_type;
public InitialState initial_state; public InitialState initial_state;
public PlottingConfig plotting_config; public PlottingConfig plotting_config;
public string prefabName; public string prefabName;

View File

@ -224,9 +224,9 @@ public class SimManager : MonoBehaviour {
/// <param name="config">Configuration settings for the threat.</param> /// <param name="config">Configuration settings for the threat.</param>
/// <returns>The created Threat instance, or null if creation failed.</returns> /// <returns>The created Threat instance, or null if creation failed.</returns>
private Threat CreateThreat(AgentConfig config) { private Threat CreateThreat(AgentConfig config) {
string prefabName = config.target_type switch { string prefabName = config.threat_type switch {
ThreatType.DRONE => "Drone", ThreatType.ANTISHIP_MISSILE => "AntishipMissile", ThreatType.DRONE => "Drone", ThreatType.ANTISHIP_MISSILE => "AntishipMissile",
_ => throw new System.ArgumentException($"Unsupported threat type: {config.target_type}") _ => throw new System.ArgumentException($"Unsupported threat type: {config.threat_type}")
}; };
GameObject threatObject = CreateAgent(config, prefabName); GameObject threatObject = CreateAgent(config, prefabName);
if (threatObject == null) if (threatObject == null)
@ -238,7 +238,7 @@ public class SimManager : MonoBehaviour {
// Assign a unique and simple ID // Assign a unique and simple ID
int targetId = _threats.Count; int targetId = _threats.Count;
threatObject.name = $"{config.target_type}_Target_{targetId}"; threatObject.name = $"{config.threat_type}_Target_{targetId}";
return threatObject.GetComponent<Threat>(); return threatObject.GetComponent<Threat>();
} }

View File

@ -5,7 +5,7 @@
"num_agents": 1, "num_agents": 1,
"agent_config": { "agent_config": {
"interceptor_type": "HYDRA_70", "interceptor_type": "HYDRA_70",
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 0, "y": 20, "z": 0 }, "position": { "x": 0, "y": 20, "z": 0 },
"rotation": { "x": -45, "y": 0, "z": 0 }, "rotation": { "x": -45, "y": 0, "z": 0 },
@ -53,7 +53,7 @@
"num_agents": 7, "num_agents": 7,
"agent_config": { "agent_config": {
"interceptor_type": "HYDRA_70", "interceptor_type": "HYDRA_70",
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 0, "y": 600, "z": 6000 }, "position": { "x": 0, "y": 600, "z": 6000 },
"rotation": { "x": 90, "y": 0, "z": 0 }, "rotation": { "x": 90, "y": 0, "z": 0 },
@ -71,27 +71,7 @@
} }
}, },
"submunitions_config": { "submunitions_config": {
"num_submunitions": 0, "num_submunitions": 0
"launch_config": { "launch_time": 0 },
"agent_config": {
"interceptor_type": "HYDRA_70",
"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": "IDEAL",
"frequency": 0
}
}
}
} }
} }
} }

View File

@ -5,7 +5,7 @@
"num_agents": 10, "num_agents": 10,
"agent_config": { "agent_config": {
"interceptor_type": "HYDRA_70", "interceptor_type": "HYDRA_70",
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 0, "y": 20, "z": 0 }, "position": { "x": 0, "y": 20, "z": 0 },
"rotation": { "x": -45, "y": 0, "z": 0 }, "rotation": { "x": -45, "y": 0, "z": 0 },
@ -51,7 +51,7 @@
"num_agents": 10, "num_agents": 10,
"agent_config": { "agent_config": {
"interceptor_type": "HYDRA_70", "interceptor_type": "HYDRA_70",
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 200, "y": 20, "z": 0 }, "position": { "x": 200, "y": 20, "z": 0 },
"rotation": { "x": -60, "y": 0, "z": 0 }, "rotation": { "x": -60, "y": 0, "z": 0 },
@ -97,7 +97,7 @@
"num_agents": 10, "num_agents": 10,
"agent_config": { "agent_config": {
"interceptor_type": "HYDRA_70", "interceptor_type": "HYDRA_70",
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": -100, "y": 20, "z": 0 }, "position": { "x": -100, "y": 20, "z": 0 },
"rotation": { "x": -45, "y": 0, "z": 0 }, "rotation": { "x": -45, "y": 0, "z": 0 },
@ -145,7 +145,7 @@
"num_agents": 200, "num_agents": 200,
"agent_config": { "agent_config": {
"interceptor_type": "HYDRA_70", "interceptor_type": "HYDRA_70",
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 0, "y": 600, "z": 6000 }, "position": { "x": 0, "y": 600, "z": 6000 },
"rotation": { "x": 90, "y": 0, "z": 0 }, "rotation": { "x": 90, "y": 0, "z": 0 },
@ -163,27 +163,7 @@
} }
}, },
"submunitions_config": { "submunitions_config": {
"num_submunitions": 0, "num_submunitions": 0
"launch_config": { "launch_time": 0 },
"agent_config": {
"interceptor_type": "HYDRA_70",
"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": "IDEAL",
"frequency": 0
}
}
}
} }
} }
} }

View File

@ -72,7 +72,7 @@ This is a basic configuration featuring a single salvo with one interceptor type
{ {
"num_agents": 7, "num_agents": 7,
"agent_config": { "agent_config": {
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 0, "y": 600, "z": 6000 }, "position": { "x": 0, "y": 600, "z": 6000 },
"rotation": { "x": 90, "y": 0, "z": 0 }, "rotation": { "x": 90, "y": 0, "z": 0 },
@ -125,7 +125,7 @@ This configuration demonstrates a more complex scenario with three salvos, each
{ {
"num_agents": 200, "num_agents": 200,
"agent_config": { "agent_config": {
"target_type": "DRONE", "threat_type": "DRONE",
"initial_state": { "initial_state": {
"position": { "x": 0, "y": 600, "z": 6000 }, "position": { "x": 0, "y": 600, "z": 6000 },
"rotation": { "x": 90, "y": 0, "z": 0 }, "rotation": { "x": 90, "y": 0, "z": 0 },
@ -160,7 +160,7 @@ Multiple salvos are achieved by:
- **`num_agents`**: Number of agents (missiles or targets) in the swarm. - **`num_agents`**: Number of agents (missiles or targets) in the swarm.
- **`agent_config`**: Settings for each agent, including: - **`agent_config`**: Settings for each agent, including:
- **`interceptor_type`** / **`target_type`**: Defines the type of interceptor or threat. - **`interceptor_type`** / **`threat_type`**: Defines the type of interceptor or threat.
- **`initial_state`**: Sets the starting position, rotation, and velocity. - **`initial_state`**: Sets the starting position, rotation, and velocity.
- **`standard_deviation`**: Adds random noise to initial states for variability. - **`standard_deviation`**: Adds random noise to initial states for variability.
- **`dynamic_config`**: Time-dependent settings like `launch_time` and sensor configurations. - **`dynamic_config`**: Time-dependent settings like `launch_time` and sensor configurations.