Mars lander

Landing on Mars is hard.

One of the main difficulties is that the atmosphere isn't thick enough to stop a landing craft. It can slow the lander enough to deploy a parachute, and the parachute can slow the lander to a few tens of metres per second. But that isn't slow enough - the crash would be comparable to hitting a concrete block while breaking the speed limit on a motorway.

Another challenge is that the journey from leaving earth to deploying the solar panels has many steps, and testing them all accurately is very difficult. Each needs to succeed.

The simulation here is meant to show how some of the steps involved in landing a space probe on Mars would work.

The simulation is loosely based around the Schiaparelli Probe, but the details are slightly different. The suspected failure that lead to the loss of the Schiaparelli probe isn't replicated here because it's a 2-dimensional simulation.

The simulation here is made slightly easier by the lack of a requirement to ditch the parachute. The real probe had to ditch the parachute, and then fly to the ground, landing away from where the parachute might drift.

The simulation is below. Edit the javascript and press submit to control the spacecraft. An example script is there to show how the spacecraft can be controlled, but the example won't manage to land the probe.

Planet

1000 km

100 km

10 km

1 km

100 m

20 m

100x

30x

10x

3x

1x - Normal Speed

{ timestep:function(dt, sensors, output, state){ if (state.releaseHeatShield){ if (!state.parachuteCut){ output.parachuteCut = true; state.parachuteCut = true; } if (sensors.velocityVertical > 4){ output.retrosLeft = true; state.retroTime += dt * 0.5; } } if (sensors.pressure > 1) { output.releaseHeatShield = true; state.releaseHeatShield = true; } output.parachuteDeploy = true; if (!state.retroTime){ state.retroTime = 0; } if (state.retroTime < 1){ output.retrosLeft=true; state.retroTime += dt * 0.5; } var vy = sensors.velocityVertical; var vx = sensors.velocityHorizontal; var d = sensors.altitude + 3.39e6; var L = vx * d; var energy = 0.5 * (vx*vx+vy*vy) - 4.28271042e13 / d; var a = energy; var c = - 0.5 * L * L; var b = 4.28271042e13 ; var minH = (-b + Math.sqrt(b*b - 4*a*c))/(2*a) - 3.39e6; var maxH = (-b - Math.sqrt(b*b - 4*a*c))/(2*a) - 3.39e6; if (sensors.pressure < 1e-4){ var angle = sensors.angle*180 / Math.PI; if (angle > 260 && angle < 280) { output.messages[6]='retros'; output.retrosLeft=true; output.retrosRight=true; state.retroTime += dt; } } output.messages[0] = 'radar altitude = ' + (sensors.radarLeft|0); output.messages[1] = 'pressure = ' + (sensors.pressure|0); output.messages[2] = 'angle = ' + (angle); output.messages[3] = 'vh = ' + (sensors.velocityHorizontal | 0); output.messages[4] = 'vv = ' + (sensors.velocityVertical |0); output.messages[5] = 'retroTime = ' + (state.retroTime ); output.messages[6] = 'orbit = ' + ((minH / 1000)|0) + " to " + (maxH); } }

Submit Code

Instructions

A parachute, which will break if you open it going too fast at too high a pressure.

A heat shield, which blocks the radars, but protects the ship from reentry heat.

Two radars, each telling the distance to ground along a certain direction. The two radars are pointing at slightly different angles from the vertical.

Other sensors.

Two thrusters - a left thruster and a right thruster. In total, there are a hundred seconds of fuel.

var sensors = { pressure: pressure * factor, // accuracy is limited at speed. radarLeft: radarLeft, // accurate if heatshield released and low enough radarRight: radarRight, // accurate if heatshield released and low enough angle: angle, // inaccurate in atmo altitude: altitude, // inaccurate in atmo velocityVertical: vv, // inaccurate in atmo unless radar working velocityHorizontal: vh, // inaccurate in atmo unless radar working acceleration: magnitude(acceleration) // accurate, scalar };

var output = { parachuteDeploy: false, parachuteCut: false, releaseHeatShield: false, retrosLeft: false, retrosRight: false, messages: [] };

Your aim is to touch the ground at a speed of 6 m/s or preferably less.To help you with that, you have the following:The thrusters will be necessary both for hitting the planet at the right angle, and slowing for the final descent.Your task is to write a javascript program to control the lander. The important part is the timestep function, which takes as input the timestep length (dt), the sensors object, the output object and a state object.The sensors object looks like this:Angles are in radians. Velocities and acceleration are in m/s and m/s/s. Distances in m. Pressure in Pa.The output object looks like this:The state object is persistent from timestep to timestep: If you create a field in it, the field will still be there next timestep.