Skip to content

Commit

Permalink
Changes output of PlotTrajectory
Browse files Browse the repository at this point in the history
  • Loading branch information
S010MON committed Jun 20, 2021
1 parent 8f98d6e commit fe10301
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/src/main/java/src/land/OpenLoopController.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public OpenLoopController()

}

public Vector3d[] plotTrajectory(Vector3d landerLocation,
public ArrayList<LanderObject> plotTrajectory(Vector3d landerLocation,
Vector3d landerVelocity,
double landerMass,
Vector3d planetLocation,
Expand All @@ -41,23 +41,27 @@ public Vector3d[] plotTrajectory(Vector3d landerLocation,
State currentState = new State(velocities, positions);
ODESolver solver = new Verlet();
ODEFunctionInterface f = new NewtonGravityFunction(masses);
ArrayList<Vector3d> trajectory = new ArrayList<Vector3d>();

ArrayList<LanderObject> trajectory = new ArrayList<LanderObject>();

Logger.logCSV("openloop_controller", "Time,Pos X, Pos Y, Pos Z, Vel X, Vel Y, Vel Z");
double time = 0;
double stepSize = 0.1;
while(!testHeight(currentState.position.get(0), currentState.position.get(1), planetRadius))
{
Logger.logCSV("openloop_controller", time + "," + currentState.position.get(0).toCSV() + currentState.velocity.get(0).toCSV());
currentState = solver.step(f, time, currentState, stepSize);
trajectory.add(currentState.position.get(0));
trajectory.add(new LanderObject(currentState.position.get(0), 0));
time = time + stepSize;
if (testHeight(currentState.position.get(0),planetLocation,height)) {

if (testHeight(currentState.position.get(0),planetLocation,height))
{
Vector3d maxThrust = new Vector3d(0,1000,0);
currentState.velocity.get(0).add(maxThrust);
}
}

return toArray(trajectory);
return trajectory;
}


Expand Down

0 comments on commit fe10301

Please sign in to comment.