Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement drag #111

Merged
merged 3 commits into from
Jun 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions app/src/main/java/src/land/LandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

public class LandingController
{
private final double LANDER_AREA = 1.91; // Mars InSight lander was 1.56 meters in diameter, pi * radius^2
private final double DRAG_COEFFICIENT = 2.1; // page 1187, from https://pdfs.semanticscholar.org/5410/30f5b4c387a3d5d06fbee8549347d6bddf82.pdf
private final double AIR_DENSITY = 5.428; // https://www.aero.psu.edu/avia/pubs/LanSch17.pdf, page 3
private final double LANDER_AREA = 1.91; // Mars InSight lander was 1.56 meters in diameter, pi * radius^2
private final double PARACHUTE_AREA = 1000;

protected boolean parachuteDeployed = false;

public LandingController()
{
Expand Down Expand Up @@ -51,6 +54,10 @@ public Vector3d[] plotTrajectory(Vector3d landerLocation,
while(!impact(currentState.position.get(0), currentState.position.get(1), planetRadius))
{
Logger.logCSV("landing_controller", time + "," + currentState.position.get(0).toCSV() + currentState.velocity.get(0).toCSV());

//Vector3d drag = calculateDrag(currentState.velocity.get(0));
//currentState.velocity.set(0, currentState.velocity.get(0).add(drag));

currentState = solver.step(f, time, currentState, stepSize);
trajectory.add(currentState.position.get(0));
time = time + stepSize;
Expand Down Expand Up @@ -108,7 +115,11 @@ public Vector3d calculateDrag(Vector3d velocity)
Vector3d vectorDirection = unitVector.mul(-1); //drag acts in the opposite direction in relation to the velocity.

double veloMagnitude = velocity.norm();
double constant = DRAG_COEFFICIENT * LANDER_AREA * AIR_DENSITY * veloMagnitude * veloMagnitude * 0.5;
double totalArea = LANDER_AREA;
if(parachuteDeployed)
totalArea = totalArea + PARACHUTE_AREA;

double constant = DRAG_COEFFICIENT * totalArea * AIR_DENSITY * veloMagnitude * veloMagnitude * 0.5;

Vector3d dragForce = vectorDirection.mul(constant); //scale the unit vector by the constants we have, to get the actual drag force vector
return dragForce;
Expand All @@ -125,4 +136,9 @@ protected Vector3d[] toArray(ArrayList<Vector3d> input)
}
return array;
}

protected void deployParachute()
{
parachuteDeployed = true;
}
}