|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||||
|
|||||
|
Re: switching turning direction using arcade drive?
if(inverted)
{ xOut = x * -1; } Couldn't be more simple than that. |
|
#3
|
|||
|
|||
|
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); Code:
myDrive.ArcadeDrive(myJoystick); Code:
float orientation = 1; if(goingBackwards) orientation = -1; myDrive.ArcadeDrive(myJoystick.GetY() * orientation, myJoystick.GetX()); 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
|
|||
|
|||
|
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
|
|||
|
|||
|
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();
}
}
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
}
}
|
|
#6
|
|||
|
|||
|
Re: switching turning direction using arcade drive?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |