Changes between Version 3 and Version 4 of ControlSystems/SoftwareTeam/Training/GettingStarted/UltrasonicRangefinder


Ignore:
Timestamp:
Oct 31, 2019, 1:39:35 PM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/UltrasonicRangefinder

    v3 v4  
    11== Ultrasonic Rangefinder
    22
    3 Robots need to sense the environment around them, particularly when driving autonomously.  Ultrasonic sensors are like the sonar used by bats.  [[Image(UltrasonicSensor.jpg,right,250px,margin=10)]] They emit a chirp of sound and measure the time it takes to hear an echo of that chirp.  The longer the time, the further the sound traveled.  Since sound travels at a particular speed through air, we can use the echo delay to calculate how far away the object was that reflected the sound.  You can read more about ultrasonic sensors [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599715-ultrasonic-sensors-measuring-robot-distance-to-a-surface here]
     3Robots need to sense the environment around them, particularly when driving autonomously.  Ultrasonic sensors are like the sonar used by bats.  [[Image(UltrasonicSensor.jpg,right,250px,margin=10)]] They emit a chirp of sound and measure the time it takes to hear an echo of that chirp.  The longer the time, the further the sound traveled.  Since sound travels at a particular speed (about 1125 ft/s) through air, we can use the echo delay to calculate distance to the object was that reflected the sound.  You can read more about ultrasonic sensors on [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599715-ultrasonic-sensors-measuring-robot-distance-to-a-surface ScreenStepsLive]
    44
    5 Create another program using the !TimedRobot java template and name it !UltrasonicTest. Modify the generated code as follows:
    6 * import the Ultrasonic class {{{ import edu.wpi.first.wpilibj.Ultrasonic; }}}
    7 * declare a ultrasonic variable in the Robot class {{{ private Ultrasonic f_ultrasonic; }}}
     5Create another program using the !TimedRobot java template and name it !UltrasonicTest. Modify the auto-generated template code as follows:
     6* import the Ultrasonic class
     7{{{
     8   import edu.wpi.first.wpilibj.Ultrasonic;
     9}}}
     10* declare a ultrasonic variable in the Robot class
     11{{{
     12   private Ultrasonic f_ultrasonic;
     13}}}
    814* in robotInit() instantiate an ultrasonic object and set it to start automatically ranging
    915  {{{