View Single Post
  #1   Spotlight this post!  
Unread 01-02-2014, 14:53
GearTech GearTech is offline
Registered User
FRC #0108
 
Join Date: Dec 2013
Location: United States
Posts: 6
GearTech is an unknown quantity at this point
C++ Help with driving the robot forward

Hello, we are of team 108. We are having some problems with our robot/code. In the code, we tell the robot to drive using the myRobot.TankDrive() function (We're driving in autonomous. We're not worrying about Teleop yet).
We have the robot using 4 Jaguars to connect to 4 motors. The Jaguars are connected to the Digital Side Car in this way:
Front Left motor: PWM 6
Rear Left motor: PWM 5
Front Right motor: PWM 2
Rear Right motor: PWM 1


Code:
#include "WPILib.h"
#include "DriverStationLCD.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
	Jaguar FR, FL, RR, RL;
	Joystick stick; // only joystick
	DriverStationLCD * screen;
	Watchdog Spot;
public:
	RobotDemo():
		FL(6), RL(5), FR(2), RR(1),
		myRobot(FL, RL, FR, RR),	// these must be initialized in the same order
		stick(1)		// as they are declared above.
	{
		Spot.SetEnabled(false);
		screen = DriverStationLCD::GetInstance();
//		myRobot.SetExpiration(0.1);
		myRobot.SetSafetyEnabled(false);
		screen->Printf(DriverStationLCD::kUser_Line2, 1, "It works $@#$@#$@#$@#$@#es!");
		screen->UpdateLCD();
		
		myRobot.TankDrive(.5, .5);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous()
	{
		screen->Printf(DriverStationLCD::kUser_Line3, 1, "It works $@#$@#$@#$@#$@#es!");
		screen->UpdateLCD();
		myRobot.TankDrive(.5, .5);		
//		FR.SetSpeed(.5);

//		myRobot.SetSafetyEnabled(false);
//		myRobot.TankDrive(0.5, 0.5);
		Wait(2.0); 				//    for 2 seconds
//		myRobot.TankDrive(0.5, 0.5);
		Wait(2.0);
		screen->Printf(DriverStationLCD::kUser_Line4, 1, "It works $@#$@#$@#$@#$@#es!");
		screen->UpdateLCD();

	}

	/**
	 * Runs the motors with arcade steering. 
	 */
	void OperatorControl()
	{
//		myRobot.SetSafetyEnabled(true);
//		while (IsOperatorControl())
//		{
//			myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
//			Wait(0.005);				// wait for a motor update time
//		}
	}
	
	/**
	 * Runs during test mode
	 */
	void Test() {

	}
};

START_ROBOT_CLASS(RobotDemo);
Using this code the robot will not drive in autonomous.
We added DriverStationLCD objects and methods to debug and test where the code gets its errors. The code goes through autonomous perfectly, just not driving the robot. We want the robot to drive at half speed forward for 2 seconds. Thank you in advanced.

*EDIT*
Also, the jaguars do not have a solid light when the autonomous is enabled. They are continuously blinking while enabled on every setting.

Last edited by GearTech : 01-02-2014 at 14:56.
Reply With Quote