Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Mechanum with XBox Controller (http://www.chiefdelphi.com/forums/showthread.php?t=132265)

LFRobotics 06-01-2015 17:39

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!

cyborgstx 06-01-2015 18:31

Re: Mechanum with XBox Controller
 
What template are you using? I could give you Iterative sample code.

SuperBK 06-01-2015 23:07

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);

afiolmahon 07-01-2015 08:33

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.

daniel12997 07-01-2015 09:47

Re: Mechanum with XBox Controller
 
Could you use one of the joysticks for forward backward and strafing and the other joystick for rotation.

LFRobotics 07-01-2015 11:07

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.

LFRobotics 07-01-2015 11:22

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!

lynca 07-01-2015 11:54

Re: Mechanum with XBox Controller
 
Quote:

Originally Posted by LFRobotics (Post 1423074)
But we now want to use mechanum wheels..

What size mechanum wheels and what gearbox ratio ?

Ethan_P 07-01-2015 12:18

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!

LFRobotics 07-01-2015 13:06

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

Ether 07-01-2015 14:20

Re: Mechanum with XBox Controller
 
Quote:

Originally Posted by Ethan_P (Post 1423605)
The values will have to be limited, other-wise it will go beyond the accepted values (-1 to 1).

Make sure you do the limiting via normalization, not clipping.



LFRobotics 07-01-2015 15:30

Re: Mechanum with XBox Controller
 
And how exactly do I do that?

Ether 07-01-2015 16:10

Re: Mechanum with XBox Controller
 
Quote:

Originally Posted by LFRobotics (Post 1423789)
And how exactly do I do that?

Search for the word "normalize" in these docs:

http://www.chiefdelphi.com/media/papers/download/2783



Mecanum Wheel 07-01-2015 22:22

Re: Mechanum with XBox Controller
 
Quote:

Originally Posted by LFRobotics (Post 1423074)
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!

Quote:

Originally Posted by lynca (Post 1423591)
What size mechanum wheels and what gearbox ratio ?

Quote:

Originally Posted by Ethan_P (Post 1423605)
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!

Hey LF, Andrew, and Ethan! Just for future reference, it's spelled mecanum. It's an easy mistake to make. Good luck this season!

Sl3dman 07-01-2015 23:17

Re: Mechanum with XBox Controller
 
I would start here. https://wpilib.screenstepslive.com/s...-mecanum-drive
Our team did our first mecanum over off season and found out that it was better to replace the "Get Z Axis" and "Get X Axis" and "Get Y Axis" with get raw axis with which ever ones you want. We put the X Axis to strafe left and right on axis 0 (left joystick X Axis). The Y Axis to go forwards and backwards on axis 1 (left joystick Y Axis). And for rotation, we put axis on the right X Axis on axis 4 (right joystick X Axis). Also make sure they your motor controllers are set up in the correct order when you set it up. Hopefully that helps some.:)

jszipszky 09-01-2015 09:04

Re: Mechanum with XBox Controller
 
Quote:

Originally Posted by Ethan_P (Post 1423605)
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!

We do something very similar to this. I don't want to hijack this thread but how are you limiting the values? Right now in our rough code we have a mess of if-elses determining if the values are over 1. I imagine that there is a better way to do this?

LFRobotics 09-01-2015 09:06

Re: Mechanum with XBox Controller
 
Okay thanks guys! Ill let you know if I can get it to work;)

Jalerre 10-01-2015 22:39

Re: Mechanum with XBox Controller
 
Our team uses mecanum with a Logitech F310 gamepad. The way we map the controls is that we use tank drive with the joysticks to control forwards, backwards, and rotation. For strafing we use the back triggers because they are analog. I believe they translate to twist on the flight sticks. Hope this helps.

Ether 17-01-2015 13:06

Re: Mechanum with XBox Controller
 
Quote:

Originally Posted by jszipszky (Post 1424889)
I don't want to hijack this thread but how are you limiting the values? Right now in our rough code we have a mess of if-elses determining if the values are over 1. I imagine that there is a better way to do this?

You don't need any "elses"

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;}




All times are GMT -5. The time now is 13:03.

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