Problems running multiple Ultrasonic sensors

We are trying to run two digital Ultrasonic sensors on the robot this year and are running into problems.

We have verified that when only 1 of the sensors has been constructed in a new Java Object, that sensor works fine. When we attempt to construct 2 different Ultrasonic objects (on different DIO ports), only the first one reports valid distance numbers. We set automatic mode to True for both sensors, and setEnabled to True. When the order for which these objects are constructed is reversed, the first one is the only one that reports a valid distance, even though isEnabled() method returns True for both objects.

Is there a known bug when attempting to operate multiple Ultrasonic sensors? We verified that the wiring, ports reference, and physical operation of the sensors is all nominal.

Relevant code:

public Ultrasonic ultrasonic_ARM = new Ultrasonic(RobotMap.PING_CHANNEL_ARM, RobotMap.ECHO_CHANNEL_ARM);
public Ultrasonic ultrasonic_HATCH = new Ultrasonic(RobotMap.PING_CHANNEL_HATCH, RobotMap.ECHO_CHANNEL_HATCH);

in constructor:


Yes, this was fixed in WPILib 2019.3.2.

Thanks! I’ll try the update

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.