Package trclib.sensor

Class TrcMaxbotixSonarArray

java.lang.Object
trclib.sensor.TrcMaxbotixSonarArray

public class TrcMaxbotixSonarArray extends Object
This class implements a platform independent Maxbotix ultrasonic sensor array. The ultrasonic sensors in the array are connected in analog chain mode where only one sensor will ping at a time to eliminate cross talk. This class supports both regular chain config and loop chain config. ...
  • Field Details

  • Constructor Details

    • TrcMaxbotixSonarArray

      public TrcMaxbotixSonarArray(String instanceName, TrcAnalogInput[] sensors, TrcDigitalOutput rx, boolean loopConfig)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      sensors - specifies an array of Maxbotix ultrasonic sensors.
      rx - specifies the digital output channel the RX pin is connected to.
      loopConfig - specifies true if the sensor array is wired in loop configuration, false otherwise.
    • TrcMaxbotixSonarArray

      public TrcMaxbotixSonarArray(String instanceName, TrcAnalogInput[] sensors, TrcDigitalOutput rx)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      sensors - specifies an array of Maxbotix ultrasonic sensors.
      rx - specifies the digital output channel the RX pin is connected to.
    • TrcMaxbotixSonarArray

      public TrcMaxbotixSonarArray(String instanceName, TrcAnalogInput sensor, TrcDigitalOutput rx)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      sensor - specifies a single Maxbotix ultrasonic sensor.
      rx - specifies the digital output channel the RX pin is connected to.
  • Method Details

    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • isRanging

      public boolean isRanging()
      This method checks if the sonar array is ranging.
      Returns:
      true if the sonar array is ranging, false otherwise.
    • startRanging

      public void startRanging(boolean autoRepeat)
      This method is called to start the ranging cycle.
      Parameters:
      autoRepeat - specifies true to auto repeat the ranging cycle, false otherwise. autoRepeat is ignored if the array is wired in loop config because it is already in continuous ranging mode.
    • startRanging

      public void startRanging()
      This method is called to start the ranging cycle.
    • stopRanging

      public void stopRanging()
      This method is called to stop the ranging cycle. Ranging cycle can only be stopped if it is not wired in loop config and was set to autoRepeat mode. If the sensor array is wired in loop config, the only way to stop ranging is to remove power.
    • getDistance

      public TrcSensor.SensorData<Double> getDistance(int sensorIndex)
      This method returns the distance data of the specifies sensor index.
      Parameters:
      sensorIndex - specifies the index of the ultrasonic sensor to read its distance data.
      Returns:
      distance data of the specified sensor.
    • setTaskEnabled

      private void setTaskEnabled(boolean enabled)
      This method is called to start the task that generates the RX pulse for ranging to start.
      Parameters:
      enabled - specifies true to start the task, false otherwise.
    • rangingTask

      private void rangingTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop)
      This method is called periodically to run the state machine that generates the RX pulse for ranging.
      Parameters:
      taskType - specifies the type of task being run.
      runMode - specifies the competition mode that is running. (e.g. Autonomous, TeleOp, Test).
      slowPeriodicLoop - specifies true if it is running the slow periodic loop on the main robot thread, false otherwise.