Go to Post 118 embodies everything this entire program is supposed to be about: INSPIRATION. Respect that. Acknowledge that. Support that. - barn34 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-01-2015, 17:39
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 06-01-2015, 18:31
cyborgstx's Avatar
cyborgstx cyborgstx is offline
Registered User
AKA: Lydia
FRC #3335 (Cy-Ranch Cy-Borgs)
Team Role: Coach
 
Join Date: Nov 2013
Rookie Year: 2011
Location: Houston, TX
Posts: 3
cyborgstx is an unknown quantity at this point
Re: Mechanum with XBox Controller

What template are you using? I could give you Iterative sample code.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-01-2015, 23:07
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 357
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
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);
__________________
Brian K
Team 1225 Robotics Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 07-01-2015, 08:33
afiolmahon afiolmahon is offline
Registered User
FRC #1218
 
Join Date: Dec 2014
Location: Philadelphia
Posts: 7
afiolmahon is an unknown quantity at this point
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 07-01-2015, 09:47
daniel12997's Avatar
daniel12997 daniel12997 is offline
Student
AKA: Daniel Parker
FRC #1736 (Robot Casserole)
Team Role: Student
 
Join Date: Nov 2014
Rookie Year: 2014
Location: United States
Posts: 14
daniel12997 is an unknown quantity at this point
Re: Mechanum with XBox Controller

Could you use one of the joysticks for forward backward and strafing and the other joystick for rotation.
Reply With Quote
  #6   Spotlight this post!  
Unread 07-01-2015, 11:07
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-01-2015, 11:22
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
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!
Reply With Quote
  #8   Spotlight this post!  
Unread 07-01-2015, 12:18
Ethan_P Ethan_P is offline
Registered User
FRC #1895 (Lambda Corps)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Virginia
Posts: 3
Ethan_P is an unknown quantity at this point
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!
Reply With Quote
  #9   Spotlight this post!  
Unread 07-01-2015, 14:20
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mechanum with XBox Controller

Quote:
Originally Posted by Ethan_P View Post
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.


Reply With Quote
  #10   Spotlight this post!  
Unread 07-01-2015, 15:30
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: Mechanum with XBox Controller

And how exactly do I do that?
Reply With Quote
  #11   Spotlight this post!  
Unread 07-01-2015, 16:10
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mechanum with XBox Controller

Quote:
Originally Posted by LFRobotics View Post
And how exactly do I do that?
Search for the word "normalize" in these docs:

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


Reply With Quote
  #12   Spotlight this post!  
Unread 09-01-2015, 09:04
jszipszky jszipszky is offline
Registered User
FRC #1168 (FriarBot)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2014
Location: United States
Posts: 5
jszipszky is an unknown quantity at this point
Re: Mechanum with XBox Controller

Quote:
Originally Posted by Ethan_P View Post
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?

Last edited by jszipszky : 09-01-2015 at 19:10.
Reply With Quote
  #13   Spotlight this post!  
Unread 17-01-2015, 13:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Mechanum with XBox Controller

Quote:
Originally Posted by jszipszky View Post
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;}

Reply With Quote
  #14   Spotlight this post!  
Unread 07-01-2015, 11:54
lynca's Avatar
lynca lynca is offline
Andrew Lynch
FRC #2587 (DiscoBots)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Houston, TX
Posts: 1,611
lynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond repute
Send a message via AIM to lynca
Re: Mechanum with XBox Controller

Quote:
Originally Posted by LFRobotics View Post
But we now want to use mechanum wheels..
What size mechanum wheels and what gearbox ratio ?
__________________
History: 624 - Cryptonite --> 118 - Robonauts --> 2158 - AusTIN CANS --> 2587 DiscoBots
Bio: Andrew Lynch "How I Work" ---- LinkedIn , Facebook, Twitter
Reply With Quote
  #15   Spotlight this post!  
Unread 07-01-2015, 13:06
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
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
Reply With Quote
Reply


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


All times are GMT -5. The time now is 11:14.

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