public Robot(string teamID) { this.teamID = teamID; radio = new Radio(this, portName); // Initialize single motor COM port motorPort = new SerialPort("COM1", 9600); motorPort.ReadTimeout = 2; motorPort.Open(); // Send baudrate autodetect byte (0xAA) motorPort.Write(new byte[] { (byte)0xAA }, 0, 1); leftMotor = new SimpleMotorController(this, 13); rightMotor = new SimpleMotorController(this, 14); }
private RXState state; /** Current state of the receiver. */ #endregion Fields #region Constructors /** Constructor for the XBeeInterfaceReceiver class. * @param p The parent Radio instance we're parsing packets for. */ public XBeeInterfaceReceiver(Radio p) { state = (int)RXState.IDLE; packet = new XBeeRXPacket(); parent = p; }
public Robot(string teamID, String robotComPort) { motorPort = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); motorPort.ReadTimeout = 2; motorPort.Open(); // Debug.Print("set actuators"); actuators = new ArrayList(); sensors = new ArrayList(); canMove = true; isAutonomous = false; // Not sure about this RobotSet = false; autoWait = new ManualResetEvent(false); scWait = new ManualResetEvent(false); this.teamID = teamID; radio = new Radio(this, robotComPort); student = new StudentCode(this); lock (radioLock) { UIAnalogVals = radio.UIAnalogVals; UIDigitalVals = radio.UIDigitalVals; FieldAnalogVals = radio.FieldAnalogVals; FieldDigitalVals = radio.FieldDigitalVals; Debug.Print(" digital length: " + UIDigitalVals.Length); } // Setup threads to maintain and control actuators based on radio input robotThread = new Thread(this.Run); //radioThread = new Thread(radio.Poll); studentCodeThread = new Thread(student.UserControlledCode); autonomousThread = new Thread(student.AutonomousCode); // Name the threads for debugging purposes /*robotThread.Name = "robotThread"; radioThread.Name = "radioThread"; studentCodeThread.Name = "studentCodeThread"; autonomousThread.Name = "autonomousThread";*/ // Start all the threads robotThread.Start(); //radioThread.Start(); studentCodeThread.Start(); autonomousThread.Start(); }
public XBeeReceiver(Radio p) { state = (int)RXState.IDLE; buffer = new byte[128]; packet = new XBeeRXPacket(); parent = p; }
public Robot(string teamID) { this.teamID = teamID; radio = new Radio(this, portName); }
/// <summary> /// Robot Constructor: initilizes variables /// </summary> /// <param name="teamID">Team ID</param> /// <param name="radioComPort">Radio Com Port</param> public Robot(string teamID, String radioComPort) { actuators = new ArrayList(); sensors = new ArrayList(); ports = new ArrayList(); canMove = true; isAutonomous = false; this.teamID = teamID; radio = new Radio(radioComPort); i2c = new I2CBus(); heartbeatTimer = DateTime.Now.Ticks; // Set the team color for the shiftBrite // Still to be implemented in 0.1c // Make a deep copy of the UI values so they don't change mid-update UIAnalogVals = (int[])radio.UIAnalogVals.Clone(); UIDigitalVals = (bool[])radio.UIDigitalVals.Clone(); }