The Vex Ultrasonics’ code is crashing the robot. As soon as a certain line of code runs (pinpointed on robot init), the driver station immediately disables and says no robot code. I have tested this with 2014’s robot system which has not been an issue however this issue only occurs with 2015’s.
package org.usfirst.frc.team334.robot;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Ultrasonic;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class Robot extends IterativeRobot {
Ultrasonic ultrasonic = new Ultrasonic(1, 2);
public void robotInit() {
ultrasonic.setAutomaticMode(true);
}
public void autonomousPeriodic() {
SmartDashboard.putNumber("Ultrasonic Value", ultrasonic.getRangeInches());
}
public void teleopPeriodic() {
}
public void testPeriodic() {
}
}
IN JAVA: We spent an entire day on this, doubting our wiring, our code. We even created a brand new empty shell using gearsbot command based as a starting point, but only adding the vex ultrasonic digital sensor. We could not get it to work. So, we then did the same thing but switched to C++…
It worked in C++. We believe there is a bug in the Java library. But without anything concrete in team updates or elsewhere on CD…
So, we are now switching our robot to C++ as we need these rangefinders on the robot. So, give it a try in C++ and report back. We are not looking back now…
md
Just an update everyone. We were able to get it to work under JAVA after all. At this point we are not sure what changed, but there was an re-image to the roborio that was done. So, it may not be a library bug after all. I just did not want anyone chasing ghosts on this…
md
Thank guys. We reflashed the roborio and it’s working now!