Title: FRC Robot Framework
1FRC Robot Framework
Labview Made Easy (er) For FIRST Robotics
2FRC Framework
- Base Code with Architecture
- Pre-configured
- Defines Interaction between code sections
- Designated places to add functionality
- Focus on robot functionality rather than program
structure
Let's walk through this together
3FRC Project
- Select FRC cRIO Robot Project
- Dialogue box opens
4Create Project
- Give Project a name
- Choose where to save project
- Give cRIO IP address your team number goes in
xx.yy e.g 10.20.67.2 - Click Finish
5Project Explorer
- Project Explorer appears
- All code listed under RT CompactRIO target
10.xx.yy.2 - Displays pre-written set of VI's to allow for an
out of box solution - Top level VI is Robot Main.vi
- Double click to open it
6Robot Main.vi Front Panel
- Front Panel has controls and indicators
- Not much on this one
- Drivers Station is main operator interface
- Click on Window
- Then Select Show Block Diagram
7Robot Main Block Diagram
- Select and modify sub-VI's from here
- Or click on sub VI from Project Explorer
Recommended not to make changes to Robot Main.vi
8Robot Main Block Diagram
- We will focus on the main block VIs
- Begin
- TeleOp
- Autonomous
X
For now, never mind these
9OPEN SET/GET - CLOSE
Programming of devices in general follows the
following protocol
- Open a Device,
- Tell the code where it is plugged in
- Give it a name
Get info from a device, or Set a value to a
device
Close the Device
Open a Joystick
Get the Y Joystick Value
Close the Joystick
Open a motor
Set the motor speed
Close the motor
10Begin.vi
- Initializes the camera, motors, joysticks
- Opens devices
- Tells program where device is plugged into cRio
- Gives the device a Refnum name which can be
recalled from other areas of the program (such as
tele-op)
- Initialize additional components desired to be
added to the system here
11Begin.vi
- Camera configuration unlikely to need to change
this, if use it at all - Discuss in later
session. - Motor configuration set up for 2 motors drive.
- Tell which PWM port plugged into, give it a name
- Why is one motor inverted?
- Set up for 1 joystick
- Tell where plugged into DS
- refnum i.e.name of devices
- Device info stored by that name to be recalled
when device is used (e.g.in tele-op)
12Begin .vi Modify to Add Extra Motor
- Edit vi Add an accessory motor
- Open function palette and select WPI Robotics
Library / Actuators / Motor Control - Add Open Motor .vi
- Identify where plugged in
- What type of controller
- Add Refnum Set.vi
- Give it a name
13Robot Main Calling TeleOp or Autonomous.vi
- This section uses a State Machine
- Case structure
- Inside a while loop
- Continues to loop until robot
Disabled
- Robot Mode controlled by Driver Station or by
Field Management System (In Competitions) - Robot Mode selects Case
14Tele-op.VI
- Out of Box Code will drive 2 motor drive with
Joystick axes 1 2 - Reads Refnums from Begin.vi
- Gets Joystick Axis data
- Cluster of data uses the Unbundle by Name
function block - Sets Drive Motor Speed
- Arcade drive
- X axis turns, Y axis fwd / reverse
Use Context Help (CTRL H) to investigate blocks
These are available but not required
15Modify Tele-op.VI for added Motor
- First Modify Joystick axes for a PS3 controller
- Right click on Axes elements
- Change Axes 1 2 to Axes 3 4
- Right thumb control on PS3 style controller
- Next access Joystick Buttons by connecting to a
Unbundle by name function from the cluster,
palette
- From WPI Robotics Library/ Actuators/
MotorControl - Bring the Refnum Get and provide name
- Bring Motor Set Output vi and connect them
- Now from the Comparison palette bring a
Select Block - Button output is true or false
- Select function assigns a value if true and
another if false - Create constant of 1 if true and 0 if false
- Wire output to the Set Output block - Results in
motor going full speed if trigger is pressed.
16Next we will see if our code works!
Interfacing with the Robot
17Driver Station Operation Tab
- Mode Selection
- Teleoperated Driver
- Autonomous Computer Control
- Practice Run like a match
Team Number (Make sure it is correct)
Battery Voltage Display
Elapsed time since start of robot communication
PC Battery
- Communication Status
- Communication a connection to the cRIO
- Robot Code the user code is running
User Messages (This area can be controlled by the
robot program)
Communication Status
Enable/Disable Buttons
Station Number for Competition Use
18Driver Station Setup TabID Team number to
connect to robot
Team Number Configuration Make sure this is set
correctly
Choose NIC Allows you select which network
adapter is connected to the robot
Joystick Setup Drag Joystick up and down to
switch which connected joystick is 1, 2, 3 or 4
in the program
Exit Logs off the Driver Station Account on the
classmate
Warning this will change your Computer TCP/IP
properties to a static IP address vs.DHCP
19IP Address
- IP (Internet Protocal ) address is how devices
address each other on the internet (public) or
closed wi-fi network. - Normally the IP address is temporary and created
automatically (DHCP) - But for a closed local network we use a static
IP address - Using 10.XX.YY.A where XX. YY is team number and
A is a device number (2 for cRio), - e. g. 10.20.67.2
20IP Address
To Change IP Address On Computer go to Control
Panelgt Network and Internet gt view network status
gt change adapter settings gt Right Click on
Wireless connection, select properties
When driver station opens it will set your
computer IP address to this static value, To
connect to internet this must be reset to the
Obtain address automatically Be sure to say ok
and get all the way out.
21Homework Challenge Slides
- Add a gyro device
- Begin Open
- Tele-op Read gyro and display reading on front
panel
22Begin .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
23Modify Tele-op.VI for Reading 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
24Modify Front Panel Indicatorfor 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 360
- Hover on the 360 until you see the rotation
arrows then drag the 360 around to the zero.
25 2 Modify Tele-op.VI for option for Tank Drive,
selectable from DS
Updated for PS3 Joystick control pad and
selectable steering modes
- Add a case structure around the arcade drive
- Add a second case Tank Drive with a tank drive
function block - Use Driver station Digital In 1 as case
selector - Update Joystick for PS3 controller
26Extra slides for reference
27Begin .vi updated for 4 motorsUse this if you
put 2 CIMs in each of two gearboxes.
Edit vi Set up for 4 motor drive Put cursor on
open 2 wheel drive block gt right click gt replace
gt drive palette gt 4 motor drive Update input
parameters
Why are 2 motors inverted?