Upload
trevor-quinn
View
240
Download
0
Tags:
Embed Size (px)
Citation preview
FRC Robot Framework
Labview Made Easy (er)
For FIRST Robotics
FRC 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
FRC Project
Select FRC cRIO Robot Project
Dialogue box opens
Create 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”
Project 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
Robot Main.vi – Front Panel Front Panel has controls
and indicators Not much on this one Driver’s Station is main
operator interface
Click on “Window” Then Select “Show Block
Diagram”
Robot 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”
11/07/12 8
For now, never mind these X
Robot Main Block Diagram
•We will focus on the main block VIs:
• Begin
• TeleOp
• Autonomous
11/07/12 9
Programming of devices in general follows the following protocol:
OPEN – SET/GET - CLOSE
Open a motor Set the motor speed Close the motor
Open a Joystick Get the Y Joystick Value Close the Joystick
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
Begin.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
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)
Begin.vi
• 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
Begin .vi Modify to Add Extra Motor
Robot 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
Out of Box Code will drive 2 motor drive with Joystick axes 1 & 2
Reads Refnums from Begin.vi
Tele-op.VIGets 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
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
Modify Tele-op.VI for added Motor
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.
From WPI Robotics Library/ Actuators/ MotorControl
Bring the Refnum Get and provide name
Bring Motor Set Output vi and connect them
Next we will see if our code works!
Interfacing with the Robot
Driver Station Operation Tab
Communication Status
Enable/Disable Buttons
Station Number for Competition
Use
User Messages (This area can be controlled by the robot program)
Team Number (Make sure it is
correct)
Communication Status
•Communication = a connection to the cRIO•Robot Code = the user code is running
Battery Voltage Display
Mode Selection•Teleoperated = Driver•Autonomous = Computer Control•Practice = Run like a match
Elapsed time since start of
robot communication
PC Battery
Driver 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
IP 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
IP Address
To Change IP Address
On Computer go to : Control Panel> Network and Internet > view network status > change adapter settings > 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.
Homework Challenge Slides
• Add a gyro device:1. Begin – Open
2. Tele-op – Read gyro and display reading on front panel
• 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
Begin .vi Updated for adding Gyro
Modify 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
Modify 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.
Updated for PS3 Joystick control pad and selectable steering modes
1) Add a “case structure” around the “arcade drive”2) Add a second case “Tank Drive” with a tank drive
function block3) Use Driver station “Digital In 1” as case selector4) Update Joystick for PS3 controller
# 2 Modify Tele-op.VI for option for Tank Drive, selectable from DS
Extra slides for reference
Edit vi: Set up for 4 motor drive:Put cursor on open 2 wheel drive block > right click > replace > drive palette > 4 motor driveUpdate input parameters
Why are 2 motors inverted?
Begin .vi updated for 4 motorsUse this if you put 2 CIMs in each of two gearboxes.