View Single Post
  #5   Spotlight this post!  
Unread 30-01-2009, 16:47
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Drive code not working; any suggestions?

I'm really surprised that this compiles... are you sure you're building the correct project?

One thing I do notice is that the OperatorControl code is only going to execute once. You need to do something like this:

Code:
void OperatorControl()
{
     while (IsOperatorControl())
     {
            update_drive();
     }
}
Additionally, your joysticks and PWM objects need to be declared as member variables within the class, rather than local variables in the class constructor. As it is in your code right now, leftmotor, rightmotor, leftjoy, rightjoy are all only available to use in the constructor.

I'd also recommend against using the PWM class directly. Instead you should use Victor or Jaguar.

Also, take note that the Joystick class will return a float from -1.0 to +1.0 when you look at an axis, not an 8-bit uint from 0-255.

You should have something more like this:

Code:
#include "WPILib.h"

class MyRobot : public SimpleRobot
{
    Victor leftMotor(1);
    Victor rightMotor(2);
    Joystick leftStick(1);
    Joystick rightStick(2);

    void Autonomous()
    {
        // Autonomous code goes here.
    }
    void OperatorControl()
    {
           while (IsOperatorControl())
           {
                // Drive code goes here.
           }
     }
};

START_ROBOT_CLASS(MyRobot);
Hope this is enough to get you started.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award