Hardening your AI for terrestrial environments and SAR deployment.
The simulation is "perfect." Real sensors have noise. Real motors have friction. A model trained in a perfect simulation will fail on the first rock it sees in the real world.
Create a new script RandomizeEnv.cs and attach it to your Cave Segment.
public override void OnEpisodeBegin() {
// 1. Randomize Friction
float friction = Random.Range(0.3f, 0.9f);
GetComponent().material.dynamicFriction = friction;
// 2. Randomize Scale (Tunnel Width)
float width = Random.Range(0.8f, 1.2f);
transform.localScale = new Vector3(width, 1, 1);
// 3. Randomize Lighting (Simulate failing headlamps)
float intensity = Random.Range(0.1f, 1.0f);
RenderSettings.ambientIntensity = intensity;
}
Effect: The drone learns to fly in slippery, narrow, and dark caves—not just the "ideal" one.
Once training is complete (Mean Reward > 50), the "Brain" exists as a .onnx file.
Go to your project folder > results > CaveRun1 > CaveExplorer.onnx.
Drag this file into your Unity Project Assets folder.
CaveExplorer.onnx here.Inference Only.In a real SAR mission, the drone must return data. We simulate this with a "Homing" reward.
Modify CaveExplorerAgent.cs:
bool returningHome = false;.returningHome = true.if(returningHome) {
// Reward for getting closer to (0,0,0)
AddReward(-distanceToStart * 0.01f);
}
You have developed an autonomous navigation system.
You can now take this project, change the environment (e.g. to a forest or city), and retrain the agent for your specific Team Project needs.
Return to Workshop Home