Go to Post The difference between a robotics kid and a generic nerd. Both use their calculators for statistical analysis. One keeps it a closely guarded secret, the other brags about it on Chief Delphi! - Kevin Leonard [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi