예제 #1
0
        public override void drive(FlightControl control)
        {
            _drive(control);

            control.yaw *= _sensetivity.value;
            control.pitch *= _sensetivity.value;
            control.roll *= _sensetivity.value;
        }
예제 #2
0
파일: Core.cs 프로젝트: sopindm/bjeb
        protected override void onDrive(FlightCtrlState s)
        {
            if(_vessel == null)
                return;

            game.FlightControl control = new game.FlightControl();

            control.update(s);
            _vessel.updateState(this.vessel);

            _protocol.requestControl(_vessel, control);

            control.apply(s);
        }
예제 #3
0
        public FlightControl copy()
        {
            FlightControl ret = new FlightControl();

            ret.throttle = throttle;

            ret.yaw = yaw;
            ret.pitch = pitch;
            ret.roll = roll;

            ret.dx = dx;
            ret.dy = dy;
            ret.dz = dz;

            return ret;
        }
예제 #4
0
        public FlightControl copy()
        {
            FlightControl ret = new FlightControl();

            ret.throttle = throttle;

            ret.yaw   = yaw;
            ret.pitch = pitch;
            ret.roll  = roll;

            ret.dx = dx;
            ret.dy = dy;
            ret.dz = dz;

            return(ret);
        }
예제 #5
0
        protected override void onDrive(FlightCtrlState s)
        {
            if (_vessel == null)
            {
                return;
            }

            game.FlightControl control = new game.FlightControl();

            control.update(s);
            _vessel.updateState(this.vessel);

            _protocol.requestControl(_vessel, control);

            control.apply(s);
        }
예제 #6
0
파일: Computer.cs 프로젝트: sopindm/bjeb
 public void onControl(FlightControl control)
 {
     attitude.drive(control);
 }
예제 #7
0
        private void _drive(FlightControl c)
        {
            double rollDelta = Math.Abs(vessel.rotation.roll - _lastRoll);
            if (rollDelta > Math.PI)
                rollDelta = 2 * Math.PI - rollDelta;
            if (rollDelta > Math.PI / 36)
            {
                _controller.reset();
                _lastRoll = vessel.rotation.roll;
            }

            Quaternion delta = vessel.rotation.inverse * target;

            Vector3 err = new Vector3((delta.pitch > Math.PI) ? (delta.pitch - 2 * Math.PI) : delta.pitch,
                                      (delta.yaw > Math.PI) ? (delta.yaw - 2 * Math.PI) : delta.yaw,
                                      (delta.roll > Math.PI) ? (delta.roll - 2 * Math.PI) : delta.roll);

            err = new Vector3(controlPitch == Control.KillRotation ? 0 : err.x,
                              controlYaw == Control.KillRotation ? 0 : err.y,
                              controlRoll == Control.KillRotation ? 0 : err.z);

            Vector3 torque = vessel.body.torque;

            Vector3 inertia = vessel.body.angularMomentum.sign *
                vessel.body.angularMomentum * vessel.body.angularMomentum *
                (torque * vessel.body.momentumOfInertia).invert;

            err += inertia;
            err *= vessel.body.momentumOfInertia * torque.invert;

            Vector3 act = _controller.compute(err, vessel.mainBody.universe.fixedDeltaTime);

            double precision = (Math.Min(vessel.body.torque.x, vessel.body.torque.y) * 20.0 / vessel.body.momentumOfInertia.magnitude).clamp(0.5, 10);
            double driveLimit = (err.magnitude * driveFactor / precision).clamp(0, 1);

            act = act.clamp(-driveLimit, driveLimit);

            act = _act + (act - _act) * (vessel.mainBody.universe.fixedDeltaTime / Tf);

            setControls(act, c, driveLimit);

            _act = new Vector3(c.pitch, c.yaw, c.roll);
        }
예제 #8
0
 private void setControls(Vector3 act, FlightControl c, double driveLimit)
 {
     control(act.z, driveLimit, controlRoll, ref c.roll);
     control(act.x, driveLimit, controlPitch, ref c.pitch);
     control(act.y, driveLimit, controlYaw, ref c.yaw);
 }
예제 #9
0
파일: Module.cs 프로젝트: sopindm/bjeb
 public abstract void drive(FlightControl c);