Getting Started
The tutorial shown below is for setting up a template that will be used throughout the beginner tutorials. It is highly advised that this tutorial be read prior to continuing on to any other tutorials in e beginner category. For the beginner tutorials, the edits provided to the Command Based Robot Template are meant to make the process of programming a robot in WindRiver easier as the project will now have designated files for initialization of variables as well as a section for global variables which will be explained later.
- click file>new>example
- click VxWorks Downloadable Kernel Module Sample Project
- add FRC Command Based Robot Template
- click OK
- First right click commandbasedrobottemplate on the Project Explorer on the left
- Hit new>file
- Name it global.h
- Hit finish
- Then open up the document named global.h
- Copy the following text:
#ifndef GLOBAL_H
#define GLOBAL_H
#include "WPILib.h"
extern RobotDrive* chassis;
extern Victor* motor_l;
extern Victor* motor_r;
#endif - Right click commandbasedrobot template
- Hit new>file
- Name it init.cpp
- Hit finish
- Copy the following text
#include "WPIlib.h"
RobotDrive* chassis;
Victor* motor_l;
Victor* motor_r;
void init()
{
motor_l = new Victor(1);
motor_r= new Victor(2);
chassis = new RobotDrive(motor_l, motor_r);
}
*note: the number that the victor for the left side of the chassis is plugged into goes inside the parenthesis on the line motor_l = new Victor([write the port in here]);. Do the same for motor_r, the right side of the chassis, motor_r = new Victor([write the port in here]); - right click commandbasedrobottemplate on the Project Explorer on the left
- Hit new>file
- name it: init.h
- hit finish
- copy the following text:
#ifndef INIT_H
#define INIT_H
void init();
#endif - open CommandBasedRobot.cpp located on the project explorer on the left
- under : #include "CommandBase.h" (line 4) write:
#include "init.h"
#include "Global.h" - write under LINE 13:
init(); - right click on commandbasedrobottemplate on the Project Explorer on the left
- click on build project
- celebrate good times come on.
Cheers!