Changes between Version 8 and Version 9 of ControlSystems/SoftwareTeam/Training/GettingStarted/UltrasonicRangefinder
- Timestamp:
- Nov 3, 2019, 10:48:54 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/GettingStarted/UltrasonicRangefinder
v8 v9 3 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 (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] 4 4 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.5 Ultrasonic 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. 6 6 7 7 Create another program using the !TimedRobot java template and name it !UltrasonicTest. Modify the auto-generated template code as follows: … … 16 16 * in robotInit() instantiate an ultrasonic object and set it to start automatically ranging 17 17 {{{ 18 // Sensor is connected to DIO8 , DIO918 // Sensor is connected to DIO8 (trig), DIO9 (echo) 19 19 f_ultrasonic = new Ultrasonic(8,9); 20 20 // Start sensor continuously pinging