Presentation is loading. Please wait.

Presentation is loading. Please wait.

Add and Use a Sensor & Autonomous For FIRST Robotics

Similar presentations


Presentation on theme: "Add and Use a Sensor & Autonomous For FIRST Robotics"— Presentation transcript:

1 Add and Use a Sensor & Autonomous For FIRST Robotics
FRC Robot Framework Add and Use a Sensor & Autonomous For FIRST Robotics

2 Sensors – Adding Intelligence and Enabling Automation
Types of sensors: Limit Switches – on/off Gyro - provides Robot rotation angle position Potentiometer – like a volume control – can be used to control arm rotation Encoder - measures shaft rotation – robot distance, lift height Light sensors – detect object breaking beam Infrared - detect presence of object nearby Ultrasonic - detects distance to object – such as wall Camera (Vision) - Direct feed to dashboard, Targeting with vision processing Kinect (Camera + Infrared) – For Driver Station or on board robot? not used ….. yet…

3 Session Objectives: Discuss principles and applications for “Gyro” sensor. Bicycle wheel demo Incorporate “Gyro” into Autonomous code: Control Robot to drive in straight line Open Gyro in Begin.vi Get Gyro Angle Tele-op.vi display on Front Panel Next use Gyro reading as “Feedback” to tell if robot is driving straight (at angle specified) PID control

4 FRC Project Browse to find your last code
(or open new) Navigate to the Robot Main block diagram Then select Begin Go to Block Diagram

5 Begin .vi Updated for adding Gyro
Edit vi: Add an accessory motor: Open function palette and select: WPI Robotics Library / Sensors / Gyro Add Open Gyro .vi Identify where plugged in Add Refnum Set.vi Give it a name

6 Open the “Autonomous VI”
Remove diagram disable Put cursor on edge of disabled structure, right click and select “Remove Diagram Disable Structure” Delete the last 2 while loops After noting what the default code is intended to do A method of sequencing operations in autonomous that we may return to

7 Set up a While Loop in Autonomous
In remaining While Loop: Enlarge, create space to add Gyro and PID functions Change length of time to 5 seconds Each loop is 50 ms, 100 loops = 5 secs. Change motor inputs to 0 For now

8 Modify Autonomous.VI to Read Gyro
From WPI Robotics Library/ Sensors/ Gyro palette Bring the Refnum Get and provide name it was given in the Begin.vi Bring Gyro Get Output vi and connect them Put cursor on “angle” output, right click, select, create indicator Indicator shows up on Front Panel Digital indicator is default but can be replaced with a Dial or Linear Indicator

9 Modify Front Panel Indicator for Gyro reading
Put Cursor on indicator, right click and select “Replace”, then “Gauge” Enlarge gauge by dragging diagonally Click on the 10 and change to: 180 Click on the 0 and make it: -180 Hover on the 180 until you see the rotation arrows – then drag the 180 around to the -180.

10 Test the Code See if in Autonomous the Gyro is being read
Next: Lets use it for an Autonomous code With “Feed-back” control

11 Feed-Back Control Open Loop: Examples:
In an (older) car: turn heater knob to high Heater turns on and stays on until the driver gets too hot and manually turns it down Robot Harvester(2012): Operator holds button to turn harvester motor, watches until sees ball move up and then releases which stops motor Controller Robot

12 Feed-Back Control Closed Loop Examples:
In a (newer) car: turn heater knob to 70oF Heater goes on until the thermostat (sensor) reads that it is 70oF , then automatically turns it off until it gets too cool, then back on, etc. Robot Harvester: Operator presses button to start harvester motor Motor goes until on board light sensor “sees” ball – sends signal back to cRio Labview program then directs motor to stop Controller Robot Sensor Generally using it to see if a process is complete, then stabilize

13 PID Control PID stands for Proportional-Integral-Derivative
A method of closed loop feedback control A way of using what you know from your sensors to compute an “intelligent” motor output. Proportional – P – looks at difference between desired position and actual and sets motor speed to close gap proportional to that gap Incorporates the idea that you need to slow down as you get close so you don’t overshoot the target.

14 The PID Function Block Set-point Process variable
Desired value to get to Process variable Actual value as measured by a sensor Output determined by magnitude of difference (error) between setpoint and process variable PID Gains adjust sensitivity

15 Add: Read Gyro And PID Control Of Steering Correction
Get Gyro Refnum, Get Gyro Angle Add PID function block Setpoint – set to 0 to drive straight forward Connect Gyro output as Process variable input to PID Limit output range Set PID gains Connect output to X input to arcade drive (Steering)

16 Suggested method for determining PID gains
Method for Setting Values  Start with CP small and CI, CD both zero.  Raise CP until the robot is oscillating consistently around the target.  Once this is accomplished, start increasing CD until the robot stops oscillating.  Then add CI until the robot stops within a desired range of the target. Often we have only used the P, or PD

17 Next we will see if our code works!

18 Homework Challenge Slides
Learn how to modify the Dashboard Make an autonomous Drive Sequence Drive a square pattern Learn to use the “examples” and be able to code a variety of sensors – including encoder

19 Modifying the Dashboard – Gyro Indicator
Open Dashboard Project, Modify to display Gyro angle on a gage (follow Labview tutorial number 7) Modify Robot code Tele-op to send data to dashboard (also part of Labview tutorial) DashboardMain.vi Front Panel:

20 Incorporating Sensors – Gyro::
Open Dashboard Project, Modify to display Gyro angle on a gage (follow Labview tutorial) Modify Robot code Tele-op to send data to dashboard (also part of Labview tutorial) Follow Tutorials 4-7 Adds Gyro Opens Dashboard Project

21 Homework / Challenge # 2 Update the Autonomous code
Add 3 sequential While loops (like in default disabled structure) Have robot go straight, turn 90 degrees, Repeat 3 times to drive in a square.

22 Homework / Challenge # 3 Add variety of sensors to Begin and Tele-op Use “Examples” as source to copy correct formats

23 Begin.VI - Open and name sensors

24 Tele-op.VI - Get values and display


Download ppt "Add and Use a Sensor & Autonomous For FIRST Robotics"

Similar presentations


Ads by Google