private bool fastMove() { TimeSpan ts = befTime - DateTime.UtcNow; //double ang = (motor.Angle - motor.BefAngle); double diffAngle = DataEntity.GetTargetAngle() - MathHelperD.ToDegrees(MyMotor.Angle); double rad = MathHelperD.ToRadians(diffAngle) / (-0.03); if (DataEntity.GetVelocity() < Math.Abs(rad * 9.549)) { MyMotor.TargetVelocityRPM = MathHelperD.ToDegrees(rad) < 0 ? DataEntity.GetVelocity() : -DataEntity.GetVelocity(); } else { MyMotor.TargetVelocityRad = -(float)(rad / 2); } befTime = DateTime.UtcNow; BefAngleDegree = MathHelperD.ToDegrees(MyMotor.Angle); if (Math.Abs(MathHelperD.ToDegrees(MyMotor.Angle) - DataEntity.GetTargetAngle()) < 1) { MyMotor.TargetVelocityRad = 0; return(true); } else { return(false); } }
private bool justMove() { TimeSpan ts = befTime - nowTime; double ang = (MathHelperD.ToDegrees(MyMotor.Angle) - BefAngleDegree); double diffAngle = DataEntity.GetTargetAngle() - (MathHelperD.ToDegrees(MyMotor.Angle)); double rad = MathHelperD.ToRadians(diffAngle) / ts.TotalSeconds; if (diffAngle > rad) { MyMotor.TargetVelocityRPM = DataEntity.GetVelocity(); } else { MyMotor.TargetVelocityRPM = (float)(diffAngle / (Math.PI * 2)); } BefAngleDegree = MathHelperD.ToDegrees(MyMotor.Angle); if ((MathHelperD.ToDegrees(MyMotor.Angle) - DataEntity.GetTargetAngle()) < 0.5) { MyMotor.TargetVelocityRad = 0; return(true); } else { return(false); } }