I am trying to create code that will slow down the robot as it gets closer to an object.
So far I have been able to write code that will stop the robot using an "if" statement with the conditional being the range as measured by sonar.
Code:
if(sonar.getRangeInches() < 40) {
motor.stop();
However, when I modify the code such that I want to change the speed on approach, I get "robotDrive...output not updated enough". Any ideas? I've gotten the code to run by disabling the motor safety, but the sensitivity doesn't change at all.
Code:
if(sonar.getRangeInches() < 40) {
driveTrain.setSensitivity(0.5)
elseif(sonar.....<30){
driveTrain.setSensitivty(0.25)......