Go to Post 5:20 - Lots of discussion about how FIRST pretty much wipes out the world of at least one object every year. - Andy Grady [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-13-2015, 01:19 PM
PredaFran PredaFran is offline
Amateur Programmer
AKA: Francisco
FRC #5285 (Sea Kings Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: California
Posts: 25
PredaFran is an unknown quantity at this point
Post Error in Tank Drive code

even tho the code seems ok, neither the 2 motors move, there is not a single problem with the joystick, or the rio, so it must be the code, any help is appreciated

Code:
#include "WPILib.h"
class Robot: public SampleRobot
{
	bool Piston;
	RobotDrive DriveRobot;
	Joystick leftStick;
	Joystick rightStick;
    Talon m_motor1;
	Talon m_motor2;
public:
	Robot() :

		    DriveRobot(1, 2),
  	        leftStick(0),
	        rightStick(1),
            m_motor1(1),
            m_motor2(2)

{
		DriveRobot.SetExpiration(0.1);
}


	void OperatorControl()
	{
		while (IsOperatorControl() && IsEnabled())
		{

			DriveRobot.TankDrive(leftStick, rightStick);
     		m_motor1.Set(leftStick.GetY());
			m_motor2.Set(rightStick.GetX());
			Wait(0.005);
		}
	}

};

START_ROBOT_CLASS(Robot);
Reply With Quote
  #2   Spotlight this post!  
Unread 02-13-2015, 03:13 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: Error in Tank Drive code

It looks like you're trying to define PWM 1 and 2 as both drive motors and individual motors simultaneously. If you want to do that, declare and initialize your Talons first, then call DriveRobot() with the actual Talon objects instead of the PWM pin numbers. But I think if you remove every reference to m_motor1 and m_motor2 your code will work as you want it to. (Actually, I think it is likely to spin when you try to go straight and vice versa, because one of the drive motors probably needs to be inverted.)

You definitely shouldn't be calling TankDrive() and setting the individual motors.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-13-2015, 05:09 PM
PredaFran PredaFran is offline
Amateur Programmer
AKA: Francisco
FRC #5285 (Sea Kings Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: California
Posts: 25
PredaFran is an unknown quantity at this point
Re: Error in Tank Drive code

Thanks for the reply! it helped us a lot, but the code didnt work as epected.
we are trying to make one joystick control the Y axis movement(foward,backwards) and anothr one the X axis movment (left,right)
any ideas,comments or suggestions are appreciated
Reply With Quote
  #4   Spotlight this post!  
Unread 02-13-2015, 07:51 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: Error in Tank Drive code

If you want forward/reverse control on one joystick and left/right control on the other, you should be using ArcadeDrive instead of TankDrive.
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 10:11 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