Package trclib.sensor

Class TrcOdometryWheels

java.lang.Object
trclib.sensor.TrcOdometryWheels

public class TrcOdometryWheels extends Object
This class implements a platform independent drive base odometry device. A drive base odometry device generally consists of two to five sensors: zero to two for the X-axis, one to two for the Y-axis and one rotational sensor. All sensors must be able to report position as well as velocity data. If the sensor does not provide velocity data natively, it must calculate velocity data by differentiating position data against time. For axis sensors, they must be oriented parallel to the axis and installed tangential to the drive base centroid. They can have an offset from the centroid of the drive base. For X-axis, the front sensor must have a positive offset value, the back sensor must have a negative offset value. For Y-axis, the left sensor must have a positive offset value, the right sensor must have a negative offset value. Some typical configurations are listed below.

Configuration 1: This configuration has 2 sensors: one for Y-axis and one for rotation. The Y-axis sensor is most likely an encoder on passive omni-wheels installed parallel to the Y-axis. The angle sensor is most likely a gyro. This configuration does not support holonomic drive base since it doesn't provide X odometry. The Y sensor is typically installed inline with either the left or the right wheels and tangential to the centroid of the drive base.

Configuration 2: This configuration has 3 sensors: one for X-axis, one for Y-axis and one for rotation. The X and Y sensors are most likely encoders on passive omni-wheels installed parallel to the X and Y axes respectively. The angle sensor is most likely a gyro. This configuration can support holonomic drive base. The Y sensor is typically installed inline with either the left or the right wheels and tangential to the drive base centroid. The X sensor is typically installed on the front or the back of the drive base tangential to the centroid of the drive base.

Configuration 3: This configuration also has 3 sensors: two for Y-axis and one for rotation. The Y sensors are most likely encoders on passive omni-wheels installed parallel to the Y axis. The angle sensor is most likely a gyro. This configuration does not support holonomic drive base since it doesn't provide X odometry. The two Y sensors are typically installed on the left and right sides of the drive base equidistant to the centroid most likely inline with the left and right wheels and tangential to the centroid of the drive base.

Configuration 4: This configuration has 4 sensors: one for X-axis, two for Y-axis and one for rotation. The three axes sensors are most likely encoders on passive omni-wheels installed parallel to the X and Y axes respectively. The angle sensor is most likely a gyro. This configuration can support holonomic drive base. The two Y sensors are typically installed on the left and right sides of the drive base equidistant to the centroid most likely inline with the left and right wheels and tangential to the centroid of the drive base. The X sensor is typically installed on the front or the back of the drive base and tangential to the centroid of the drive base.

Configuration 5: This configuration has 5 sensors: two for X-axis, two for Y-axis and one for rotation. The four axes sensors are most likely encoders on passive omni-wheels installed parallel to the X and Y axes respectively. The angle sensor is most likely a gyro. This configuration can support holonmic drive base. The two Y sensors are typically installed on the left and right sides of the drive base equidistant to the centroid most likely inline with the left and right wheels and tangential to the centroid of the drive base. The two X sensors are typically installed on the front or the back of the drive base equidistant to the centroid and tangential to the centroid of the drive base.

  • Field Details

  • Constructor Details

    • TrcOdometryWheels

      public TrcOdometryWheels(TrcOdometryWheels.AxisSensor[] xSensors, TrcOdometryWheels.AxisSensor[] ySensors, TrcOdometrySensor angleSensor)
      Constructor: Create an instance of the object. This is typically used for configuration 5.
      Parameters:
      xSensors - specifies an array of Odometry sensors for the X-axis.
      ySensors - specifies an array of Odometry sensors for the Y-axis.
      angleSensor - specifies the Odometry sensor for rotation.
    • TrcOdometryWheels

      public TrcOdometryWheels(TrcOdometryWheels.AxisSensor xSensor, TrcOdometryWheels.AxisSensor[] ySensors, TrcOdometrySensor angleSensor)
      Constructor: Create an instance of the object. This is typically used for configuration 4.
      Parameters:
      xSensor - specifies an Odometry sensors for the X-axis.
      ySensors - specifies an array of Odometry sensors for the Y-axis.
      angleSensor - specifies the Odometry sensor for rotation.
    • TrcOdometryWheels

      public TrcOdometryWheels(TrcOdometryWheels.AxisSensor[] ySensors, TrcOdometrySensor angleSensor)
      Constructor: Create an instance of the object. This is typically used for configuration 3.
      Parameters:
      ySensors - specifies an array of Odometry sensors for the Y-axis.
      angleSensor - specifies the Odometry sensor for rotation.
    • TrcOdometryWheels

      public TrcOdometryWheels(TrcOdometryWheels.AxisSensor xSensor, TrcOdometryWheels.AxisSensor ySensor, TrcOdometrySensor angleSensor)
      Constructor: Create an instance of the object. This is typically use for configuration 2.
      Parameters:
      xSensor - specifies an Odometry sensors for the X-axis.
      ySensor - specifies an Odometry sensors for the Y-axis.
      angleSensor - specifies the Odometry sensor for rotation.
    • TrcOdometryWheels

      public TrcOdometryWheels(TrcOdometryWheels.AxisSensor ySensor, TrcOdometrySensor angleSensor)
      Constructor: Create an instance of the object. This is typically use for configuration 1.
      Parameters:
      ySensor - specifies an Odometry sensors for the Y-axis.
      angleSensor - specifies the Odometry sensor for rotation.
  • Method Details

    • isSensorUsed

      public boolean isSensorUsed(TrcOdometrySensor sensor)
      This method checks if the given sensor is used as part of the Odometry sensors.
      Parameters:
      sensor - specifies the sensor to be checked.
      Returns:
      true if the sensor is part of the odometry sensors, false otherwise.
    • setOdometryScales

      public void setOdometryScales(double xScale, double yScale, double angleScale)
      This method sets the scaling factors for both X, Y and angle data. This is typically used to scale encoder counts to physical units such as inches. If the scale of a direction is not provided, it must be set to 1.0.
      Parameters:
      xScale - specifies the scale factor for the X direction.
      yScale - specifies the scale factor for the Y direction.
      angleScale - specifies the scale factor the the angle.
    • setOdometryScales

      public void setOdometryScales(double xScale, double yScale)
      This method sets the scaling factors for Y and angle data. This is typically used to scale encoder counts to physical units such as inches. If the scale of a direction is not provided, it must be set to 1.0.
      Parameters:
      xScale - specifies the scale factor for the X direction.
      yScale - specifies the scale factor for the Y direction.
    • resetOdometry

      public void resetOdometry(boolean resetPositionOdometry, boolean resetHeadingOdometry, boolean resetHardware)
      This method resets the odometry device and data.
      Parameters:
      resetPositionOdometry - specifies true for resetting position odometry, false otherwise. Generally, this should be set to true unless the position odometry has been reset somewhere else.
      resetHeadingOdometry - specifies true to also reset the heading odometry, false otherwise.
      resetHardware - specifies true to do a hardware reset, false to do a soft reset.
    • getOdometryDelta

      public TrcDriveBase.Odometry getOdometryDelta()
      This method reads all the sensors and calculates the delta displacement from the last odometry update. Only position data are deltas but not velocities because we only integrate position data into absolute field position.
      Returns:
      delta odometry.
    • updateAxisOdometries

      private void updateAxisOdometries(TrcOdometryWheels.AxisSensor[] axisSensors)
      This method is called to update the odometry data for all sensors of the given axis.
      Parameters:
      axisSensors - specifies the axis sensor array to be updated.
    • averageSensorValues

      private double averageSensorValues(TrcOdometryWheels.AxisSensor[] axisSensors, double scale, boolean position)
      This method calculates the average of either position or velocity odometry data of all sensors in the given axis.
      Parameters:
      axisSensors - specifies the axis sensor array to be averaged.
      scale - specifies the odometry sensor scale.
      position - specifies true to average position data, false to average velocity data.
      Returns:
      averaged value.