Changes between Version 6 and Version 7 of ControlSystems/SampleCode/Ultrasonic


Ignore:
Timestamp:
Nov 3, 2019, 11:37:32 PM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SampleCode/Ultrasonic

    v6 v7  
    33
    441. Create a new project named Ultrasonic2.
    5 1. Download the attached Ultrasonic2537.java and save it in the src/main/java/frc/robot folder.
     51. Download the attached Ultrasonic2537.java and save it in the src/main/java/frc/robot folder.  This file is needed because the default Ultrasonic class provided with WPILib is defective and does not work with more than one ultrasonic sensor.
    661. Replace the auto-generated Robot.java class with the one below
     7
     8* Notice that we don't need to import the Ultrasonic2537 class because it is declared to be in the same package as the Robot class (package frc.robot).
    79
    810{{{
     
    6163  @Override
    6264  public void robotPeriodic() {
    63     SmartDashboard.putNumber("front distance", front.getRangeInches());
    64     SmartDashboard.putNumber("rear distance",  rear.getRangeInches());
     65    if (front.isRangeValid())
     66       SmartDashboard.putNumber("front distance", front.getRangeInches());
     67    if (rear.isRangeValid())
     68       SmartDashboard.putNumber("rear distance",  rear.getRangeInches());
    6569  }
    6670
     
    113117  }
    114118}
    115 
    116119}}}