View Single Post
  #1   Spotlight this post!  
Unread 24-03-2015, 13:16
DeeWBee DeeWBee is offline
Registered User
FRC #3630
 
Join Date: Feb 2011
Location: Breck
Posts: 3
DeeWBee is an unknown quantity at this point
Updating Speed Using Ultrasonic Sensors

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)......
Reply With Quote