View Single Post
  #1   Spotlight this post!  
Unread 15-02-2010, 11:40
abpahl abpahl is offline
Registered User
FRC #3407
 
Join Date: Feb 2010
Location: Shoreview, MN
Posts: 4
abpahl is an unknown quantity at this point
Very basic programming issue

First of all, I know almost nothing of programming. We spent a lot of time on debugging and troubleshooting, and I'm just now getting around to writing the code. I have a tiny issue that I don't know how to fix.

I'm building my code off the sample template, and having almost no C++ knowledge, I'm working completely off example.

My currently modified( not by much, just added a third motor) code is as follows:

Code:
#include "WPILib.h"
#include "vision/AxisCamera2010.h"
/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */ 
class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	Joystick stick;// only joystick
	Jaguar kicker; // call kicking motor

public:
	RobotDemo(void):
		myRobot(1, 2),	// these must be initialized in the same order
		stick(1),
		kicker(3)// the motor for kicking should be plugged into slot 3
		// as they are declared above.
	{
		GetWatchdog().SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		// I edited this code for testing
		GetWatchdog().SetEnabled(false);
		myRobot.Drive(0.5, 0.0); 	// drive backwards half speed
		Wait(1.0); 			
		myRobot.Drive(0.0,0.0);//    stop for a bit
		Wait(1.0);
		myRobot.Drive(-5.0, 0.0);// go back to where you started
		Wait(1.0);
		myRobot.Drive(0.0,0.0);
}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl(void)
	{

		
		GetWatchdog().SetEnabled(true);
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
			if  (stick.GetTrigger()) // use trigger to activate kicking device (I added this bit)
				kicker.Set(1.0); // If trigger is pressed, full speed!
			else
				kicker.Set(.2); // Otherwise, go at 1/5 speed
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
The issue is that the joystick is currently reversed. Forward and backwards are fine, but if you go left on the joystick, the robot goes right, and vice versa. Switching the PWM slots on the jaguars doesn't help, it just inverts forward and backwards. It seems like this would be very easy to fix, but I have no clue where to start.

Do I need to modify RobotDrive? And if so, where do I modify it? If I modify a file in WPIlib, will the new file get built into my project?
Reply With Quote