Beispiel #1
0
        private IEnumerator OnApplyClick()
        {
            yield return(null);

            if (mFlightComputer.InputAllowed)
            {
                kp = RTUtil.ConstrictNum(kp, false);
                ki = RTUtil.ConstrictNum(ki, false);
                kd = RTUtil.ConstrictNum(kd, false);

                mFlightComputer.Enqueue(PIDCommand.WithNewChanges(Double.Parse(kp), Double.Parse(ki), Double.Parse(kd)));
            }
        }
Beispiel #2
0
        private void HDG()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl().StartsWith("RC"))
            {
                mFlightComputer.Enqueue(DriveCommand.DistanceHeading(Dist, Heading, mSteerClamp, Speed));
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Wheel: ", "How sharp to turn at max"));
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max"));
                GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Hdg.", "Heading to keep"), GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref Mheading, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Dist.", "Distance to drive"), GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Speed", "Speed to keep"), GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", "Speed to keep"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            Mheading = RTUtil.ConstrictNum(Mheading, 360);
            mDist    = RTUtil.ConstrictNum(mDist, false);
            mSpeed   = RTUtil.ConstrictNum(mSpeed, false);
        }
Beispiel #3
0
        private void DrawHDGContent()
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_HDGSteer"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"Steer: ", "How sharp to turn at max"
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc")));                      //"How sharp to turn at max"
                GUILayout.Label(new GUIContent("max", Localizer.Format("#RT_RoverFragment_HDGSteer_desc")), GUILayout.Width(40));                     //"How sharp to turn at max"
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_mHdg"), Localizer.Format("#RT_RoverFragment_mHdg_desc")), GUILayout.Width(50));//"Hdg", "Heading to maintain"
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mHeading, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Dist"), Localizer.Format("#RT_RoverFragment_Dist_desc")), GUILayout.Width(50));//"Dist", "Distance to drive"
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain"
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain"
            }
            GUILayout.EndHorizontal();

            mHeading = RTUtil.ConstrictNum(mHeading, 360);
            mDist    = RTUtil.ConstrictNum(mDist, false);
            mSpeed   = RTUtil.ConstrictNum(mSpeed, false);
        }
Beispiel #4
0
        private void DrawHDGContent()
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Steer: ", "How sharp to turn at max"));
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max"));
                GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Hdg", "Heading to maintain"), GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mHeading, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Dist", "Distance to drive"), GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Speed", "Speed to maintain"), GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", "Speed to maintain"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            mHeading = RTUtil.ConstrictNum(mHeading, 360);
            mDist    = RTUtil.ConstrictNum(mDist, false);
            mSpeed   = RTUtil.ConstrictNum(mSpeed, false);
        }
Beispiel #5
0
        private void DrawTargetContent()
        {
            string      targetTypeString = Localizer.Format("#RT_RoverFragment_coordinations");                                      //"Body coordinations"
            string      tooltip          = Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name); //"Hold " +  + " and click on ground to input coordinates"
            ITargetable Target           = mFlightComputer.Vessel.targetObject;

            if (GameSettings.MODIFIER_KEY.GetKey() && ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) != MouseClick)) // on lookout for mouse click on body
            {
                MouseClick = Input.GetMouseButton(0) || Input.GetMouseButton(1);
                Vector2 latlon;
                if (MouseClick && RTUtil.CBhit(mFlightComputer.Vessel.mainBody, out latlon))
                {
                    Latitude  = latlon.x;
                    Longitude = latlon.y;
                }
            }
            else if (Target != null) // only if target is vessel not world coord
            {
                if (Target.GetType().ToString().Equals("Vessel"))
                {
                    Vessel TargetVessel = Target as Vessel;
                    Latitude         = (float)TargetVessel.latitude;
                    Longitude        = (float)TargetVessel.longitude;
                    targetTypeString = Localizer.Format("#RT_RoverFragment_TargetVessel");      //"Designated Vessel"
                    tooltip          = Localizer.Format("#RT_RoverFragment_TargetVessel_desc"); //"Drive to this vessel"
                }
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_HDGSteer"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"Steer: ", "How sharp to turn at max"
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc")));                      //"How sharp to turn at max"
                GUILayout.Label(new GUIContent("max", Localizer.Format("#RT_RoverFragment_HDGSteer_desc")), GUILayout.Width(40));                     // "How sharp to turn at max"
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_ModeLabel", targetTypeString), tooltip));//"Mode: "

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_LAT"), Localizer.Format("#RT_RoverFragment_LAT_desc")), GUILayout.Width(50));//"LAT", "Latitude to drive to"
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name)), GUI.skin.textField, GUILayout.Width(40));//"Hold " +  + " and click on ground to input coordinates"
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_LON"), Localizer.Format("#RT_RoverFragment_LON_desc")), GUILayout.Width(50));//"LON", "Longitude to drive to"
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name)), GUI.skin.textField, GUILayout.Width(40));//"Hold " +  + " and click on ground to input coordinates"
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain"
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain"
            }
            GUILayout.EndHorizontal();


            mLatitude   = RTUtil.ConstrictNum(mLatitude);
            mLongditude = RTUtil.ConstrictNum(mLongditude);
            mSpeed      = RTUtil.ConstrictNum(mSpeed, false);
        }
Beispiel #6
0
        private void DrawFineContent()
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_FINESteer"), Localizer.Format("#RT_RoverFragment_FINESteer_desc")));//"Steer: ", "How much to turn"
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(Math.Abs(mSteering).ToString("P"), ""));
                if (mSteering != 0)
                {
                    if (mSteering < 0)
                    {
                        GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_right"), ""), GUILayout.Width(40));//"right"
                    }
                    else
                    {
                        GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_left"), ""), GUILayout.Width(40)); //"left"
                    }
                }
                else
                {
                    GUILayout.Label(new GUIContent("", ""), GUILayout.Width(40));
                }
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteering, 1, -1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Turn"), Localizer.Format("#RT_RoverFragment_Turn_desc")), GUILayout.Width(50));//"Turn", "How many degrees to turn"
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mTurn, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_Turn_desc")), GUI.skin.textField, GUILayout.Width(40));//, "How many degrees to turn"
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Dist"), Localizer.Format("#RT_RoverFragment_Dist_desc")), GUILayout.Width(50));//"Dist", "Distance to drive"
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m)", Localizer.Format("#RT_RoverFragment_Dist_desc")), GUI.skin.textField, GUILayout.Width(40));//"Distance to drive"
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_Speed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain, negative for reverse"
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("#RT_RoverFragment_Speed_desc")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain, negative for reverse"
            }
            GUILayout.EndHorizontal();

            mTurn  = RTUtil.ConstrictNum(mTurn, 90);
            mDist  = RTUtil.ConstrictNum(mDist, false);
            mSpeed = RTUtil.ConstrictNum(mSpeed);


            if (prevTurn != Turn)
            {
                distDefault = false;
            }
            else if (prevDist != Dist)
            {
                distDefault = true;
            }

            prevTurn = Turn;
            prevDist = Dist;
        }
Beispiel #7
0
        private void Target()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl().StartsWith("RC"))
            {
                mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed));
            }
            else if (GameSettings.MODIFIER_KEY.GetKey() && ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) != MouseClick))
            {
                MouseClick = Input.GetMouseButton(0) || Input.GetMouseButton(1);
                Vector2 latlon;
                if (MouseClick && RTUtil.CBhit(mFlightComputer.Vessel.mainBody, out latlon))
                {
                    Latitude  = latlon.x;
                    Longitude = latlon.y;

                    if (Input.GetMouseButton(1))
                    {
                        mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed));
                    }
                }
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Wheel: ", "How sharp to turn at max"));
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max"));
                GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("LAT.", "Latitude to drive to"), GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(°)", "Hold " + GameSettings.MODIFIER_KEY.name + " and click on ground to input coordinates"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("LON.", "Longitude to drive to"), GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(°)", "Hold " + GameSettings.MODIFIER_KEY.name + " and click on ground to input coordinates"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Speed", "Speed to keep"), GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", "Speed to keep"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();


            mLatitude   = RTUtil.ConstrictNum(mLatitude);
            mLongditude = RTUtil.ConstrictNum(mLongditude);
            mSpeed      = RTUtil.ConstrictNum(mSpeed, false);
        }
Beispiel #8
0
        private void Fine()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && Speed != 0)
            {
                if (GUI.GetNameOfFocusedControl() == "RC1" && mSteering != 0 && Turn != 0)
                {
                    EnqueueTurn();
                }
                else if (GUI.GetNameOfFocusedControl() == "RC2" && Dist != 0)
                {
                    EnqueueDist();
                }
                else if (GUI.GetNameOfFocusedControl() == "RC3")
                {
                    if (!distDefault && mSteering != 0 && Turn != 0)
                    {
                        EnqueueTurn();
                    }
                    else if (distDefault && Dist != 0)
                    {
                        EnqueueDist();
                    }
                }
            }


            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Wheel: ", "how much to turn"));
                GUILayout.FlexibleSpace();
                GUILayout.Label(new GUIContent(Math.Abs(mSteering).ToString("P"), "How much to turn"));
                if (mSteering != 0)
                {
                    if (mSteering < 0)
                    {
                        GUILayout.Label(new GUIContent("right", "how much to turn"), GUILayout.Width(40));
                    }
                    else
                    {
                        GUILayout.Label(new GUIContent("left", "how much to turn"), GUILayout.Width(40));
                    }
                }
                else
                {
                    GUILayout.Label(new GUIContent("", "how much to turn"), GUILayout.Width(40));
                }
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteering, 1, -1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Turn", "How many degrees to turn"), GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mTurn, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(°)", "How many degrees to turn"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Dist.", "Distance to drive"), GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m)", "Distance to drive"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(new GUIContent("Speed", "Speed to keep, negative for reverse"), GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label(new GUIContent("(m/s)", "Speed to keep, negative for reverse"), GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            mTurn  = RTUtil.ConstrictNum(mTurn, 90);
            mDist  = RTUtil.ConstrictNum(mDist, false);
            mSpeed = RTUtil.ConstrictNum(mSpeed);


            if (prevTurn != Turn)
            {
                distDefault = false;
            }
            else if (prevDist != Dist)
            {
                distDefault = true;
            }

            prevTurn = Turn;
            prevDist = Dist;
        }