protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            string IP       = Intent.GetStringExtra("IP");
            string StreamIP = Intent.GetStringExtra("Stream IP");
            string username = Intent.GetStringExtra("Username");
            string password = Intent.GetStringExtra("Password");

            var MainActivity = new Intent(this, typeof(MainActivity));


            try
            {
                SetContentView(Resource.Layout.layout1);
                Forward         = FindViewById <Button>(Resource.Id.button1);
                Backward        = FindViewById <Button>(Resource.Id.button2);
                Left            = FindViewById <Button>(Resource.Id.button3);
                Right           = FindViewById <Button>(Resource.Id.button4);
                rotateLeft      = FindViewById <Button>(Resource.Id.button5);
                rotateRight     = FindViewById <Button>(Resource.Id.button6);
                Video           = FindViewById <VideoView>(Resource.Id.videoView1);
                controlBot      = new Rovio.Robot(IP, username, password);
                _sensorManager  = (SensorManager)GetSystemService(Context.SensorService);
                _sensorTextView = FindViewById <TextView>(Resource.Id.accelerometer_text);
                var surfaceOrientation = WindowManager.DefaultDisplay.Rotation;

                update();
            }
            catch (Exception e)
            {
                DisplayAlert("Error", "Connection Failed, Rovio may be offline or incorrect login details may of been entered.", "OK");
                StartActivity(MainActivity);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //instantiate the robot object
            Rovio.Robot robot = new Rovio.Robot("http://ip_address/", "user", "password");

            //check if we can receive responses from the robot
            try { robot.API.Movement.GetLibNSVersion(); } // a dummy request
            catch (Exception) { Console.WriteLine("Could not connect to the robot"); return; }

            //move the robot forward

            //using the CGI commands
            //robot.Request("rev.cgi?Cmd=nav&action=18&drive=1&speed=5");

            //using the wrapper library - API commands
            //robot.API.Movement.ManualDrive.Forward(5);

            //using the convenience class
            //robot.Drive.Forward(5);

            //main loop
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKey key = Console.ReadKey(true).Key;

                    //loop until the ESC key is pressed
                    if (key == ConsoleKey.Escape)
                    {
                        break;
                    }

                    //custom keyboard handler
                    switch (key)
                    {
                    case ConsoleKey.Q:
                        //enter your code here
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Rovio.Robot robot = new Rovio.Robot("http://ip_address/", "user", "password");

            //check if we can receive responses from the robot
            try { robot.API.Movement.GetLibNSVersion(); } // a dummy request
            catch (Exception) { Console.WriteLine("Could not connect to the robot"); return; }

            //move the robot forward

            //using the CGI commands
            //robot.Request("rev.cgi?Cmd=nav&action=18&drive=1&speed=5");

            //using the wrapper library - API commands
            //robot.API.Movement.ManualDrive.Forward(5);

            //using the convenience class
            //robot.Drive.Forward(5);

            //main loop
            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKey key = Console.ReadKey(true).Key;

                    //loop until the ESC key is pressed
                    if (key == ConsoleKey.Escape) break;

                    //custom keyboard handler
                    switch (key)
                    {
                        case ConsoleKey.Q:
                            //enter your code here
                            break;
                        default:
                            break;
                    }
                }
            }
        }
        /// <summary>
        /// Initial setup of Rovio including new thread for handling input of camera bitmaps.
        /// </summary>
        private void SetUpRovio()
        {
            try
            {
                rovioAddress = txtRovioIP.Text;
                robot = new Rovio.Robot(rovioAddress, "admin", "administrator");

                // Confirmation of successful connection.
                AppendTextMain("Rovio connected successfully at address: " + rovioAddress + "\n");
                AppendTextRovio("Rovio connected successfully at address: " + rovioAddress + "\n");

                movementThread = new Thread(rovioTick);
                movementThread.Start();

            }
            catch (Exception ex)
            {
                // Catch any errors and print message.
                AppendTextMain("Could not connect to Rovio: " + ex.Message + "\n");
                AppendTextRovio("Could not connect to Rovio: " + ex.Message + "\n");
            }
        }