I’m new to c++ and I’m trying to code our bot in it, and I really need a reference point (none of the upperclassman coders are helping me). Are there any open source projects for robots out there I could just look at from time to time to learn what I should be doing?
Team 2704’s code from 2013 season is posted at:
http://www.firstplusplus.com/samplerobot-code.html
If you have any questions, or to set up a skype session contact us at:
http://www.firstplusplus.com/contact-us.html
Our 2009 and 2010 robots were done in C++. FIRST Robotics Resources
Team 1967’s code is open source at github.
There are several test jig programs that keep it simple as well as competition sources too.
Feel free to ask questions.
bob
I was looking for sample robot code and stumbled upon this thread. Its great but I am looking for specific pieces of code and it seems like I need to download each code seperately. Can someone post the element of each code so that this won’t be necessary?
Thank y’all!!
Something like this?
#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:
#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?