Go to Post Do you mean...? If so, it's illegal under . (insert your favorite reminder to read the manual here) - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-03-2010, 23:26
Kyledoo Kyledoo is offline
Registered User
FRC #2603
 
Join Date: Jan 2010
Location: Ohio
Posts: 24
Kyledoo is an unknown quantity at this point
switching turning direction using arcade drive?

We have implemented a way to change the polarity of the motors by hitting a button(simply using the SetInvertedMotor), and in this way, we can select which end of our robot is the front. However, while in the reversed mode, pushing the stick to the left turns the robot to the right. I was exploring a way to basically invert the x axis of the joystick. any ideas on how to do this? oh and we have our first matches tomorrow, so i'm hoping to figure it out sooner rather than later!
We are using C++
  #2   Spotlight this post!  
Unread 11-03-2010, 23:32
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: switching turning direction using arcade drive?

if(inverted)
{
xOut = x * -1;
}

Couldn't be more simple than that.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #3   Spotlight this post!  
Unread 11-03-2010, 23:35
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: switching turning direction using arcade drive?

You can use the ArcadeDrive method that takes raw values for the speed/turn inputs. This is the signature:
Code:
void RobotDrive::ArcadeDrive(float moveValue, float rotateValue, bool squaredInputs = true);
So instead of doing something like this
Code:
 myDrive.ArcadeDrive(myJoystick);
You could do something like
Code:
float orientation = 1;

if(goingBackwards) 
   orientation = -1;

myDrive.ArcadeDrive(myJoystick.GetY() * orientation, myJoystick.GetX());
You shouldn't have to reverse the motors with that.

EDIT: You shouldn't have to reverse the X axis actually. Kind of counter intuitive, but thats the way it works out. A left hand turn is a left hand turn looking forward and backward. You just want to change your direction. (moveValue)

Last edited by Tom Bottiglieri : 11-03-2010 at 23:45.
  #4   Spotlight this post!  
Unread 12-03-2010, 00:05
Kyledoo Kyledoo is offline
Registered User
FRC #2603
 
Join Date: Jan 2010
Location: Ohio
Posts: 24
Kyledoo is an unknown quantity at this point
Re: switching turning direction using arcade drive?

Thanks for the great quick responses! I really can't believe i missed that now... but anyways, is anyone timing the release of pnumatics(we want to leave our kicker extended for a full second once we press the button). What makes most sense to me is to use a for loop, and possibly put this inside an if.
For example:
if(buttonpressed){
for(i = 0; i<10; i++){
// whole code
//feed watchdog
s1->Set(true);
Wait(.1);
}
}
any experiences with this? we basically have tomorrow morning to test all the code and make any necessary modifications so i'd just like to know what to expect. Also, would this concept work for restricting kicker movement after it retracts(so we don't get a penalty)?
  #5   Spotlight this post!  
Unread 12-03-2010, 02:26
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: switching turning direction using arcade drive?

You probably dont want to have any kind of nested loops in your main program loop, unless you are certain it will execute fast enough. A for loop will block the execution of the code after it, and will fire the watch dog, or worse, cause your bot to "freeze" its output values while the loop is executing.

Instead, you could use a Timer object.
Code:
class MyRobot : public IterativeRobot
{
   // Declare the timer
   Timer * kickTimer;
 
   // Then down in the constructor...
   MyRobot(void){
      // ...
      kickTimer = new Timer();
   }

   void TeleopPeriodic(void){
      if( somethingHappened ){
         kickTimer->Start();
         mySolenoid->Set(true);
      }

      if( kickTimer->Get() >= 1.0){
         mySolenoid->Set(false);
         kickTimer->Stop();
         kickTimer->Reset();
      }
}
Or you could just increment a counter every time you loop around
Code:
static unsigned int solenoidCounts = 0;
static bool kickerFired = false;

if(somethingHappened){
   solenoid->Set(true);
   kickerFired = true;
   solenoidCounts = 0;
}

if(kickerFired){
   solenoidCounts++;
   if(solenoidCounts > 1 * 40){ // 40Hz(ish)
      solenoid->Set(false);
      kickerFired = false;
      solenoidCounts = 0; // just to be safe
   }
}
It's not the prettiest thing in the world, but it gets the job done and its pretty easy to understand/implement/change.
  #6   Spotlight this post!  
Unread 25-03-2010, 23:17
Kyledoo Kyledoo is offline
Registered User
FRC #2603
 
Join Date: Jan 2010
Location: Ohio
Posts: 24
Kyledoo is an unknown quantity at this point
Re: switching turning direction using arcade drive?

Quote:
Originally Posted by Tom Bottiglieri View Post
You probably dont want to have any kind of nested loops in your main program loop, unless you are certain it will execute fast enough. A for loop will block the execution of the code after it, and will fire the watch dog, or worse, cause your bot to "freeze" its output values while the loop is executing.

Instead, you could use a Timer object.
Code:
class MyRobot : public IterativeRobot
{
   // Declare the timer
   Timer * kickTimer;
 
   // Then down in the constructor...
   MyRobot(void){
      // ...
      kickTimer = new Timer();
   }

   void TeleopPeriodic(void){
      if( somethingHappened ){
         kickTimer->Start();
         mySolenoid->Set(true);
      }

      if( kickTimer->Get() >= 1.0){
         mySolenoid->Set(false);
         kickTimer->Stop();
         kickTimer->Reset();
      }
}
Or you could just increment a counter every time you loop around
Code:
static unsigned int solenoidCounts = 0;
static bool kickerFired = false;

if(somethingHappened){
   solenoid->Set(true);
   kickerFired = true;
   solenoidCounts = 0;
}

if(kickerFired){
   solenoidCounts++;
   if(solenoidCounts > 1 * 40){ // 40Hz(ish)
      solenoid->Set(false);
      kickerFired = false;
      solenoidCounts = 0; // just to be safe
   }
}
It's not the prettiest thing in the world, but it gets the job done and its pretty easy to understand/implement/change.
Hey. I know it has been awhile since I actually asked this question, but we are now at our second regional(Buckeye) and it has been quite hectic. I just wanted to thank you for all the advice, I used that same format you suggested and we were even able to put in a penalty preventer so that the kicker will not fire more than once every 2 seconds.
Closed Thread


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
Semi-Omni-Arcade Drive byteit101 Programming 20 24-01-2010 08:21
Normalizing motor speeds using Arcade Drive in Labview rsisk NI LabVIEW 9 28-08-2009 20:56
Programming Arcade Drive kyungjin C/C++ 4 06-04-2009 11:28
Arcade/Tank Drive Malfunction piedmont Programming 2 19-01-2009 17:37
Arcade Drive Anfony VEX 4 08-11-2006 19:46


All times are GMT -5. The time now is 23:10.

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