/// <summary>
        /// Updates the status of the robot's parts with the new keyboard commands received.
        /// </summary>
        /// <param name="commands">Keyboard state.</param>
        public void Update(KeyCommand commands)
        {
            irisAngle = commands.open ? 0.0f : 180.0f;
            armAngle = commands.lower ? 180.0f : 0.0f;
            LeftDriveThrottle = 0.0f;
            RightDriveThrottle = 0.0f;
            Led_State = 0;

            isLedOn = (commands.led ^ isLedOn);
            Led_State = Convert.ToByte(isLedOn);

            if (commands.forward)
            {
                LeftDriveThrottle = 0.5f;
                RightDriveThrottle = 0.5f;
            }
            else if (commands.reverse)
            {
                LeftDriveThrottle = -0.5f;
                RightDriveThrottle = -0.5f;
            }

            if (commands.left)
            {
                if (commands.forward || commands.reverse)
                {
                    LeftDriveThrottle /= 2;
                }
                else
                {
                    LeftDriveThrottle = -0.5f;
                    RightDriveThrottle = 0.5f;
                }
            }

            if (commands.right)
            {
                if (commands.forward || commands.reverse)
                {
                    RightDriveThrottle /= 2;
                }
                else
                {
                    RightDriveThrottle = -0.5f;
                    LeftDriveThrottle = 0.5f;
                }
            }

            if (commands.sprint)
            {
                LeftDriveThrottle *= 2.0f;
                RightDriveThrottle *= 2.0f;
            }
        }
        /// <summary>
        /// Initializes the BaseStation GUI.
        /// Attempts to connect to the Python server.  If successful, the GUI opens up for use.
        /// </summary>
        public BaseStationGUI()
        {
            InitializeComponent();
              //      IPModeWindow ipMode = new IPModeWindow();
            robotConnection = new UdpClient(4444);

            /*        if (ipMode.ShowDialog() != DialogResult.OK) System.Environment.Exit(0);
            else
            {
                if (ipMode.check == 1)
                {
                    getIP = new GetRobotIP(robotConnection);
                    robotIP = getIP.GetIP();
                    robotConnection.Connect(IPAddress.Parse(robotIP), 4444);
                }
                else
                {
                    robotIP = ipMode.IP;
                    robotConnection.Connect(IPAddress.Parse(robotIP), 4444);
                }
            }

            string baseip = "";
            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily.ToString() == "InterNetwork")
                {
                    baseip = ip.ToString();
                }
            }

            byte[] buff = Encoding.ASCII.GetBytes(baseip);
            robotConnection.Send(buff, buff.Length);
            sensorData = new SensorData(robotIP);
            sensorData.SensorUpdate += SensorData_SensorDataUpdate; */
            commands = new KeyCommand();
            xboxController = new GamepadState(SlimDX.XInput.UserIndex.One);
            xboxController.ControllerUpdate += xboxController_ControllerUpdate;
            xcontroller = new MotorControl();
            kcontroller = new MotorControl();
              /*  ffplay = new Process();
            ffplay.StartInfo.Arguments = "http://192.168.2.29:8090/live.mpg";
            ffplay.StartInfo.FileName = "ffplay.exe";
            ffplay.Start(); */
            this.Activate();
        }