View Single Post
  #10   Spotlight this post!  
Unread 22-02-2012, 12:39
rbmj rbmj is offline
Registered User
FRC #0612 (Chantilly Robotics)
Team Role: Alumni
 
Join Date: Apr 2011
Rookie Year: 2011
Location: DC Area/Fairfax County
Posts: 192
rbmj is a jewel in the roughrbmj is a jewel in the roughrbmj is a jewel in the rough
Re: Newbie Alert. Our robot is competing, and I can't program it.

You'll need to ask your Electrical team if your motors are wired on Spikes or on Jaguars.

If they're on Spikes, then the relevant class is the Relay class. For Jaguars, see this. You would add motors like this:

Code:
class myRobot : public IterativeRobot { //or SimpleRobot
public:
    //your constructor
    myRobot();
    //the methods you're overriding go here
private:
    Relay motor1;
    Jaguar motor2;
};

//then in your constructor implementation
myRobot::myRobot() :
    motor1(1), //on relay port 1
    motor2(1)  //on pwm port 1
{
    //initialization
}

//then when you want to use them
//to set a spike:
motor1.Set(Relay::kForward); //or Relay::kReverse, or Relay::kOff

//to set a Jaguar
motor1.Set(1.0); //1.0 is full forward, 0.0 is off, -1.0 is full reverse
Make sure to read the GettingStartedWithC, the FRC 2012 control systems document, and everything else that was posted.

Plenty of teams have also open-sourced their code as well if you need to see examples. We have a huge code base, but if you're feeling ambitious, you can look at it here.

And http://cplusplus.com/doc/tutorial/ is a go-to reference.

As always, if you need help, you can post

Oh yeah, @mickets, yes, it is possible, but you're saved from yourself a little bit more
Reply With Quote