Go to Post It's cool when good things happen to good people. :) - Rich Kressly [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 29-01-2013, 13:17
e10 e10 is offline
Registered User
FRC #3949
 
Join Date: Nov 2012
Location: Brampton
Posts: 5
e10 is an unknown quantity at this point
Error with the RobotDrive

The robot is moving in the opposite direction from how we move the joystick. It moves forwards and backwards correctly, but it turns left when we turn it right and it turns right when we turn it left. We are using windriver and we are coding in c++. How can i change the direction of the x axis?
Reply With Quote
  #2   Spotlight this post!  
Unread 29-01-2013, 14:04
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: Error with the RobotDrive

You have several options for correcting your problem. The easiest one is simply to swap the left and right motor controls.

Are you using tank drive or arcade drive? If tank, you might have your joysticks swapped. Press a button on the left one and make sure the indicator on the Driver Station display shows that to be the joystick you expect it to be. If they're reversed, just drag them to the proper place in the Setup list.

You could negate the X axis in the code if you're using Arcade drive.

However, the correct thing to do is to go through the motors one by one and make sure the wiring matches the programming. If you run one motor at a time, is it the motor you expect to run? Does it run in the direction you expect it to? There are several places both in hardware and software where things can get swapped.
Reply With Quote
  #3   Spotlight this post!  
Unread 29-01-2013, 15:17
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Error with the RobotDrive

If you are using ArcadeDrive, there is a bug in WPILib in my opinion. I have reported it last year and I am surprise to see it not fixed for this year. See code excerpt below:
If both moveValue and rotateValue are positive, I am expecting the robot to go forward and turn to the right by convention. But as you can see, when both values are positive and for demonstration purpose, let's say moveValue equals to rotateValue. leftMotorOutput will be zero and rightMotorOutput will be some positive number. This will make the robot to turn left, not right!
If you want to argue that my understanding of the convention is wrong, then please look at MecanumDrive_Cartesian and apply the same values (both Y and rotation being positive and equal and X is 0). You will see the left motor powers will be the sum of Y and rotation which are both positive and the right motor powers will be zero. So the robot is turning right. So the convention in mecanum drive is different from the arcade drive! So my conclusion is that ArcadeDrive is wrong.
Code:
WPILib\RobotDrive.cpp line 439:
if (moveValue > 0.0)
{
        if (rotateValue > 0.0)
        {
                leftMotorOutput = moveValue - rotateValue;
                rightMotorOutput = max(moveValue, rotateValue);
        }
        else
        {
                leftMotorOutput = max(moveValue, -rotateValue);
                rightMotorOutput = moveValue + rotateValue;
        }
}
Code:
WPILib\RobotDrive.cpp line 501:
    wheelSpeeds[kFrontLeftMotor] = xIn + yIn + rotation;
    wheelSpeeds[kFrontRightMotor] = -xIn + yIn - rotation;
    wheelSpeeds[kRearLeftMotor] = -xIn + yIn + rotation;
    wheelSpeeds[kRearRightMotor] = xIn + yIn - rotation;
BTW, the way we fixed it was to have our own DriveBase class that inherits the RobotDrive class. We then override the ArcadeDrive method that negates the rotation argument.
__________________

Last edited by mikets : 29-01-2013 at 15:24.
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 14:03.

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