Go to Post There's blood in the water and the Piranhas are biting. It's CD. This thread is gonna have legs all the way til January 9th. - Koko Ed [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 21-02-2010, 02:51
roknjohn roknjohn is offline
Registered User
#1051
Team Role: Engineer
 
Join Date: Jan 2003
Location: Marion
Posts: 31
roknjohn is an unknown quantity at this point
Tank Drive is backwards

Ok, I have a strange issue that makes me think that my joysticks Y axies are 'inverted'. Here's the deal, I'm driving with code like this:

m_robotDrive->TankDrive(LeftJoystick, RightJoystick);

I know that my left and right joysticks are defined correctly because the buttons of each control the desired actions. However, the drive train output isn't correct.

When I press forward on the left joystick, the left hand jaguar leds turn RED and the left motors run backwards. Similarly, when I move the right joystick forward, the right side motors run backwards and the leds are again RED. Moving the joysticks backward, cause the respective motors to run forward and the jaguar LEDs turn GREEN.

Now, obviously I could rewire the motors to get the robot to travel in the correct direction. But shouldn't the LEDs be GREEN for FORWARD and RED for REVERSE?
Reply With Quote
  #2   Spotlight this post!  
Unread 21-02-2010, 08:39
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,113
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: Tank Drive is backwards

The Y axis value for a standard joystick is indeed "inverted" from what most non-pilots would expect. Forward is negative.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2010, 09:20
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Tank Drive is backwards

the colors mean nothing. it basically means the flow of electricity.
you shouldn't judge the movement of the robot by the colors.
i would change the power to the motors that way when u run autonomous, you have code like...
myRobot.Drive(1.0,1.0);//for forward
instead of
myRobot.Drive(1.0,-1.0);// for forward

this makes it easier from a coding standpoint
Reply With Quote
  #4   Spotlight this post!  
Unread 21-02-2010, 09:33
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Tank Drive is backwards

Quote:
Originally Posted by whatabouteve View Post
the colors mean nothing. it basically means the flow of electricity.
you shouldn't judge the movement of the robot by the colors.
i would change the power to the motors that way when u run autonomous, you have code like...
myRobot.Drive(1.0,1.0);//for forward
instead of
myRobot.Drive(1.0,-1.0);// for forward

this makes it easier from a coding standpoint
you are using Drive, not TankDrive, that example is doing donuts at full speed! I think you meant
myRobot.TankDrive(1.0,1.0);//for forward
instead of
myRobot.TankDrive(-1.0,-1.0);// for forward
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #5   Spotlight this post!  
Unread 21-02-2010, 09:47
roknjohn roknjohn is offline
Registered User
#1051
Team Role: Engineer
 
Join Date: Jan 2003
Location: Marion
Posts: 31
roknjohn is an unknown quantity at this point
Re: Tank Drive is backwards

Quote:
Originally Posted by Alan Anderson View Post
The Y axis value for a standard joystick is indeed "inverted" from what most non-pilots would expect. Forward is negative.
Actually, I am a pilot (instrument rated, too). Now as soon as we get our robot flying, the controls would make sense.

But obivously, we want our drivers to push the stick (yoke) forward to drive the robot forward. So, full forward on the stick is -1.0 on the Y-axis? OK, then robotDrive.SetLeftRightMotorSpeeds(-1.0, -1.0) is supposed to drive the robot forward?

It just seems counter intuitive to me, but I've recently rejoined the team after a two year absence - so my thinking may be a bit "old school".
Reply With Quote
  #6   Spotlight this post!  
Unread 21-02-2010, 09:54
roknjohn roknjohn is offline
Registered User
#1051
Team Role: Engineer
 
Join Date: Jan 2003
Location: Marion
Posts: 31
roknjohn is an unknown quantity at this point
Re: Tank Drive is backwards

Quote:
Originally Posted by whatabouteve View Post
the colors mean nothing. it basically means the flow of electricity.
you shouldn't judge the movement of the robot by the colors.
i would change the power to the motors that way when u run autonomous, you have code like...
myRobot.Drive(1.0,1.0);//for forward
instead of
myRobot.Drive(1.0,-1.0);// for forward

this makes it easier from a coding standpoint
If memory serves me correctly, on the spikes and victors, the LEDs glowed green for normal polarity and red for reversed polarity. As such, we've always wired our motors and control logic to match. It just made things simpler to troubleshoot, code, etc.

So, please correct me if I'm wrong.. If we used the RobotDrive class, we have to think of "forward" as the "negative" direction? Sounds just like the economony?
Reply With Quote
  #7   Spotlight this post!  
Unread 21-02-2010, 10:29
roknjohn roknjohn is offline
Registered User
#1051
Team Role: Engineer
 
Join Date: Jan 2003
Location: Marion
Posts: 31
roknjohn is an unknown quantity at this point
Re: Tank Drive is backwards

I think I'm going to try something like this later today:

Code:
 
myRobot.SetInvertedMotor(myRobot.kFrontLeftMotor, true);
myRobot.SetInvertedMotor(myRobot.kRearLeftMotor, true);
myRobot.SetInvertedMotor(myRobot.kFrontRightMotor, true);
myRobot.SetInvertedMotor(myRobot.kRearRightMotor, true);
Reply With Quote
  #8   Spotlight this post!  
Unread 24-02-2010, 17:52
pafwl pafwl is offline
Franciose
AKA: Frank Larkin
FRC #0272 (Cyber Crusaders)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 1998
Location: Lansdale, Pennsylvania
Posts: 108
pafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud ofpafwl has much to be proud of
Re: Tank Drive is backwards

The invert is the answer. Forget about the colors. If you add 1 gear the direction is reversed. Add 2 reversed again.

The Joystick is -1 for full forward. It does not make sense except at a binary level reverse has (-1) more bits on than forward.
Reply With Quote
  #9   Spotlight this post!  
Unread 24-02-2010, 20:29
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Tank Drive is backwards

here is exactly what i did.
Joystick leftstick;
Joystick rightstick;

Victor *left;
Victor *right;

left = new Victor(4,1);
right = new Victor(4,2);


float leftdrive = leftstick.Get();//do the same with the right and you can change the joystick values to make say halfspeed by dividing by 2

left->Set(leftdrive);
Reply With Quote
  #10   Spotlight this post!  
Unread 25-02-2010, 00:14
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Tank Drive is backwards

You can do it either by telling RobotDrive to "invert" the motors, or using whatabouteve's example. I personally prefer the latter because it allows your program to very easily hook into your drive code(i.e.you don't have to re-do your ramping system for when the robot is running on camera tracking)
__________________
Get yer robot source code here!
Reply With Quote
  #11   Spotlight this post!  
Unread 27-02-2010, 23:13
Al3+'s Avatar
Al3+ Al3+ is offline
ARTist
AKA: Anthony
FRC #0840 (Aragon Robotics Team)
Team Role: Programmer
 
Join Date: Oct 2009
Rookie Year: 2008
Location: San Mateo, CA
Posts: 58
Al3+ is a jewel in the roughAl3+ is a jewel in the roughAl3+ is a jewel in the rough
Re: Tank Drive is backwards

Couldn't you also do the following:

drive = new RobotDrive(1, 2);

float leftSpeed = -leftStick.Get();
float rightSpeed = -rightStick.Get();

drive->TankDrive(leftSpeed, rightSpeed);

That's similar to what I've done at the moment. It's not as "proper" as SetInvertedMotor, but it appears to work.
__________________
cout << "Hello, robotics. Goodbye, world." << endl;

"The two-axis accelerometer provided in the kit of parts (shown in the picture below) is a two-axis accelerometer." - WPILib User's Guide
Reply With Quote
  #12   Spotlight this post!  
Unread 27-02-2010, 23:17
jblay's Avatar
jblay jblay is offline
Here comes StuyPulse
AKA: Joe Blay
FRC #0694 (StuyPulse)
Team Role: Coach
 
Join Date: Feb 2008
Rookie Year: 2006
Location: New York, NY
Posts: 984
jblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond reputejblay has a reputation beyond repute
Re: Tank Drive is backwards

I would just go with taking the joysticks and flipping them backwards
__________________
It's pronounced StighPulse like HighPulse
2016 Curie Champions
2016 New York City Champions
2016 New York City Engineering Inspiration
2015 New York City Finalists
2013 New York City Champions
2012 Connecticut Chairman's
2011 Connecticut Chairman's
2010 Connecticut Chairman's

2010 New York City Champions
2008 New York City Engineering Inspiration
2007 New York City Finalists
2006 New York City Finalists
2005 New York City Chairman's
2003 New York City Champions
2002 New York City Engineering Inspiration
2001 New York City Finalists
Reply With Quote
  #13   Spotlight this post!  
Unread 01-03-2010, 23:10
cmh0114 cmh0114 is offline
Registered User
AKA: Cam H
FRC #0217 (Thunderchickens)
Team Role: Alumni
 
Join Date: Jan 2009
Rookie Year: 2005
Location: Michigan
Posts: 61
cmh0114 will become famous soon enoughcmh0114 will become famous soon enough
Re: Tank Drive is backwards

You could always reverse the wiring on your bot so that it matches up with the joysticks. That would probably be the easiest solution and the best if you're really short on time. But if you have time before your next competition and can edit your code, multiply the values of the y-axis of the joysticks by -1 whenever you input them. That should fix your problem without adding too much extra code.
__________________


Thank you to teams 174, 188, 191, 610, and 1551 for some great matches in the FLR finals!!
Reply With Quote
  #14   Spotlight this post!  
Unread 08-03-2010, 01:10
Fletch1373's Avatar
Fletch1373 Fletch1373 is offline
Registered User
AKA: Fletch
FRC #3181 (Panthers)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2004
Location: Rochester, NY
Posts: 251
Fletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud ofFletch1373 has much to be proud of
Re: Tank Drive is backwards

Quote:
Originally Posted by roknjohn View Post
Ok, I have a strange issue that makes me think that my joysticks Y axies are 'inverted'. Here's the deal, I'm driving with code like this:

m_robotDrive->TankDrive(LeftJoystick, RightJoystick);

I know that my left and right joysticks are defined correctly because the buttons of each control the desired actions. However, the drive train output isn't correct.

When I press forward on the left joystick, the left hand jaguar leds turn RED and the left motors run backwards. Similarly, when I move the right joystick forward, the right side motors run backwards and the leds are again RED. Moving the joysticks backward, cause the respective motors to run forward and the jaguar LEDs turn GREEN.

Now, obviously I could rewire the motors to get the robot to travel in the correct direction. But shouldn't the LEDs be GREEN for FORWARD and RED for REVERSE?
I believe that the Jaguars' LED doesn't turn green... but anyone feel free to correct me
__________________
Student:
<04: FRC0213> <05-08: FRC1373>
Mentor:
<09-10: FRC0809> <11-12: FRC3555> <12-14: FRC0073> <15-??: FRC3181>
Volunteer:
<FTAA> <CSA> <Defense Coordinator> <Scorekeeper> <Robot Inspector> <Official Scorer>
2016 Tour:
CTWAT [DefCoord] > Pittsburgh[Mentor/DefCoord] > TVR[FTAA] > FLR[CSA] > NE DCMP[CSA] > CMP[CSA]
Reply With Quote
  #15   Spotlight this post!  
Unread 08-03-2010, 14:22
Alexa Stott's Avatar
Alexa Stott Alexa Stott is offline
All I do is twin.
AKA: elixir
FRC #0025 (Raider Robotix)
Team Role: College Student
 
Join Date: Oct 2005
Rookie Year: 2006
Location: No. Bruns., NJ/College Park, MD
Posts: 781
Alexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond repute
Send a message via AIM to Alexa Stott
Re: Tank Drive is backwards

Quote:
Originally Posted by cmh0114 View Post
You could always reverse the wiring on your bot so that it matches up with the joysticks. That would probably be the easiest solution and the best if you're really short on time. But if you have time before your next competition and can edit your code, multiply the values of the y-axis of the joysticks by -1 whenever you input them. That should fix your problem without adding too much extra code.
Yup. Just reversing the wires on your bot will solve this problem quickly. Just remember that in case you need to change a motor or speed controller out.
__________________
|Email:alexastott[at]gmail.com|Facebook|@zelixir|Google+|
[University of Maryland Computer Science, Psychology]
[Brunswick Eruption]
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tank Drive 'sensitivity' fishLlama NI LabVIEW 5 19-02-2010 21:44
Tank Drive vs. Omni Directional Drive jamie_1930 General Forum 9 24-01-2010 22:50
Tank Drive Sauce Programming 1 05-01-2009 18:50
Tank Drive Idaman323 Programming 14 15-02-2005 09:01
tank drive Stormhammer Programming 11 29-01-2004 23:08


All times are GMT -5. The time now is 13:18.

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