public NavX() { try { /*********************************************************************** * navX-MXP: * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB. * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface. * * navX-Micro: * - Communication via I2C (RoboRIO MXP or Onboard) and USB. * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface. * * Multiple navX-model devices on a single robot are supported. ************************************************************************/ ahrs = new AHRS(SerialPort.Port.kUSB); } catch (RuntimeException ex ) { DriverStation.reportError("Error instantiating navX MXP: " + ex.getMessage(), true); } }
/** * Constructs the IMU class, overriding the default update rate * with a custom rate which may be from 4 to 100, representing * the number of updates per second sent by the nav6 IMU. * * Note that increasing the update rate may increase the * CPU utilization. * @param serial_port BufferingSerialPort object to use * @param update_rate_hz Custom Update Rate (Hz) */ public IMU(SerialPort serial_port, byte update_rate_hz) { ypr_update_data = new IMUProtocol.YPRUpdate(); this.update_rate_hz = update_rate_hz; flags = 0; accel_fsr_g = DEFAULT_ACCEL_FSR_G; gyro_fsr_dps = DEFAULT_GYRO_FSR_DPS; this.serial_port = serial_port; yaw_history = new float[YAW_HISTORY_LENGTH]; yaw = (float) 0.0; pitch = (float) 0.0; roll = (float) 0.0; try { serial_port.reset(); } catch (RuntimeException ex) { ex.printStackTrace(); } initIMU(); m_thread = new Thread(this); m_thread.start(); }
public IMU(SerialPort serial_port, byte update_rate_hz) { ypr_update_data = new IMUProtocol.YPRUpdate(); this.update_rate_hz = update_rate_hz; flags = 0; accel_fsr_g = DEFAULT_ACCEL_FSR_G; gyro_fsr_dps = DEFAULT_GYRO_FSR_DPS; this.serial_port = serial_port; yaw_history = new float[YAW_HISTORY_LENGTH]; yaw = (float) 0.0; pitch = (float) 0.0; roll = (float) 0.0; try { serial_port.reset(); } catch (RuntimeException e) { } initIMU(); m_thread = new Thread(this); m_thread.start(); }
public SerialIO( SerialPort.Port port_id, byte update_rate_hz, boolean processed_data, IIOCompleteNotification notify_sink, IBoardCapabilities board_capabilities ) { this.serial_port_id = port_id; ypr_update_data = new IMUProtocol.YPRUpdate(); gyro_update_data = new IMUProtocol.GyroUpdate(); ahrs_update_data = new AHRSProtocol.AHRSUpdate(); ahrspos_update_data = new AHRSProtocol.AHRSPosUpdate(); board_id = new AHRSProtocol.BoardID(); board_state = new IIOCompleteNotification.BoardState(); this.notify_sink = notify_sink; this.board_capabilities = board_capabilities; serial_port = getMaybeCreateSerialPort(); this.update_rate_hz = update_rate_hz; if ( processed_data ) { update_type = AHRSProtocol.MSGID_AHRSPOS_UPDATE; } else { update_type = IMUProtocol.MSGID_GYRO_UPDATE; } }
/** * Constructs the AHRS class, overriding the default update rate * with a custom rate which may be from 4 to 60, representing * the number of updates per second sent by the navX MXP. * * Note that increasing the update rate may increase the * CPU utilization. * @param serial_port SerialPort object to use * @param update_rate_hz Custom Update Rate (Hz) */ public AHRS(SerialPort serial_port, byte update_rate_hz) { super(serial_port,update_rate_hz); ahrs_update_data = new AHRSProtocol.AHRSUpdate(); update_type = AHRSProtocol.MSGID_AHRS_UPDATE; world_linear_accel_x = world_linear_accel_y = world_linear_accel_z = mpu_temp_c = fused_heading = altitude = barometric_pressure = baro_sensor_temp_c = mag_field_norm_ratio = 0.0f; cal_mag_x = cal_mag_y = cal_mag_z = 0; is_moving = is_rotating = altitude_valid = is_magnetometer_calibrated = magnetic_disturbance = false; resetDisplacement(); }
public SerialIO( SerialPort.Port port_id, byte update_rate_hz, boolean processed_data, IIOCompleteNotification notify_sink, IBoardCapabilities board_capabilities ) { this.serial_port_id = port_id; is_usb = ((port_id == SerialPort.Port.kUSB) || (port_id == SerialPort.Port.kUSB1)|| (port_id == SerialPort.Port.kUSB2)); ypr_update_data = new IMUProtocol.YPRUpdate(); gyro_update_data = new IMUProtocol.GyroUpdate(); ahrs_update_data = new AHRSProtocol.AHRSUpdate(); ahrspos_update_data = new AHRSProtocol.AHRSPosUpdate(); ahrspos_ts_update_data = new AHRSProtocol.AHRSPosTSUpdate(); board_id = new AHRSProtocol.BoardID(); board_state = new IIOCompleteNotification.BoardState(); this.notify_sink = notify_sink; this.board_capabilities = board_capabilities; serial_port = getMaybeCreateSerialPort(); this.update_rate_hz = update_rate_hz; if ( processed_data ) { update_type = AHRSProtocol.MSGID_AHRSPOS_TS_UPDATE; } else { update_type = IMUProtocol.MSGID_GYRO_UPDATE; } }
/** * Creates a new Lights subsystem. */ public Lights() { teensyCommunication = new SerialPort(9600, SerialPort.Port.kMXP); teensyCommunication.enableTermination(); Thread serialThread = new Thread(this::serialThread); serialThread.setName("LED UART Thread"); serialThread.setDaemon(true); serialThread.start(); setLedLight(Type.SIGN_FUEL, Pulse.SOLID, Color.OFF); setLedLight(Type.SIGN_GEAR, Pulse.SOLID, Color.OFF); }
public Vision(){ serial = new SerialPort(115200, SerialPort.Port.kMXP, 8, SerialPort.Parity.kNone, SerialPort.StopBits.kOne); serial.disableTermination(); serial.setTimeout(1); serial.setFlowControl(SerialPort.FlowControl.kNone); serial.setReadBufferSize(32); serial.setWriteBufferSize(8); serial.setWriteBufferMode(SerialPort.WriteBufferMode.kFlushOnAccess); }
protected SerialPort resetSerialPort() { if (serial_port != null) { try { serial_port.free(); } catch (Exception ex) { // This has been seen to happen before.... } serial_port = null; } serial_port = getMaybeCreateSerialPort(); return serial_port; }
public ArduPilotAthenaInputStream() { try { sp = new SerialPort(115200, Port.kUSB); } catch (Exception e) { ; } }
public PixyVision( final String instanceName, Robot robot, int signature, int brightness, Orientation orientation, SerialPort.Port port) { pixyCamera = new FrcPixyCam(instanceName, port, RobotInfo.PIXY_BAUD_RATE, RobotInfo.PIXY_DATA_BITS, RobotInfo.PIXY_PARITY, RobotInfo.PIXY_STOP_BITS); commonInit(robot, signature, brightness, orientation); }
/** * Constructor: Creates an instance of the object. * * @param instanceName specifies the instance name. * @param port specifies the serial port (on-board or on the MXP). * @param baudRate specifies the serial baud rate. * @param dataBits specifies the number of data bits. * @param parity specifies the parity type. * @param stopBits specifies the number of stop bits. */ public FrcSerialPortDevice( final String instanceName, Port port, int baudRate, int dataBits, Parity parity, StopBits stopBits) { super(instanceName); if (debugEnabled) { dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel); } device = new SerialPort(baudRate, port, dataBits, parity, stopBits); }
/** * Constructor: Create an instance of the object. * * @param instanceName specifies the instance name. * @param port specifies the serial port on the RoboRIO. * @param baudRate specifies the baud rate. * @param dataBits specifies the number of data bits. * @param parity specifies the parity type. * @param stopBits specifies the number of stop bits. */ public FrcPixyCam( final String instanceName, SerialPort.Port port, int baudRate, int dataBits, SerialPort.Parity parity, SerialPort.StopBits stopBits) { super(instanceName); if (debugEnabled) { dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel); } pixyCam = new FrcSerialPortDevice(instanceName, port, baudRate, dataBits, parity, stopBits); start(); }
/** * Constructor: Create an instance of the object. * * @param instanceName specifies the instance name. * @param port specifies the serial port on the RoboRIO. * @param baudRate specifies the baud rate. * @param dataBits specifies the number of data bits. * @param parity specifies the parity type. * @param stopBits specifies the number of stop bits. */ public FrcEmic2TextToSpeech( final String instanceName, SerialPort.Port port, int baudRate, int dataBits, SerialPort.Parity parity, SerialPort.StopBits stopBits) { super(instanceName); if (debugEnabled) { dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel); } tts = new FrcSerialPortDevice(instanceName, port, baudRate, dataBits, parity, stopBits); }
/** * @return the ledOut */ public static SerialPort getLedOut() { return ledOut; }
/** * @param ledOut the ledOut to set */ public static void setLedOut(SerialPort ledOut) { LEDz.ledOut = ledOut; }
public IMU(SerialPort serial_port) { this(serial_port, DEFAULT_UPDATE_RATE_HZ); }
public SerialPortInputStream(SerialPort sp) { this.sp = sp; }
@Override public void robotInit() { l = new LIDARLite(SerialPort.Port.kMXP); }
/** * Constructs the AHRS class using serial communication, overriding the * default update rate with a custom rate which may be from 4 to 60, * representing the number of updates per second sent by the sensor. * <p> * This constructor should be used if communicating via either TTL UART or * USB Serial interface. * <p> * Note that the serial interfaces can communicate either processed data, or * raw data, but not both simultaneously. If simultaneous processed and raw * data are needed, use one of the register-based interfaces (SPI or I2C). * <p> * Note that increasing the update rate may increase the CPU utilization. * <p> * * @param serial_port_id * SerialPort to use * @param data_type * either kProcessedData or kRawData * @param update_rate_hz * Custom Update Rate (Hz) */ public AHRS(SerialPort.Port serial_port_id, SerialDataType data_type, byte update_rate_hz) { commonInit(update_rate_hz); boolean processed_data = (data_type == SerialDataType.kProcessedData); io = new SerialIO(serial_port_id, update_rate_hz, processed_data, io_complete_sink, board_capabilities); io_thread.start(); }
/** * Constructs the AHRS class using serial communication, overriding the * default update rate with a custom rate which may be from 4 to 60, * representing the number of updates per second sent by the sensor. *<p> * This constructor should be used if communicating via either * TTL UART or USB Serial interface. *<p> * Note that the serial interfaces can communicate either * processed data, or raw data, but not both simultaneously. * If simultaneous processed and raw data are needed, use * one of the register-based interfaces (SPI or I2C). *<p> * Note that increasing the update rate may increase the * CPU utilization. *<p> * @param serial_port_id SerialPort to use * @param data_type either kProcessedData or kRawData * @param update_rate_hz Custom Update Rate (Hz) */ public AHRS(SerialPort.Port serial_port_id, SerialDataType data_type, byte update_rate_hz) { commonInit(update_rate_hz); boolean processed_data = (data_type == SerialDataType.kProcessedData); io = new SerialIO(serial_port_id, update_rate_hz, processed_data, io_complete_sink, board_capabilities); io_thread.start(); }
/** * Constructs the AHRS class using serial communication, overriding the * default update rate with a custom rate which may be from 4 to 200, * representing the number of updates per second sent by the sensor. *<p> * This constructor should be used if communicating via either * TTL UART or USB Serial interface. *<p> * Note that the serial interfaces can communicate either * processed data, or raw data, but not both simultaneously. * If simultaneous processed and raw data are needed, use * one of the register-based interfaces (SPI or I2C). *<p> * Note that increasing the update rate may increase the * CPU utilization. *<p> * @param serial_port_id SerialPort to use * @param data_type either kProcessedData or kRawData * @param update_rate_hz Custom Update Rate (Hz) */ public AHRS(SerialPort.Port serial_port_id, SerialDataType data_type, byte update_rate_hz) { commonInit(update_rate_hz); boolean processed_data = (data_type == SerialDataType.kProcessedData); io = new SerialIO(serial_port_id, update_rate_hz, processed_data, io_complete_sink, board_capabilities); io_thread.start(); }
/** * Constructs the IMU class, using the default update rate. * * @param serial_port BufferingSerialPort object to use */ public IMU(SerialPort serial_port) { this(serial_port,DEFAULT_UPDATE_RATE_HZ); }
/** * Constructs the IMUAdvanced class, overriding the default update rate * with a custom rate which may be from 4 to 100, representing * the number of updates per second sent by the nav6 IMU. * * Note that increasing the update rate may increase the * CPU utilization. Note that calculation of some * advanced values utilizes additional cpu cycles, when compared * to the IMU class. * @param serial_port BufferingSerialPort object to use * @param update_rate_hz Custom Update Rate (Hz) */ public IMUAdvanced(SerialPort serial_port, byte update_rate_hz) { super(serial_port,update_rate_hz); quaternion_update_data = new IMUProtocol.QuaternionUpdate(); update_type = IMUProtocol.MSGID_QUATERNION_UPDATE; }
/** * Constructs the IMUAdvanced class, using the default update rate. * * Note that calculation of some advanced values utilizes additional * cpu cycles, when compared to the IMU class. * @param serial_port BufferingSerialPort object to use */ public IMUAdvanced(SerialPort serial_port) { this(serial_port, DEFAULT_UPDATE_RATE_HZ); }
/** * Constructs the AHRS class using serial communication and the default * update rate, and returning processed (rather than raw) data. * <p> * This constructor should be used if communicating via either TTL UART or * USB Serial interface. * <p> * * @param serial_port_id * SerialPort to use */ public AHRS(SerialPort.Port serial_port_id) { this(serial_port_id, SerialDataType.kProcessedData, NAVX_DEFAULT_UPDATE_RATE_HZ); }
/** * Constructs the AHRS class, using the default update rate. * * Note that calculation of some advanced values utilizes additional * cpu cycles, when compared to the IMU class. * @param serial_port BufferingSerialPort object to use */ public AHRS(SerialPort serial_port) { this(serial_port, NAVX_MXP_DEFAULT_UPDATE_RATE_HZ); }
/** * Constructs the AHRS class using serial communication and the default update rate, * and returning processed (rather than raw) data. *<p> * This constructor should be used if communicating via either * TTL UART or USB Serial interface. *<p> * @param serial_port_id SerialPort to use */ public AHRS(SerialPort.Port serial_port_id) { this(serial_port_id, SerialDataType.kProcessedData, NAVX_DEFAULT_UPDATE_RATE_HZ); }
/** * Constructor: Create an instance of the object. * * @param instanceName specifies the instance name. * @param port specifies the serial port on the RoboRIO. * @param baudRate specifies the baud rate. */ public FrcPixyCam(final String instanceName, SerialPort.Port port, int baudRate) { this(instanceName, port, baudRate, DEF_DATA_BITS, DEF_PARITY, DEF_STOP_BITS); }
/** * Constructor: Create an instance of the object. * * @param instanceName specifies the instance name. * @param port specifies the serial port on the RoboRIO. */ public FrcPixyCam(final String instanceName, SerialPort.Port port) { this(instanceName, port, DEF_BAUD_RATE, DEF_DATA_BITS, DEF_PARITY, DEF_STOP_BITS); }
/** * Constructor: Create an instance of the object. * * @param instanceName specifies the instance name. * @param port specifies the serial port on the RoboRIO. * @param baudRate specifies the baud rate. */ public FrcEmic2TextToSpeech(final String instanceName, SerialPort.Port port, int baudRate) { this(instanceName, port, baudRate, DEF_DATA_BITS, DEF_PARITY, DEF_STOP_BITS); }