Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Tank Drive is backwards (http://www.chiefdelphi.com/forums/showthread.php?t=83250)

roknjohn 21-02-2010 02:51

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?

Alan Anderson 21-02-2010 08:39

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.

whatabouteve 21-02-2010 09:20

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

byteit101 21-02-2010 09:33

Re: Tank Drive is backwards
 
Quote:

Originally Posted by whatabouteve (Post 925194)
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

roknjohn 21-02-2010 09:47

Re: Tank Drive is backwards
 
Quote:

Originally Posted by Alan Anderson (Post 925167)
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".

roknjohn 21-02-2010 09:54

Re: Tank Drive is backwards
 
Quote:

Originally Posted by whatabouteve (Post 925194)
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? :)

roknjohn 21-02-2010 10:29

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);


pafwl 24-02-2010 17:52

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.

whatabouteve 24-02-2010 20:29

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);

nathanww 25-02-2010 00:14

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)

Al3+ 27-02-2010 23:13

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.

jblay 27-02-2010 23:17

Re: Tank Drive is backwards
 
I would just go with taking the joysticks and flipping them backwards

cmh0114 01-03-2010 23:10

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.

Fletch1373 08-03-2010 01:10

Re: Tank Drive is backwards
 
Quote:

Originally Posted by roknjohn (Post 925116)
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

Alexa Stott 08-03-2010 14:22

Re: Tank Drive is backwards
 
Quote:

Originally Posted by cmh0114 (Post 930327)
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.


All times are GMT -5. The time now is 11:25.

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