US First Kickoff 2011 Software Programming

Preview:

DESCRIPTION

US First Kickoff 2011 Software Programming. (And Control System) Daniel Kohn University of Memphis. What will be presented……. For Everyone Classmate Updates / Install. Rookie Teams General intro programming options. Veteran Teams Changes from Last Year. Classmate PC. Rookie Teams - PowerPoint PPT Presentation

Citation preview

US First Kickoff 2011Software Programming

(And Control System)

Daniel KohnUniversity of Memphis

What will be presented……

Rookie Teams• General intro

programming options

Veteran Teams• Changes from Last Yea

r

For Everyone• Classmate Updates / Install

Classmate PC• Rookie Teams

There will be NO Software loaded on the Classmate when you get it.

• Veteran Teams Classmates (driver station NetBook) will be re-

imaged. – BACKUP FIRST!

Classmate PC• See handout “Updating the CTL Classmate

PC” for how to load up the software from the USB Thumb Drive provided in the KOP

• Note: Images for rookie and veteran teams are different!

ROOKIE TEAMS

Programming Options• LabVIEW• C/C++• Java

LabVIEW - Advantages• Made By National Instruments (NI)

Makers of the cRIO Control system• Graphical Programming Language• Lots of support on line in forums and from NI

NI is a huge supporter of FRC and FIRST• Lots of build in documentation (help on every

VI)

LabVIEW - Disadvantages• Many windows need to be opened to do

anything (hard to do on the Classmate)• Hard to find things the first time you need

them• Programmers (those who know standard

programming languages) have a hard time with the graphical nature of LabVIEW

Sample LabVIEW Code

C/C++ Advantages• Common programming language

Mentors and students might be more comfortable with C/C++ if they programmed in C before

• Many books on C/C++ (but NOT the specifics for FRC teams)

• Mentors and students who know C/C++ will have a shorter learning curve

C/C++ Disadvantages• Licensing issues!

Sample C/C++ Code

Java Advantages• Uses NetBeans (commonly used by

programmers)• Mentors and students who know Java

already will have a very short learning curve.• All public domain – no licensing issues in off

season and no registration required.

Java Disadvantages• Newest Language (only the 2nd year offered)• Least amount of help/info available

Sample Java Code

Where to Start• Basic code

Each language has basic robot code or templates available

Don’t be afraid to search the internet, some teams post code from previous years!

• HINT: the basic code usually uses the standard wiring (don’t deviate from the standard wiring or code will not work)

Keep Current• A common rookie mistake is not to keep the

software up to date.• Check the 2011 software update website

often: http://www.usfirst.org/roboticsprograms/frc/content.aspx?id=18758

Other Comments• If you are NOT using LabVIEW, you still need

many of the files that are installed with LabVIEW (so you will need to install LabVIEW anyway)

• You will probably want to do your programming on a computer with a bigger screen (laptop)

VETERAN TEAMS

Major Changes This Year• Hardware and Software support for Jaguar

CAN interface• “Watchdog” replaced with “Motor Safety” VI’s

or routines

New with LabView in 2011

Safety VI’s• Instead of the watchdog function that would

shut down the entire robot, safety VI’s now monitor each motor separately.

Drive VI’s• Drive motors now have their own VI’s, with

pre-existing Arcade and Tank Drive VI’s.

Motor Set Output• Motor Set Speed VI has been replaced with

Motor Set Output VI, which is basically the same thing.

CAN Libraries• LabView now has VI’s made specifically for

teams who wish to use CAN.

Other Changes• Improved Error Reporting- Because of the

safety vi’s, errors in the diagnostics tab are more specific.

• Faster build and deployment times.

• Robot Framework- You can choose a framework that comes with some game-specific code.

New Features for 2011

C++ Beta Testing

New Motor Safety Class

class MotorSafety{public: virtual void SetExpiration(float timeout) = 0; virtual float GetExpiration() = 0; virtual bool IsAlive() = 0; virtual void StopMotor() = 0; virtual void SetSafetyEnabled(bool enabled) = 0; virtual bool IsSafetyEnabled() = 0;};

class RobotDrive: public MotorSafety{ <original declarations>

void SetExpiration(float timeout); float GetExpiration(); bool IsAlive(); void StopMotor(); bool IsSafetyEnabled(); void SetSafetyEnabled(bool enabled);

<etc>};

Motor Based Classes

Any class with motion involved is now derived from MotorSafetyand implements its virtual functions.

Usage

• Much like the existing watchdog.

• Watchdog still available, but there is no need to use both.

• Motor(s) will stop if the Motor Safety feature times out.

• No dedicated “Feed” function

• Timeout occurs if the motor speed is not set within the expiration time

• Depending on situation, can use Set(), Drive(), TankDrive() etc.

Example: Autonomous ModeOld Way

void Autonomous(){ // drive forward half speed myRobot.Drive(0.5, 0.0);

// Wait for 2 seconds Wait(2.0);

// Stop myRobot.Drive(0.0, 0.0);}

New Way

void Autonomous(){ Timer driveTime;

driveTime.Start(); do { myRobot.Drive(0.5, 0.0);

// Wait 1 motor update time Wait(0.005); // 5 ms } while (driveTime.Get() < 2.0);

myRobot.Drive(0.0, 0.0);}

Example: Teleop ModeOld Way

while ( IsOperatorControl() ){ myRobot.ArcadeDrive(stick);

if ( stick.GetRawButton(5) ) roller.Set(0.5); else if ( stick.GetRawButton(6) ) roller.Set(1.0); else if ( stick.GetRawButton(4) ) roller.Set(0.0);

// wait for a motor update time Wait(0.005);}

New Way

double rollerSpeed = 0.0;

while ( IsOperatorControl() ){ myRobot.ArcadeDrive(stick);

if ( stick.GetRawButton(5) ) rollerSpeed = 0.5; else if ( stick.GetRawButton(6) ) rollerSpeed = 1.0; else if ( stick.GetRawButton(4) ) rollerSpeed = 0.0;

roller.Set( rollerSpeed );

Wait(0.005); // motor update time}

New Imaging Tool

• now looks for images in ADE specific locations

• now allows you to image when multiple network interfaces are enabled and connected

• will warn you if your PC subnet will not work with the cRIO address

• will allow you to turn on NetConsole

• has more verbose progress feedback

• allows you to rescan for cRIO devices

C/C++ WPILIB

• Safety functiono Take place of watchdogo Works on per-actuator basiso Implemented in all PWM classes 

Java Updates• Updated along with C/C++ and LabVIEW

CAN Watchdog Replaced Etc….

Thanks to…..• Chop Shop )Team 166)

http://www.chopshop166.com/cms/• The Fighting PI (Team 1718)

http://www.fightingpi.org/first-robotics-competition/

• The Green Machine (Team 1816) http://www.edinarobotics.com/

Thanks to…..• Bill’s Blog

http://frcdirector.blogspot.com/• FRC Website

http://www.usfirst.org/Default.aspx

Recommended