예제 #1
0
        public void AttitudeGUI(int windowID)
        {
            if (core.Wheel
                &&
                GUILayout.Button(_RM ? "Rover" : "Attitude", GUI.skin.textField)
                )
            {
                _RM = !_RM;

                if (_RM)
                {
                    RoverState r = new RoverState();
                    r.Steer    = false;
                    r.Target   = -0;
                    r.Steering = 0;
                    r.ActTime  = Planetarium.GetUniversalTime() + (core.localControl ? 0 : core.path.ControlDelay);
                    rover.states.Enqueue(r);
                }
            }


            if (roverMode)
            {
                attitudeButtons[0].Draw();
                rover.draw();
            }
            else
            {
                foreach (AttitudeStateButton b in attitudeButtons)
                {
                    b.Draw();
                }
            }
            GUI.DragWindow();
        }
예제 #2
0
 public void setRover(RoverState StateIn)
 {
     throttlePID     = new RoverPidController(10, 1e-5F, 1e-5F, 50, 1);
     this.roverState = StateIn;
     altitude        = Vector3d.Distance(core.vessel.mainBody.position, core.vessel.transform.position);
     roverActive     = true;
     core.vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, false);
 }
예제 #3
0
        public void update()
        {
            if (sending && states.Peek().ActTime <= Planetarium.GetUniversalTime())
            {
                state               = states.Dequeue();
                state.longitude     = computer.core.vessel.longitude;
                state.latitude      = computer.core.vessel.latitude;
                state.roverRotation = computer.core.vessel.ReferenceTransform.rotation;

                computer.core.computer.setRover(state);
            }
        }
예제 #4
0
 public void setRover(RoverState StateIn)
 {
     throttlePID = new RoverPidController(10, 1e-5F, 1e-5F, 50, 1);
     this.roverState = StateIn;
     altitude = Vector3d.Distance(core.vessel.mainBody.position, core.vessel.transform.position);
     roverActive = true;
     core.vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, false);
 }
예제 #5
0
        public void draw()
        {
            GUILayout.Label((SteeringBar >= 0 ? "Right: " : "Left: ") + Math.Abs(Mathf.RoundToInt(SteeringBar * 100)) + "%", GUI.skin.textField);
            SteeringBar = GUILayout.HorizontalSlider(SteeringBar, -1, 1);

            reverse = GUILayout.Toggle(reverse, reverse ? "Reverse" : "Forward");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Speed (m/s):", GUI.skin.textField, GUILayout.Width(100));
            SpeedS = GUILayout.TextField(SpeedS, GUILayout.Width(50));
            SpeedS = RTUtils.FormatNumString(SpeedS);
            if (SpeedS == "")
            {
                SpeedS = "0";
            }

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(SpeedS);
                tmp   += 1;
                SpeedS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(SpeedS);
                tmp   -= 1;
                SpeedS = Mathf.RoundToInt(tmp).ToString();
            }

            Speed  = Mathf.Clamp(Convert.ToSingle(SpeedS), 0, float.MaxValue);
            SpeedS = Speed.ToString();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Drive (m):", GUI.skin.textField, GUILayout.Width(100));
            DistS = GUILayout.TextField(DistS, GUILayout.Width(50));
            DistS = RTUtils.FormatNumString(DistS);
            if (DistS == "")
            {
                DistS = "0";
            }

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DistS);
                tmp  += 1;
                DistS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DistS);
                tmp  -= 1;
                DistS = Mathf.RoundToInt(tmp).ToString();
            }

            Distance = Mathf.Clamp(Convert.ToSingle(DistS), 0, float.MaxValue);
            DistS    = Distance.ToString();

            if (GUILayout.Button("Send", GUI.skin.textField))
            {
                RoverState r = new RoverState();
                r.Steer     = false;
                r.Target    = Distance;
                r.Speed     = Speed;
                r.reverse   = reverse;
                r.Steering  = 0;
                lastActTime = r.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? 0 : computer.core.path.ControlDelay);
                states.Enqueue(r);
            }

            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();

            GUILayout.Label("Turn (°):", GUI.skin.textField, GUILayout.Width(100));
            DegS = GUILayout.TextField(DegS, GUILayout.Width(50));
            DegS = RTUtils.FormatNumString(DegS);
            if (DegS == "")
            {
                DegS = "0";
            }

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DegS);
                tmp += 1;
                DegS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DegS);
                tmp -= 1;
                DegS = Mathf.RoundToInt(tmp).ToString();
            }

            Degrees = Mathf.Clamp(Convert.ToSingle(DegS), 0, 90);
            DegS    = Degrees.ToString();

            if (GUILayout.Button("Send", GUI.skin.textField))
            {
                RoverState r = new RoverState();
                r.Steer     = true;
                r.Target    = Degrees;
                r.Speed     = Speed;
                r.reverse   = reverse;
                r.Steering  = Mathf.RoundToInt(SteeringBar * 100) == 0 ? 0 : -SteeringBar;
                lastActTime = r.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? 0 : computer.core.path.ControlDelay);
                states.Enqueue(r);
            }

            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();
            GUILayout.Label(sending ? "Sending " + computer.arrows :
                            (computer.core.computer.roverActive ? DriveDescript : "")
                            , GUI.skin.textField);
            GUILayout.Label(sending ? RTUtils.time(lastActTime - Planetarium.GetUniversalTime()) : (computer.core.computer.roverActive ? TargetDescript : "")
                            , GUI.skin.textField, GUILayout.Width(100));
            GUILayout.EndHorizontal();
        }
예제 #6
0
        public void update()
        {
            if (sending && states.Peek().ActTime <= Planetarium.GetUniversalTime())
            {
                state = states.Dequeue();
                state.longitude = computer.core.vessel.longitude;
                state.latitude = computer.core.vessel.latitude;
                state.roverRotation = computer.core.vessel.ReferenceTransform.rotation;

                computer.core.computer.setRover(state);
            }
        }
예제 #7
0
        public void draw()
        {
            GUILayout.Label((SteeringBar >= 0 ? "Right: " : "Left: ") + Math.Abs(Mathf.RoundToInt(SteeringBar * 100)) + "%", GUI.skin.textField);
            SteeringBar = GUILayout.HorizontalSlider(SteeringBar, -1, 1);

            reverse = GUILayout.Toggle(reverse, reverse ? "Reverse" : "Forward");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Speed (m/s):", GUI.skin.textField, GUILayout.Width(100));
            SpeedS = GUILayout.TextField(SpeedS, GUILayout.Width(50));
            SpeedS = RTUtils.FormatNumString(SpeedS);
            if (SpeedS == "")
                SpeedS = "0";

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(SpeedS);
                tmp += 1;
                SpeedS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(SpeedS);
                tmp -= 1;
                SpeedS = Mathf.RoundToInt(tmp).ToString();
            }

            Speed = Mathf.Clamp(Convert.ToSingle(SpeedS), 0, float.MaxValue);
            SpeedS = Speed.ToString();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Drive (m):", GUI.skin.textField, GUILayout.Width(100));
            DistS = GUILayout.TextField(DistS, GUILayout.Width(50));
            DistS = RTUtils.FormatNumString(DistS);
            if (DistS == "")
                DistS = "0";

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DistS);
                tmp += 1;
                DistS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DistS);
                tmp -= 1;
                DistS = Mathf.RoundToInt(tmp).ToString();
            }

            Distance = Mathf.Clamp(Convert.ToSingle(DistS), 0, float.MaxValue);
            DistS = Distance.ToString();

            if (GUILayout.Button("Send", GUI.skin.textField))
            {
                RoverState r = new RoverState();
                r.Steer = false;
                r.Target = Distance;
                r.Speed = Speed;
                r.reverse = reverse;
                r.Steering = 0;
                lastActTime = r.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? 0 : computer.core.path.ControlDelay);
                states.Enqueue(r);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Turn (°):", GUI.skin.textField, GUILayout.Width(100));
            DegS = GUILayout.TextField(DegS, GUILayout.Width(50));
            DegS = RTUtils.FormatNumString(DegS);
            if (DegS == "")
                DegS = "0";

            if (GUILayout.Button("+", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DegS);
                tmp += 1;
                DegS = Mathf.RoundToInt(tmp).ToString();
            }
            if (GUILayout.Button("-", GUI.skin.textField, GUILayout.Width(21.0F)))
            {
                float tmp = Convert.ToSingle(DegS);
                tmp -= 1;
                DegS = Mathf.RoundToInt(tmp).ToString();
            }

            Degrees = Mathf.Clamp(Convert.ToSingle(DegS), 0, 90);
            DegS = Degrees.ToString();

            if (GUILayout.Button("Send", GUI.skin.textField))
            {
                RoverState r = new RoverState();
                r.Steer = true;
                r.Target = Degrees;
                r.Speed = Speed;
                r.reverse = reverse;
                r.Steering = Mathf.RoundToInt(SteeringBar * 100) == 0 ? 0 : -SteeringBar;
                lastActTime = r.ActTime = Planetarium.GetUniversalTime() + (computer.core.localControl ? 0 : computer.core.path.ControlDelay);
                states.Enqueue(r);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(sending ? "Sending " + computer.arrows :
                (computer.core.computer.roverActive ? DriveDescript : "")
            , GUI.skin.textField);
            GUILayout.Label(sending ? RTUtils.time(lastActTime - Planetarium.GetUniversalTime()) : (computer.core.computer.roverActive ? TargetDescript : "")
                , GUI.skin.textField, GUILayout.Width(100));
            GUILayout.EndHorizontal();
        }
예제 #8
0
        public void AttitudeGUI(int windowID)
        {
            if (core.Wheel
                &&
                GUILayout.Button(_RM ? "Rover" : "Attitude", GUI.skin.textField)
                )
            {
                _RM = !_RM;

                if (_RM)
                {
                    RoverState r = new RoverState();
                    r.Steer = false;
                    r.Target = -0;
                    r.Steering = 0;
                    r.ActTime = Planetarium.GetUniversalTime() + (core.localControl ? 0 : core.path.ControlDelay);
                    rover.states.Enqueue(r);
                }
            }

            if (roverMode)
            {
                attitudeButtons[0].Draw();
                rover.draw();
            }
            else
                foreach (AttitudeStateButton b in attitudeButtons)
                {
                    b.Draw();
                }
            GUI.DragWindow();
        }