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.
...
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final TrcEvent
private final String
private final boolean
private static final double
private static final double
private boolean
private final TrcTaskMgr.TaskObject
private final TrcDigitalOutput
private final TrcAnalogInput[]
private final TrcStateMachine<TrcMaxbotixSonarArray.State>
private final TrcTimer
private final TrcDbgTrace
-
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.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.private void
setTaskEnabled
(boolean enabled) This method is called to start the task that generates the RX pulse for ranging to start.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.
-
Field Details
-
RANGING_START_PULSE_WIDTH
private static final double RANGING_START_PULSE_WIDTH- See Also:
-
RANGING_PERIOD
private static final double RANGING_PERIOD- See Also:
-
tracer
-
instanceName
-
sensors
-
rx
-
loopConfig
private final boolean loopConfig -
rangingTaskObj
-
sm
-
timer
-
event
-
autoRepeat
private boolean autoRepeat -
rangingStarted
private boolean rangingStarted
-
-
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.
-
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.
-