OCCRA
Go to Post Your GPA in High School and College is a reflection of your cooperation with educational processes, nothing more. It is NOT a measurement of how much you know or how much you can learn. - Mike Martus [more]
Home
Go Back   Chief Delphi > Technical > Programming > WindRiver C++
CD-Events   CD-Media   CD-Spy   FRC-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 03-30-2012, 11:00 AM
cddp14 cddp14 is offline
Registered User
FRC #1270
 
Join Date: Feb 2007
Location: Clevleand, Oh
Posts: 10
cddp14 is an unknown quantity at this point
Flipping the X - axis

Ok. this a simple problem that I know I am just overlooking a small detail. For this years robot we what to be able to push a button to be able to make the back of the robot to become the front and vice versa during TeleOp mode. The only problem is that the x-axis of doesn't adjust when the switch is made. when the robot is reversed and you move the joystick to the left the robot turns to the right and vice versa. Here is my code below:
MyBase->ArcadeDrive(Driver);
if(Driver->GetRawButton(6))// reverse direction of robot
{

MyBase->SetInvertedMotor(RobotDrive::kRearLeftMotor, true);
MyBase->SetInvertedMotor(RobotDrive::kFrontLeftMotor,true );
MyBase->SetInvertedMotor(RobotDrive::kRearRightMotor, true);
MyBase->SetInvertedMotor(RobotDrive::kFrontRightMotor,tru e);

}
if(Driver->GetRawButton(7))// normal configuration
{

MyBase->SetInvertedMotor(RobotDrive::kRearRightMotor, false);
MyBase->SetInvertedMotor(RobotDrive::kFrontRightMotor,fal se);
MyBase->SetInvertedMotor(RobotDrive::kRearLeftMotor, false);
MyBase->SetInvertedMotor(RobotDrive::kFrontLeftMotor,fals e);


}
How can I get the X- axis to switch with the reversal? Thanks in advance. Also, I am using WindRiver.

Last edited by cddp14 : 03-30-2012 at 11:02 AM.
Reply With Quote
  #2   Spotlight this post!  
Unread 03-30-2012, 11:18 AM
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 966
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: Flipping the X - axis

You need to also switch around your motors.
left side & right side swaps
Left front becomes right rear
left rear becomes right front
ETC

For a simple tank drive might be easier to swap & invert the joy sticks inputs into the motors.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-30-2012, 12:59 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,192
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Flipping the X - axis

Quote:
Originally Posted by cddp14 View Post
.
Instead of inverting the motors, just try changing the sign of the joystick X and Y values before feeding them into the arcade algorithm

Reply With Quote
  #4   Spotlight this post!  
Unread 03-30-2012, 02:17 PM
cddp14 cddp14 is offline
Registered User
FRC #1270
 
Join Date: Feb 2007
Location: Clevleand, Oh
Posts: 10
cddp14 is an unknown quantity at this point
Re: Flipping the X - axis

Quote:
Originally Posted by Ether View Post
Instead of inverting the motors, just try changing the sign of the joystick X and Y values before feeding them into the arcade algorithm

I have looked into doing that but I have not had any success. any sample code would be helpful
Reply With Quote
  #5   Spotlight this post!  
Unread 03-30-2012, 02:51 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,192
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Flipping the X - axis

Quote:
Originally Posted by cddp14 View Post
I have looked into doing that but I have not had any success. any sample code would be helpful
sample code? not to be flippant, but this is what I meant:

Code:
Y = -Y;
X = -X;

Reply With Quote
  #6   Spotlight this post!  
Unread 03-30-2012, 04:07 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: 7,894
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
Send a message via AIM to Alan Anderson
Re: Flipping the X - axis

Quote:
Originally Posted by Ether View Post
sample code? not to be flippant, but this is what I meant:

Code:
Y = -Y;
X = -X;

Maybe you don't realize that the single-argument ArcadeDrive() method he's using doesn't provide anywhere to do this inversion. The sample code he's asking for is how to get around that lack. By the way, it's only the Y axis that needs to be inverted. The originally posted code is already getting the effect of inverting both axes by running all the motors in the other direction.

Try this: (warning -- untested)
Code:
if(Driver->GetRawButton(6)) // reversed direction of robot
{
    directionInverted = true;
}
if(Driver->GetRawButton(7)) // normal configuration
{
    directionInverted = false;
}
if(directionInverted)
{
    MyBase->ArcadeDrive(-Driver->GetY(),Driver->GetX(),false);
}
else
{
    MyBase->ArcadeDrive(Driver);
}
You'll have to declare directionInverted as a static boolean variable, with an initial value of false.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-30-2012, 05:23 PM
cddp14 cddp14 is offline
Registered User
FRC #1270
 
Join Date: Feb 2007
Location: Clevleand, Oh
Posts: 10
cddp14 is an unknown quantity at this point
Re: Flipping the X - axis

Quote:
Originally Posted by Alan Anderson View Post
Maybe you don't realize that the single-argument ArcadeDrive() method he's using doesn't provide anywhere to do this inversion. The sample code he's asking for is how to get around that lack. By the way, it's only the Y axis that needs to be inverted. The originally posted code is already getting the effect of inverting both axes by running all the motors in the other direction.

Try this: (warning -- untested)
Code:
if(Driver->GetRawButton(6)) // reversed direction of robot
{
    directionInverted = true;
}
if(Driver->GetRawButton(7)) // normal configuration
{
    directionInverted = false;
}
if(directionInverted)
{
    MyBase->ArcadeDrive(-Driver->GetY(),Driver->GetX(),false);
}
else
{
    MyBase->ArcadeDrive(Driver);
}
You'll have to declare directionInverted as a static boolean variable, with an initial value of false.
This worked!!! Thanks!!!
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 06:01 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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