Package trclib.sensor
Class TrcMaxbotixSonarArray
java.lang.Object
trclib.sensor.TrcMaxbotixSonarArray
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.
...
-
Constructor Summary
ConstructorsConstructorDescriptionTrcMaxbotixSonarArray
(String instanceName, TrcAnalogInput[] sensors, TrcDigitalOutput rx) Constructor: Creates an instance of the object.TrcMaxbotixSonarArray
(String instanceName, TrcAnalogInput[] sensors, TrcDigitalOutput rx, boolean loopConfig) Constructor: Creates an instance of the object.TrcMaxbotixSonarArray
(String instanceName, TrcAnalogInput sensor, TrcDigitalOutput rx) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetDistance
(int sensorIndex) This method returns the distance data of the specifies sensor index.boolean
This method checks if the sonar array is ranging.void
This method is called to start the ranging cycle.void
startRanging
(boolean autoRepeat) This method is called to start the ranging cycle.void
This method is called to stop the ranging cycle.toString()
This method returns the instance name.
-
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
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
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
This method returns the 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
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.
-