View Single Post
  #13   Spotlight this post!  
Unread 04-03-2012, 16:36
Unforgiven_Hero Unforgiven_Hero is offline
Registered User
FRC #1989
 
Join Date: Feb 2012
Location: Vernon
Posts: 11
Unforgiven_Hero is an unknown quantity at this point
Re: Programming Mecanum Wheels - 4 Victors

Alright, thank you! However, I was sure everything was ready to go but now im getting a watchdog not fed error. I feed the watchdog but its not working. Does anyone know how to fix this?

Code:
#include "WPILib.h"
class RobotDemo : public SimpleRobot
{	
    Victor *leftFrontMotor;
    Victor *leftRearMotor;
    Victor *rightFrontMotor;
    Victor *rightRearMotor;

    RobotDrive *drive; // Drive system for the robot
 
    Joystick *Attack1; // Plugged into USB port 1
    Joystick *Attack2; // Plugged into USB port 2
    
    Jaguar *beltMotor; // Slides the cart for the basketballs
    Jaguar *angleMotor; // Changes the angle for the basketball shooter
    Jaguar *bshooter; // Moves the belt to shoot the basketball (Must be able to go forward and backward)

public:
    RobotDemo(void)
    {

    	//Initialize the four Victors to power the Mecanum wheels
    	leftFrontMotor = new Victor(1); 
        leftRearMotor = new Victor(2);
        rightFrontMotor = new Victor(3);
        rightRearMotor = new Victor(4);

        //Initialize the drive system
        drive = new RobotDrive(leftFrontMotor,leftRearMotor,rightFrontMotor,rightRearMotor);  

        //Initialize the two joysticks used to control the robot
        //Define joysticks being used at USB port #1 and USB port #2 on the Driver's Station
        Attack1 = new Joystick(1);        
        Attack2 = new Joystick(2);

        //Initialize Jaguars for the various Robot's functions
        beltMotor = new Jaguar(5);
        angleMotor = new Jaguar(6);
        bshooter = new Jaguar(7);

        
        Watchdog().SetExpiration(0.1);
        drive->SetExpiration(0.1);
        drive->SetSafetyEnabled(false);

        printf("Object Initialization is a success!");
    }

    void Autonomous(void)
    {
    	while (IsAutonomous() && IsEnabled()) {
    		Watchdog().SetEnabled(false);
    	}
    }
    void OperatorControl(void)
    {
    	//Enable Watchdog  which is responsible for handling robot failure
    	Watchdog().SetEnabled(true);
        drive->SetSafetyEnabled(true);

        //Enter the loop where robot can be controlled manually

        while (IsOperatorControl())
        {
        	Watchdog().Feed();
        	printf("The Operator Controlled period has begun!");
            //Use Attack3 joysticks to drive the robot 
            drive->MecanumDrive_Cartesian(Attack1->GetX(),Attack1->GetY(),Attack2->GetX());
            Wait(0.001);                
        }
    }
}; 
START_ROBOT_CLASS(RobotDemo);
Reply With Quote