FRC LabVIEW Quick Start Guide

advertisement
How to Use This Training Deck
Updated
2/10/14
•
This slide deck is designed to give teams & mentors a quick start in using
FRC LabVIEW. It is not designed to teach you everything but instead give
an overview of important concepts so you can get started on your own.
•
At the end of each section there is a list of links with more detailed
tutorials, training, and troubleshooting info if you want to explore a
certain topic in more detail.
(All Quick Start Links are listed on NI.com.FRC)
•
This training will be updated throughout the FRC Season as I get more
feedback on NI.com/FRC
•
Be sure to install LabVIEW before the presentation and read the notes as
they contain a lot of additional Information
•
(This slide is hidden by default)
ni.com
FRC LabVIEW Quick Start Guide
FRC 2014 Training Material
Set Up
ni.com
LabVIEW
Basics
Vision,
& PID
Advanced
Programming
FRC LabVIEW Quick Start Guide
Set Up
LabVIEW
Basics
•Software Set Up Overview
•FRC Software Orientation
•Finding/Connecting to the cRIO
Vision,
PID, &
Simulation
•Basics of the Robot Project
•Deploying and Driving
Advanced
Programming
ni.com
Set Up
FRC Software Overview
NI Software for FRC 2014
Included in Kit of Parts
Or
Download on NI.com/FRC
•LabVIEW 2013
•LabVIEW Real-Time 2013
•Vision
•PID Control Toolkit 2013
•NI-RIO (driver)
•FRC 2014 Simulation
FRC 2014 Update Suite
Required for ALL FRC Teams
Download Only
•Driver station
•cRIO utilities
•WPI Library
•FRC LabVIEW Templates
•FRC LabVIEW Examples
All Download links available at NI.com/FRC
ni.com
1. Install NI Software
NI Software for FRC 2014 (DVD or Download)
•
If you download the software you must Unzip and run AutoRun.exe
If you program in LabVIEW
If you program in C++/Java
but want to use NI Vision
ni.com
Set Up
Set Up
2. Activation
•
Activate LabVIEW using the serial on the back of the DVD
Envelope
Serial Starts with M
ni.com
3. FRC 2014 Update Suite
•
All Teams must install the Update Suite
Install Update after
LabVIEW
ni.com
Set Up
Set Up
Software Orientation: Getting Started Window
•
This window will open you start LabVIEW
! Requires FRC 2014 Update Suite !
Built In Training
Create New
Project
Tools
Help
Call for Help
Recent
Projects
ni.com
Software Orientation : cRIO Robot Project
•
Set Up
The LabVIEW project window allows you to see all of the code
that will run on your robot. The FRC software includes a
template project with everything you need to start.
All the code you need to
change is in the Team Code
folder
Robot Main will communicate
with the Field control system
and run your team code
(Don’t edit)
ni.com
Software Orientation: Team Code
•
Set Up
This is the Autonomous Independent VI, create your
autonomous program here. This is one of the Vis you will need
to edit.
Instructions Included
Edit this code
ni.com
Software Orientation : Driver Station
•
Set Up
The driver station your robot control utility for practice and
competition for all FRC Teams. Open this to connect to your robot
and run the code you written.
Different Tabs for More
Functionality
This should be your team #
All Lights should be
green to run
ni.com
Robot Statistics
Software Orientation : Dashboard
•
Set Up
The Dashboard is a customizable display and control utility you can
use to read the current status of controllers, sensors, motors, and
Different Tabs for More
more
Controller Inputs
Functionality
& Motor Status
Camera View
ni.com
New Record and playback
feature
Set Up
IP Addresses
Both the driver station computer and the
cRIO need to have unique IP addresses.
IP always end in .2
IP always end in .5
ni.com
Control Panel>Network&Sharing>Adapter settings>Properties>IPV4
Software Orientation : cRIO Imaging Tool
•
This utility allows you to set up your
cRIO controller
Connect to I/O using the
sidecar and bumper boards
Connect to your computer
via ethernet
ni.com
Set Up
Drive a Robot: Step 1
Open the Template Project
Set Up
Step1: From the LabVIEW Getting Started Window, select New >> FRC cRIO Robot Project to
create a new LabVIEW project. (Step 0: Open LabVIEW for FRC!)
If you plan to use real hardware the cRIO and D-Link will need to be properly
set up before attempting the rest. You could run the project in simulation
ni.com
Drive a Robot: Step 2
Configure your cRIO Robot Project
Step2: Fill in the New Project dialog box. Give the project a meaningful name, use
your team number to replace xx.yy in the ip address, and pick the type project you
want to make.
Choose the project type
that sounds most similar
to your robot.
ni.com
Set Up
Drive a Robot: Step 3
Open the Template Project
The code you need to edit
is in the Team Code folder
Set Up
If you add new Vis be sure
they are under the cRIO
To drive your robot open
Robot Main
Step3: To open Robot Main.vi double click on it in the project window. The front
panel should launch. Hit Ctrl+E to open the block diagram and look at the code.
ni.com
Drive a Robot: Step 4
Select a Target
Step4: If you have a cRIO connected make sure it
is selected . If you don’t have an actual
robot to drive around you can still simulate
one. Select the …lvproj/My Computer
target to open the simulator
Simulated cRIO
Real cRIO
(not connected here)
ni.com
Set Up
Driving a Robot: Step 5
Deploy Code
Set Up
Step5: Click on the white run arrow at the top left of Robot Main. The robot project will be
deployed to the cRIO/Simulator. Once LabVIEW is finished deploying the code you will
need to open up the driver station. The LED’s should all be green. Click TeleOp button
and then Start.
ni.com
Set Up
Set Up Resources
Software Set Up Guide
• LabVIEW Development Suite for FRC 2014
• Imaging cRIO & Windows IP Configuration
• Troubleshooting cRIO connections
• Driver Station Tutorial
• Custom Dashboard Tutorial
• Robotics Framework Tutorial
• Robot Simulation Tutorial
•
•
FRC LabVIEW
Quick Start
Guide
Forum Support
•
•
All links available at
NI.com/FRC
Click this button
NI.com/FRC – year round
Phone Support
•
ni.com
1(866)511-6285 from 1pm to 7pm (CST) - During build season only
FRC LabVIEW Quick Start Guide
Set Up
LabVIEW
Basics
• What is LabVIEW?
• LabVIEW development environment
• LabVIEW programming fundamentals
Vision,
PID, &
Simulation
• Tools and Troubleshooting
• Teleop and Autonomous Code
Advanced
Programming
ni.com
What Is LabVIEW?
—
LabVIEW
Basics
A graphical programming environment used to develop sophisticated
measurement, test, and control systems.
Graphical Drag and Drop Code
(Block Diagram)
Rich User Interface
(Front Panel)
Powerful built-in analysis
libraries and tools
ni.com
The LabVIEW Environment
ni.com
LabVIEW
Basics
Parts of Robot Main.vi
Front Panel
(User Interface)
Project Explorer
ni.com
LabVIEW
Basics
Block Diagram
(Code)
Project Explorer
LabVIEW
Basics
LabVIEW file extensions:
LabVIEW project —.lvproj
Virtual instrument (VI) — .vi
Custom control — .ctl
Right-Click to
connect to cRIO
ni.com
File Location in
Wondows
Parts of a VI – Front Panel
LabVIEW
Basics
The front panel is the VIs graphical user interface with inputs and outputs.
Controls (inputs)
buttons,
knobs, slides...
Indicators (outputs)
numeric display,
graphs, LEDS…
LED Indicator
Numeric Indicator
Slider Control
Boolean (On/OFF)
Control
ni.com
LabVIEW
Basics
Controls Palette
Search for Controls
Right-Click on
Front Panel
(not the block diagram)
to open the control
palette
ni.com
Pin to keep open
Browse Sub-Palettes
LabVIEW
Basics
Parts of a VI – Block Diagram
The block diagram is the code for each VI. In LabVIEW graphical blocks are
connected with wires to control the execution.
Loop
Terminal
(Front Panel Objects)
Function
ni.com
LabVIEW
Basics
Functions Palette
Search for functions by name
•Right-Click on the Block Diagram (not the
front panel) to open the functions palette
•Contains the VIs, functions, and constants
you use to create the block diagram.
•FRC Specific Palettes include the WPI
Robotics Library, FIRST Vision, and PID
ni.com
Terminals
LabVIEW
Basics
Terminals allow you to read and write to front panel controls and
indicators.
Same Name
ni.com
Dataflow Programming
•
Order of execution is
controlled by how the
wires are connected
•
Each function will
execute when all of the
inputs are ready.
•
Parallel code executes at
the same time
ni.com
LabVIEW
Basics
Turn on
Highlight
Execution
LabVIEW
Basics
LabVIEW Toolbar
•
The tools you need to run, debug, clean up and edit your code
Front
Tool
Run Tools
Arrange Tools
Debug Tools
Broken Arrow
(Errors found)
ni.com
Clean Up
LabVIEW
Basics
Wires (Data Types)
•
Here are some other examples of wires in LabVIEW
• Floating
point
Broken Wire
(type mismatch)
• Integer
• Boolean
• String
• Array
– note wire thickness
• Cluster
ni.com
(group of other datatypes)
LabVIEW
Basics
Loops
Allow same piece of code to run multiple times
• Exit conditions different for each
•
Run N times
While Loop
Run until stop
condition met
ni.com
For Loop
Iteration Counter
Text Based Math in LabVIEW
Formula Node
Right-Click, Select Help
for syntax info
ni.com
LabVIEW
Basics
Sub VIs
•
Double Click a SubVI to
open it
•
Use the connector pane
to connect controls and
indicators
ni.com
LabVIEW
Basics
Connector
Pane
LabVIEW Programming Demonstration
Programming Demonstration
•Front Panel / Block Diagram
•Tools/ Functions Palettes
•Controls / Terminals
•Wiring
•Constants
•Dropping functions
•Run / Run Continuously
•Loops
•Datatypes
•Highlight execution
ni.com
LabVIEW
Basics
How Do I Make Decisions in LabVIEW?
1.
2.
Case Structures
Select
(a)
(c)
ni.com
(b)
LabVIEW
Basics
Introduction to Clusters
•
Data structure that groups data together
•
Data may be of different types
•
Elements must be either all controls or all indicators
•
Thought of as wires bundled into a cable
Easier to bundle wires together and pass around as a group rather than
wire each individually
•
Order is important
ni.com
LabVIEW
Basics
LabVIEW
Basics
Cluster Functions
• In the Cluster & Variant subpalette of the Programming functions palette
• Can also be accessed by right-clicking the cluster terminal
(Terminal labels
reflect data type)
ni.com
LabVIEW
Basics
Building Arrays with Loops
Auto-Indexing Enabled
• Loops can accumulate arrays
at their boundaries with
auto-indexing
• For Loops auto-index by
default
• While Loops output only the
final value by default
• Right-click tunnel and
enable/disable autoindexing
Wire becomes
thicker
1D Array
0 1 2 3
Auto-Indexing Disabled
Wire remains the same
size
5
ni.com
4 5
Only one value (last
iteration) is passed out
of the loop
Shift Register - Access Previous Loop Data
•
•
•
•
Available at left or right border of loop structures
Right-click the border and select Add Shift Register
Right terminal stores data on completion of iteration
Left terminal provides stored data at beginning of next iteration
Use for next iteration
Initial
Value
ni.com
LabVIEW
Basics
Context Help
LabVIEW
Basics
Click ? To Open
Context Help
•
Displays basic information
about wires and nodes when
you hover over with your
mouse.
•
Turn Context Help On/Off
o
o
o
Click the yellow ? on the top right
corner of your VI
Press <Ctrl-H>
Select Help»Show Context Help
from the LabVIEW menu.
Click for more info
ni.com
LabVIEW Help
•
Contains detailed descriptions and instructions for most palettes,
menus, tools, VIs, and functions.
• Open LabVIEW Help by
− Selecting Help»LabVIEW Help from
the menu
− Clicking the Detailed help
link in the Context Help window
− Right-clicking an object
and selecting Help from
the shortcut menu.
− Press F1
ni.com
LabVIEW
Basics
LabVIEW
Basics
Find Examples
Search by
keyword
•
Find FRC templates in
the Support Tab>>Find
FRC Examples…
•
Or Help>>Find
Examples and browse
to the FRC Robotics
Folder
ni.com
Debugging: Correcting Broken VIs
Broken Run arrow > VI cannot be compiled > VI cannot be executed
Click to open
Error List
ni.com
LabVIEW
Basics
Debugging: Probes
Use the Probe tool to observe intermediate data
values and check the error output of VIs
and functions, especially those performing I/O.
• Specify to retain the values in the wires so that you
can probe wires for data after execution.
•
ni.com
LabVIEW
Basics
LabVIEW
Basics
Telop Code
When Modifying The FRC Robot Project Template, do not modify Robot Main.vi
Modify the code within the Team Code Folder within the Project
This code is called upon in Robot Main.vi
ni.com
Begin.
vi
Teleop.
vi
Finish.
vi
Autonomous Code
•
LabVIEW
Basics
Similar to Teleop, Autonomous executes code by references
Begin.
vi
ni.com
Autonomous Independant.vi
Learn Your Hotkeys
ni.com
LabVIEW
Basics
LabVIEW
Basics
Set Up Resources
Learn LabVIEW - Video Training
LabVIEW Environment Overview
Creating custom controls
LabVIEW Dataflow
LabVIEW Tools
LabVIEW Data Structres
LabVIEW Debugging
WPI Library Overview
•
•
•
•
•
•
•
•
•
FRC LabVIEW
Quick Start
Guide
Forum Support
•
•
All links available at
NI.com/FRC
Click this button
NI.com/FRC – year round
Phone Support
•
ni.com
1(866)511-6285 from 1pm to 7pm (CST) - During build season only
FRC LabVIEW Quick Start Guide
Set Up
LabVIEW
Basics
Vision,
PID, &
Simulation
• Vision
•Code Overview
•Vision Assistant
•PID Control
•What is it?
•LabVIEW PID
• Robot Simulation
Advanced
Programming
ni.com
Vision,
Vision,
PID, &
& PID
Simulation
Vision
NI Vision provides tools to make
your robot smarter.
Vision Uses:
• Locate Colored Object
• Locate Shapes
• Locate game elements
• Calculate distance
Dashboard with
Vision Controls
ni.com
Vision,
PID, &
Simulation
Vision Code
Image Processing
Code
Image data
Add Vision
Code Here
Camera Set
Up Code
ni.com
NI Vision Assistant
Vision,
PID, &
Simulation
Processing
functions
Vision Script
(LabVIEW Code)
Start>Programs>National Instruments>NI Vision Assistant
ni.com
Vision Processing Algorithm
Vision,
PID, &
Simulation
Develop a process to convert a camera image into useful data
for your robot
Segment / Simplify
Convert to Binary Image
Clean Up
Remove Noise
Extract
Output IE: X,Y coordinates of each object
ni.com
Vision,
Vision,
PID, &
& PID
Simulation
Vision Assistant Demonstration
Select mode
Object Pixel
Coordinates
ni.com
Vision,
Vision,
PID, &
& PID
Simulation
Generate Vision Code
Generate
LabVIEW Code
ni.com
Vision,
Vision,
PID, &
& PID
Simulation
Generated Code
This code was generated from Vision Assistant
•
Delete the Open Image code, and paste this into “Vision Processing.vi” in your team
code
Data
Output
Open Image
Selected
Controls
ni.com
Vision,
Vision,
PID, &
& PID
Simulation
Integrate Vision Code
•
Paste generated code in “Vision Processing.vi”
•
•
•
Use the Open Image function in Vision Processing.vi
Now you can do math and make decision using the Data Output
Use Edit>Create SubVI to convert your algorithm to one function to
keep your code clean
Open Image
Edit> Create SubVI
Data Output
ni.com
Vision Examples
2014 Game Specific
Examples
ni.com
Vision,
PID, &
Simulation
PID
Vision,
PID, &
Simulation
Proportional-Integral-Derivative
• An algorithm used in a control feedback loop to regulate a
process such as the motion of a motor or the flow through a
valve
•
Output feeds back into
the input
(Closed-Loop Control)
ni.com
Vision,
PID, &
Simulation
PID in the Real World
Fast but shaky
Just Right
Smooth but
takes too long
ni.com
Tuning a Controller
Adjust the PID gains to appropriate values for your specific
system
• Decrease rise-time and steady-state error
•
ni.com
Vision,
PID, &
Simulation
Using PID in LabVIEW
•
LabVIEW FRC PID palette consists of four VIs:
•
•
•
•
ni.com
PID
PID Setpoint Profile
PID Control Input Filter
PID Lead-Lag
Vision,
PID, &
Simulation
Vision,
PID, &
Simulation
PID in LabVIEW
Set Point
Shift Register
Required for PID
Coefficients set
on Front Panel
NI Example Finder > General PID Simulator.vi
ni.com
Vision,
PID, &
Simulation
PID Example
•
Try the PID Simulator
example
Set Point
PID Coefficients
NI Example Finder > General PID Simulator.vi
ni.com
Vision,
PID, &
Simulation
The Robotics Simulator
Speed Up / Slow
down Simulation
ni.com
View settings
Deploy Code to Simulator
•
Start the Driver Station - it is needed
for real and simulated robots.
•
Right-click in the lower left corner of
Robot Main.vi and choose 2014
Robot Project.lvproj/My Computer
•
Run Robot Main.vi and notice that
the FRC Simulation Viewer opens
•
Enable Teleop mode in order to
drive the simulated robot or enable
Autonomous for independent
control.
ni.com
Vision,
PID, &
Simulation
Exercise-Deploy FRC cRIO Robot Project
•
Deploy the default robot project to the simulator
•
The Driver Station must be running
Simulated Camera View
ni.com
Vision,
PID, &
Simulation
Deploy to Real FRC Robot
•
Right-click in the lower left corner
of Robot Main.vi and choose 2014
Robot Project.lvproj/RT
CompactRIO Target
ni.com
Vision,
PID, &
Simulation
Vision, PID, & Simulation Resources
Configure an AXIS Camera
• Image Processing Tutorial
• Using Vision Targets
• List of NI Vision Functions
• LabVIEW PID Tutorial
• PID Theory Explained
• Robot Simulator Tutorial
Vision,
PID, &
Simulation
•
•
FRC LabVIEW
Quick Start
Guide
Forum Support
•
•
All links available at
NI.com/FRC
Click this button
NI.com/FRC – year round
Phone Support
•
ni.com
1(866)511-6285 from 1pm to 7pm (CST) - During build season only
FRC LabVIEW Quick Start Guide
Set Up
•Customizing Dashboards
•Dashboard Record and Playback
LabVIEW
Basics
Vision,
PID, &
Simulation
•Event Error Logs
•Performance
•Autonomous Strategies
Advanced
Programming
ni.com
Customizing Dashboard
•
Start by opening an FRC Dashboard Project
ni.com
Advanced
Programming
Advanced
Programming
Customizing Dashboards
Additional Robot
Controls
Vision Input
ni.com
Connecting Custom Variables to the Dashboard
Teleop.VI
ni.com
Dashboard Record & Playback
Playback Options
ni.com
Advanced
Programming
Advanced
Programming
Record
Log Location: C:\Users\Public\Documents\FRC\Log Files\Dashboard
ni.com
Advanced
Programming
Playback
Playback
Speed Options
ni.com
Playback Timeline
Troubleshooting: Driver Station Charts
•
Network Issues
•
•
•
Programming Issue
•
•
•
CPU Usage
Free RAM on cRIO
Hardware Issue
•
ni.com
Lost data packets
Data packet trip time
Robot battery voltage
Advanced
Programming
Troubleshooting: Event Error Logs
ni.com
Advanced
Programming
Troubleshooting: Event Error Logs
Log Location: C:\Users\Public\Documents\FRC\Log Files
ni.com
Advanced
Programming
Troubleshooting: Driver Station Diagnostics
•
Advanced
Programming
The Diagnostics tab in the FRC Driver Station can display
important warning and error messages for troubleshooting
Reboot cRIO
ni.com
Advanced
Programming
Debugging: Breakpoints
•
When you reach a breakpoint during execution, the VI pauses and
the Pause button appears red.
•
•
(right-click Breakpoint>Set Breakpoint)
You can take the following actions at a breakpoint:
•
•
•
•
Single-step through execution using the single-stepping buttons.
Probe wires to check intermediate values.
Change values of front panel controls.
Click the Pause button to continue running to the next breakpoint or until
the VI finishes running.
Breakpoint
on a wire
Breakpoint
on a SubVI
ni.com
Performance
Tools>Profile>Performance and Memory
ni.com
Advanced
Programming
Watchdog
•
System Watchdog
•
•
•
Monitors communication from Driver Station
Turns off outputs if no robot communication in 100ms
Causes
1.
2.
3.
ni.com
No communication – radio issues?
Slow Communication – CPU overload?
Driver Station running too slowly – Dashboard hogging CPU
Advanced
Programming
Safety Config Timeouts
You can turn on/off safety timeouts
• Available for RobotDrive, MotorControl, PWM, Relay, and
Solenoid
•
ni.com
Advanced
Programming
Autonomous Strategies
•
Easiest Autonomous – Tell the robot to do the same thing
every time!
ni.com
Advanced
Programming
Autonomous Strategies
•
Closed-loop Feedback
ni.com
Advanced
Programming
Advanced Programming Resources
Advanced
Programming
Full FRC LabVIEW Training (Beginner & Advanced) 4.5 hrs each
• Programming for Performance
All links available at
• Sensor Fusion Tutorial
NI.com/FRC
Click this button
• Autonomous Timed Movement
•
•
Forum Support
•
•
FRC LabVIEW
Quick Start
Guide
NI.com/FRC – year round
Phone Support
•
ni.com
1(866)511-6285 from 1pm to 7pm (CST) - During build season only
NI.com/FRC
Download LV FRC and
Update Suite
Download
FRC 2014
Software
Additional Training
FRC LabVIEW
Quick Start
Guide
NI FRC
Forums
LabVIEW
Training
Learn more for
next season
NI roboRIO
New controller for
FRC 2015
Get help from NI engineers
and other teams
This Power Point and
a list of all links
@nifirstrobotics
ni.com
nifirstrobotics
nifirstrobotics
Download