/// <summary> /// 初始化飞行器。 /// </summary> /// <param name="propeller1Pin">飞行器1号动力装置的引脚编号。</param> /// <param name="propeller2Pin">飞行器2号动力装置的引脚编号。</param> /// <param name="propeller3Pin">飞行器3号动力装置的引脚编号。</param> /// <param name="propeller4Pin">飞行器4号动力装置的引脚编号。</param> /// <param name="computingMode">飞行器控制程序的计算模式。</param> public static void Initialize(int propeller1Pin, int propeller2Pin, int propeller3Pin, int propeller4Pin, ComputingMode computingMode) { _status = new MiniquadStatus(propeller1Pin, propeller2Pin, propeller3Pin, propeller4Pin); _computingMode = computingMode; // Initialize the algorithm IncrementPIDFlyingControllingAlgorithm.Initialize(); }
/// <summary> /// 获取调整后的飞行器油门输出。(根据当前的飞行器状态。) /// </summary> /// <returns>返回一个 int[] 数组表示四个油门的输出。</returns> public static int[] GetAdjustedThrottleOutputs_PC() { if (_status == null) { return(null); } //// Static PID //StaticPIDFlyingControllingAlgorithm.Angle_pitch = _status.YawPitchRoll.Pitch; //StaticPIDFlyingControllingAlgorithm.Angle_roll = _status.YawPitchRoll.Roll; //StaticPIDFlyingControllingAlgorithm.Angle_yaw = _status.YawPitchRoll.Yaw; //StaticPIDFlyingControllingAlgorithm.Accel_z = _status.Acceleration.Z; //return StaticPIDFlyingControllingAlgorithm.GetThrottleOutputs(); // Increment PID IncrementPIDFlyingControllingAlgorithm.Angle_pitch = _status.YawPitchRoll.Pitch; IncrementPIDFlyingControllingAlgorithm.Angle_roll = _status.YawPitchRoll.Roll; IncrementPIDFlyingControllingAlgorithm.Angle_yaw = _status.YawPitchRoll.Yaw; IncrementPIDFlyingControllingAlgorithm.Accel_z = _status.Acceleration.Z; IncrementPIDFlyingControllingAlgorithm.Rotation_xpi = _status.Rotation.X; IncrementPIDFlyingControllingAlgorithm.Rotation_ypi = _status.Rotation.Y; IncrementPIDFlyingControllingAlgorithm.Rotation_zpi = _status.Rotation.Z; return(IncrementPIDFlyingControllingAlgorithm.GetThrottleOutputs()); }
/// <summary> /// 初始化飞行器。 /// </summary> public static void Initialize() { // Initialize the algorithm IncrementPIDFlyingControllingAlgorithm.Initialize(); }