_________________A.K.A. inxt-generationSelf-proclaimed genius, and future world dominator.My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth DoctorBow down to Nikola Tesla, King of the Geek Gods.

Sun Feb 02, 2014 4:21 pm

Quantum

Rookie

Joined: Sun Feb 02, 2014 4:09 pmPosts: 3

Re: Help making arcade drive instead of tank?

NeXT-Generation wrote:

I'm not entirely sure what 'arcade drive' is to you - but to me, that would mean push one stick forwards it goes forwards, left/forwards it stops the left track, left it turns in place left, etc.

if (joystick.joy1_x1 != -5) // Here again why is -5 chosen? { motor[motorA] = (joystick.joy1_y1 + joystick.joy1_x1) / 2.56; // Are both of these two used when it's diagonal? And cut to half motor[motorB] = (joystick.joy1_y1 - joystick.joy1_x1) / 2.56; // speed? What does it do exactly? } } else if (joystick.joy1_x1 != -5) //Again -5? Is it not same as above? Is this for when y1 has no value and this is just to spin l/r? { motor[motorA] = joystick.joy1_x1 / 1.28; motor[motorB] = joystick.joy1_x1 / -1.28; }

In arcade drive, we use the x-axis of the joystick to control the turning power and the y-axis to control the driving power. When x-axis is reading zero, both left and the right wheels get the y-axis value as the driving power so it drives forward or backward. When x-axis reads some positive value, we add the value to the left wheel power and subtract the value from the right wheel power so it will turn right. Similarly, when x-axis reads some negative value, the same operation will turn left. So the simplest arcade drive algorithm is like this:

In arcade drive, we use the x-axis of the joystick to control the turning power and the y-axis to control the driving power. When x-axis is reading zero, both left and the right wheels get the y-axis value as the driving power so it drives forward or backward. When x-axis reads some positive value, we add the value to the left wheel power and subtract the value from the right wheel power so it will turn right. Similarly, when x-axis reads some negative value, the same operation will turn left. So the simplest arcade drive algorithm is like this:

Thanks I got it work, now I just need help allowing switch between tank and arcade? Using joy2Btn? or something so if the button was pressed just once then it will be tank then pressed again it will be arcade? How can I do that?

Tue Feb 04, 2014 10:04 pm

BurningLights

Professor

Joined: Sat Aug 31, 2013 9:15 amPosts: 256

Re: Help making arcade drive instead of tank?

Yes, you could use joy1Btn() or joy2Btn() to check to see if a specific button is pressed. If that button is pressed you could toggle a Boolean variable that indicates whether the robot is in tank drive or arcade drive mode. Also, you'll need to keep track of if the button was pressed the last time you checked it, to make sure that you don't change the mode more than once per button press.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum