Changes between Version 15 and Version 16 of ControlSystems/SoftwareTeam/Training/GettingStarted/IntroRobotJava


Ignore:
Timestamp:
Oct 16, 2019, 12:44:06 AM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

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

    v15 v16  
    5353* Even though the program is running on the robot, you can set breakpoints, step through code, examine and change variables, etc. from your laptop.
    5454
     55* Extra credit: extend the program to print a message or display a value on the Smart Dashboard when a button is pressed on the xbox controller.
     56
    5557== Second program: Ultrasonic Rangefinder
     58
     59Robots often need to sense the environment around them, particularly when driving autonomously.  Ultrasonic sensors are like the sonar used by bats.  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]
    5660
    5761Create another program using the !TimedRobot java template and name it !UltrasonicTest. Modify the generated code as follows:
     
    7276Run the program and observe the "Front range" value in the [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599724-displaying-data-on-the-ds-dashboard-overview Smart Dashboard] as you move the robot towards and away from the wall.
    7377
     78Notice that the measurements aren't always perfect; the sensor may receive echos from multiple surfaces.
     79
    7480== Third program: Servo Motor Control
     81
     82Robots must be able to interact with the environment around them too.  Many types of actuators are used in FRC robotics; one of them is the [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599703-repeatable-low-power-movement-controlling-servos-with-wpilib Servo Motor].  A servo motor is a special type of motor that can rotate to a precise position, usually between 0 and 180 degrees.  They come in a variety of sizes and strengths.  You can connect a servo motor to any of the PWM ports on the !RoboRIO.  Examine the PWM ports and identify which row of pins are ground ([[Image(https://incompliancemag.com/wp-content/uploads/2012/01/1201_OnYourMark_5019.png, 50px)]], +6V, and Signal (S).  Make sure you connect them to the proper pins on the Servo motor: black or brown goes to Ground, red or orange goes to +6V, yellow/white/blue goes to Signal.  You can read more about servo motors [https://learn.sparkfun.com/tutorials/servo-trigger-hookup-guide/all here]
    7583
    7684Create another program using the !TimedRobot java template and name it !ServoTest. Modify the generated code as follows:
     
    104112
    105113Connect a Servo motor to PWM port 1 on the roboRIO and run your program.  You'll need to press the Enable button on the driver station to put the robot in Teleop mode so that teleopPeriodic() is called repeatedly.
     114
     115* Extra credit: use buttons on the Xbox controller to set the servo to a specific position (e.g. 45-degrees, 90-degrees, 135-degrees).
    106116
    107117== Fourth program: DC Motor Control