Changes between Version 8 and Version 9 of ControlSystems/SoftwareTeam/Training/GettingStarted/UltrasonicRangefinder


Ignore:
Timestamp:
Nov 3, 2019, 10:48:54 PM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

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

    v8 v9  
    33Robots 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 Ultrasonic sensors are connected to the RoboRIO using DIO ports.  In the example below, a sensor's Ping and Echo wires are connected to DIO1 and DIO0.
     5Ultrasonic sensors are connected to the RoboRIO using DIO ports.  In the example below, a sensor's Ping/Trig and Echo wires are connected to DIO8 and DIO9 respectively.
    66
    77Create another program using the !TimedRobot java template and name it !UltrasonicTest. Modify the auto-generated template code as follows:
     
    1616* in robotInit() instantiate an ultrasonic object and set it to start automatically ranging
    1717  {{{
    18     // Sensor is connected to DIO8, DIO9
     18    // Sensor is connected to DIO8 (trig), DIO9 (echo)
    1919    f_ultrasonic = new Ultrasonic(8,9);
    2020    // Start sensor continuously pinging