Go to Post "If I say its name three times, will it appear in my lab?" - Madison [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-01-2014, 02:53 PM
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 : 02-01-2014 at 02:56 PM.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-01-2014, 03:41 PM
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: C++ Help with driving the robot forward

Welcome to Chief Delphi!

The Jaguar LEDs blinking yellow indicates that there is no PWM signal. Check your PWM connections and cables. Also, just a suggestion, but you might find it easier to debug drive motor issues in teleop mode than in autonomous mode.
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote
  #3   Spotlight this post!  
Unread 02-01-2014, 10:46 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: C++ Help with driving the robot forward

Code:
// these must be initialized in the same order
// as they are declared above.
I've always treated that as deep magic that must not be tampered with. Your initializations quite reasonably put the Jaguars before the RobotDrive, but your declarations have the RobotDrive first.
Reply With Quote
Reply


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 09:51 AM.

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