// Emulate sensor inputs since we don't actually have sensors public void GetSensorData() { // Get sensor data - altimeter altitude = (altitude - velocity) > 0 ? (altitude - velocity) : 0; // Get sensor data - velocity double averageThrust = ((AxialAlpha.GetThrust() + AxialBeta.GetThrust() + AxialCharlie.GetThrust()) / 3); double Gravity = guidanceTrajectory.GetGravity(); velocity = velocity - averageThrust + Gravity; }
private void InitDataRecorder() { string filePath = Application.ExecutablePath + @"\DAT\"; filePath = filePath.Replace(Application.ProductName, "").Replace(".exe", ""); if (!(Directory.Exists(filePath))) { Directory.CreateDirectory(filePath); } filePath += @"flight-recorder-" + System.DateTime.Now.ToLongTimeString().Replace(":", "").Replace(" ", "").Replace("AM", "").Replace("PM", "") + ".csv"; DataRecorderCSV = new StreamWriter(filePath, false); DataRecorderCSV.WriteLine("Configuration loaded:"); DataRecorderCSV.WriteLine("Axial Thrust: " + AxialAlpha.GetThrust()); DataRecorderCSV.WriteLine("Gravity: " + guidanceTrajectory.GetGravity()); DataRecorderCSV.WriteLine("Parachute Terminal Velocity: " + guidanceTrajectory.GetParachuteTerminalVelocity()); DataRecorderCSV.WriteLine("Parachute Release Height: " + guidanceTrajectory.GetParachuteTerminalVelocity()); DataRecorderCSV.WriteLine("Engine Cut Height: " + guidanceTrajectory.GetDropHeight()); DataRecorderCSV.WriteLine("Slow Descent Height: " + guidanceTrajectory.GetTargetDescentVelocitySmallAltitude()); DataRecorderCSV.WriteLine("Target High Altitude Fall Speed: " + guidanceTrajectory.GetTargetDescentVelocityLarge()); DataRecorderCSV.WriteLine("Target Low Altitude Fall Speed: " + guidanceTrajectory.GetTargetDescentVelocitySmall()); DataRecorderCSV.WriteLine("\n\nAltitude, Velocity, Throttle"); }
private bool RunThrottleTest(ref AxialThruster testThruster, double throttleTest, int resultTest) { // Try setting throttle try { testThruster.SetThrottle(throttleTest); } catch { if (resultTest != -1) { // Log a failure or output message return(false); } } // Try getting throttle if (resultTest == -1) { try { if (testThruster.GetThrottle() != 0) { Debug.Write(testThruster.GetThrottle()); // Log a failure or output message return(false); } } catch { // Log a failure or output message return(false); } } else { if (testThruster.GetThrottle() != throttleTest) { // Log a failure or output message return(false); } } // Try getting thrust if (resultTest == -1) { try { if (testThruster.GetThrust() != 0) { // Log a failure or output message return(false); } } catch { // We expect failure possibilities depending on input } } else { try { if (testThruster.GetThrust() != resultTest) { // Log a failure or output message return(false); } } catch { // Log a failure or output message return(false); } } // Get generated thrust try { if (testThruster.GetThrustGenerated() != 24) { // Log a failure or output message return(false); } } catch { return(false); } // Nothing else made us fail, so it looks good return(true); }