Exemple #1
0
 void StopTranslation()
 {
     if (currentDirectionState != DirectionalMotionState.STRAIGHT)
     {
         webView.Eval("wsSendCommand ('command',  'walkX 100');");
     }
     currentDirectionState = DirectionalMotionState.STRAIGHT;
 }
Exemple #2
0
        void TranslateRight()
        {
            if (currentDirectionState == DirectionalMotionState.RIGHT)
            {
                return;
            }

            if (currentDirectionState == DirectionalMotionState.LEFT)
            {
                StopTranslation();
            }
            webView.Eval("wsSendCommand ('command',  'walkX 130');");
            currentDirectionState = DirectionalMotionState.RIGHT;
        }
Exemple #3
0
        public MotionPage()
        {
            InitializeComponent();

            var defaultColor = goForwardButton.BackgroundColor;

            rotationSlider.Maximum       = 130;
            rotationSlider.Minimum       = 70;
            rotationSlider.Value         = 100;
            rotationSlider.ValueChanged += (sender, e) => {
                if (e.NewValue > 80 && e.NewValue < 110)
                {
                    StopTranslation();
                }
                else if (e.NewValue < 100)
                {
                    TranslateLeft();
                }
                else
                {
                    TranslateRight();
                }
            };

            currentDirectionState = DirectionalMotionState.STRAIGHT;
            currentScalarState    = ScalarMotionState.STOPPED;

            joyStickTranslation.OnValueChanged += (float xPos, float yPos) => {
                Debug.WriteLine("" + xPos + ", " + yPos);
                if (xPos > 0.5)
                {
                    TranslateRight();
                }
                else if (xPos < -0.5)
                {
                    TranslateLeft();
                }
                else
                {
                    StopTranslation();
                }

                if (yPos > 0.5)
                {
                    GoBackScalar();
                }
                else if (yPos < -0.5)
                {
                    GoForwardScalar();
                }
                else
                {
                    StopMoving();
                }
            };

            joyStickRotation.OnValueChanged += (float xPos, float yPos) => {
                if (xPos > 0.5)
                {
                    RotateRight();
                }
                else if (xPos < -0.5)
                {
                    RotateLeft();
                }
                else
                {
                    StopRotation();
                }
            };

            stopButton.Clicked += async(object sender, EventArgs e) => {
                StopMoving();
                StopTranslation();
                StopRotation();
                await stopButton.AnimateButton();

                goForwardButton.BackgroundColor = defaultColor;
                goBackButton.BackgroundColor    = defaultColor;
                StopAnimationSpider();
            };


            goForwardButton.Clicked += async(object sender, EventArgs e) => {
                GoForwardScalar();
                await goForwardButton.AnimateButton();

                goForwardButton.BackgroundColor = Color.Red;
                goBackButton.BackgroundColor    = defaultColor;

                if (!animating)
                {
                    StartAnimationSpider();
                }
            };

            goBackButton.Clicked += async(object sender, EventArgs e) => {
                GoBackScalar();
                await goBackButton.AnimateButton();

                goForwardButton.BackgroundColor = defaultColor;
                goBackButton.BackgroundColor    = Color.Red;

                if (!animating)
                {
                    StartAnimationSpider();
                }
            };
        }