View Single Post
  #6   Spotlight this post!  
Unread 27-11-2013, 12:14
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Is there an open source robot project out there based of of WPI's SimpleTemplate

Something like this?
Code:
#include <WPILib.h>
//Import necessary libraries here
class DefaultRobot : public SimpleRobot{
	//allocate all required components
	public:
	DefaultRobot(void){	
		//Initialize components
	}
	void Autonomous(void){
		//Run once at the beginning of autonomous
		while(IsAutonomous()){
			//Code that runs throughout autonomous
		}	
	}
	void OperatorControl(void){
		//Run once at the beginning of teleop
		while (IsOperatorControl()){
			//Code that runs throughout teleop
		}
	}
};
START_ROBOT_CLASS(DefaultRobot);
The most basic thing I would then do with this is the following:
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot{	
	Joystick *leftStick;			       
	Joystick *rightStick;          
	RobotDrive *myRobot;                   
	public:
	DefaultRobot(void){	
		leftStick = new Joystick(1);  //USB port 1
		rightStick = new Joystick(2);  //USB port 2
		myRobot = new RobotDrive(1,2); //motor controllers plugged into PWM 1 and 2
	}
	void Autonomous(void){
		while(IsAutonomous()){
		}				
	}
	void OperatorControl(void){
		while (IsOperatorControl()){	
			float leftStickYAxis = leftStick->GetY();
			float rightStickYAxis = rightStick->GetY();	
			myRobot->TankDrive(-leftStickYAxis, rightStickYAxis);  //negate axes depending on the robot's behaviour
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
Does this help at all? What type of drivetrain are you programming?

Last edited by ekapalka : 27-11-2013 at 12:16.
Reply With Quote