|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Mechanum with XBox Controller
As of now our team has the XBox controller working using ArcadeDrive. But we now want to use mechanum wheels.. I have an okay understanding of how to do this with a joystick using x, y, and twist but how do I do it with an XBox controller. I don't even know how I would begin to structure the code.
ANY help would be GREATLY appreciated! THANKS! |
|
#2
|
||||
|
||||
|
Re: Mechanum with XBox Controller
What template are you using? I could give you Iterative sample code.
|
|
#3
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Something like this:
float gyroAngle = 0.0; // we don't have a gyro connected myRobot->MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick.GetZ(), gyroAngle); |
|
#4
|
|||
|
|||
|
Re: Mechanum with XBox Controller
I would just pick one of the sticks for your X and Y axis, and then a good replacement for the joystick twist would be using the analog triggers on the xbox controller. If you need Axis numbers, the input tab on the driver station has live controller readings and axis/button numbers.
|
|
#5
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Could you use one of the joysticks for forward backward and strafing and the other joystick for rotation.
|
|
#6
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Im using command base but just any code examples will do - its easy to change over.
Yeah I was thinking about what daniel was saying - using one stick for x and y and the other for rotation - right now only one is being used. |
|
#7
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Okay here is what I was thinking - use L1 and R1 to turn slow and L2 and R2 to turn fast. Then use left joystick x to move left and right and left joystick y to move up and down - if I push up on the joystick AND move it right the robot should move diagonally - will this work and if so how would I implement it? I also want to be able to have a button - probably the up arrow and down arrow - that I can change the speed with.
THANKS for the help! |
|
#8
|
|||
|
|||
|
Re: Mechanum with XBox Controller
for mechanum wheels, our team also uses a Xbox controller. We have the right joystick axis mapped to the linear movement of the robot, and the the left joystick x axis mapped to the rotation.
Here's a simplified version of our code: //FLMotor = Front Left Motor //FRMotor = Front Right Motor //BLMotor = Back Left Motor //BRMotor = Back Right Motor //x = right joystick, x axis //y = right joystick, y axis //yaw = left joystick, x axis FLMotor = y + x + yaw FRMotor = y - x - yaw BLMotor = y - x + yaw BRMotor = y + x - yaw The values will have to be limited, other-wise it will go beyond the accepted values (-1 to 1). Make sure the wheels are set up properly, and good luck! |
|
#9
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Quote:
|
|
#10
|
||||
|
||||
|
Re: Mechanum with XBox Controller
And how exactly do I do that?
|
|
#11
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Search for the word "normalize" in these docs:
http://www.chiefdelphi.com/media/papers/download/2783 |
|
#12
|
|||
|
|||
|
Re: Mechanum with XBox Controller
Quote:
Last edited by jszipszky : 09-01-2015 at 19:10. |
|
#13
|
||||
|
||||
|
Re: Mechanum with XBox Controller
Quote:
Code:
max=fabs(s1);
if (fabs(s2)>max) max=fabs(s2);
if (fabs(s3)>max) max=fabs(s3);
if (fabs(s4)>max) max=fabs(s4);
if (max>1) {s1/=max; s2/=max; s3/=max; s4/=max;}
|
|
#14
|
||||
|
||||
|
Re: Mechanum with XBox Controller
What size mechanum wheels and what gearbox ratio ?
|
|
#15
|
||||
|
||||
|
Re: Mechanum with XBox Controller
6in and we have not decided on the ratios yet - what is suggested - also should we purchase Heavy Duty or Standard Duty wheels?
Okay thanks Ethan I think im starting to get a picture of what I need to do |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|