Go to Post The most amazing and inspiring character I've met in FIRST, Wayne [Cokeley] has definately shown me the character of a true leader. - Bharat Nain [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 18-01-2011, 20:04
Austin3324 Austin3324 is offline
Lead Programmer Team 3324
FRC #3324 (Metrobots)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2008
Location: Columbus, Ohio
Posts: 10
Austin3324 is an unknown quantity at this point
XBox 360 Controller Programming in LabView

Greetings to all from team 3324 of Columbus, Ohio!

In our talking today about the control system we will be using, many (well, to be honest, most) of my fellow teammates thought that it would be a good idea to use an XBox 360 controller to control our robot since they are more familiar with it because of their gaming experience.

I tried to look up how to do it, but it generally came down to the older posts from the 2008/2009 game seasons where you still needed the USB Chicklet to control the robot using some sort of USB controller (like the XBox 360 controller). I managed to find a sample LabView project that appears to have all the code that I need and I was able to construct an alpha version of a control VI for its use. (I only really defined which button is which and all that. I'm still learning how to create my own VI and have it have both inputs and outputs.) If anyone has already gotten this to work (which I know someone has because at least one team at the Buckeye Regionals last year used them), I would be grateful for your help. If you haven't gotten it to work, then I hope that maybe I can help you with this post and my alpha version of my VI.

Thanks in advance!

Austin
Programmer, Team 3324
Attached Files
File Type: vi XBox 360 Controller.vi (10.0 KB, 898 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 18-01-2011, 20:13
360skier 360skier is offline
RTFM!!
AKA: Eric A.
FRC #1334 (Red Devils)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Oakville, Ontario
Posts: 45
360skier is an unknown quantity at this point
Re: XBox 360 Controller Programming in LabView

The XBox controllers should work by default with the driver station for most things. Just pretend they're normal joysticks and figure out which button numbers correspond to the buttons on the controller.

The only problem is that you can't use the DPad, but there are some ways around that too...
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 18-01-2011, 20:22
Brandon_L Brandon_L is offline
Someone told me there was food here
AKA: Brandon Liatys
FRC #2180 (Zero Gravity)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Newark, NJ
Posts: 1,202
Brandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond repute
Re: XBox 360 Controller Programming in LabView

Quote:
Originally Posted by 360skier View Post
The XBox controllers should work by default with the driver station for most things. Just pretend they're normal joysticks and figure out which button numbers correspond to the buttons on the controller.

The only problem is that you can't use the DPad, but there are some ways around that too...
I messed around with this on my home pc a while back, and I remember that the D pad is an axis, just like in other languages/whatever.

I do not remember which one it is, but it outputs the angle (such as 90, 45, 0, 180) if I remember correctly. Just make a bunch of displays and wire each to each of the available axis and see which one it is.
__________________
FRC 2495 - Hamilton West Robotics [2007-2014] - whats a..."hive mind"?
FRC 3929 - Atomic Dragons [2012-2013]
FRC 2180 - Zero Gravity [2017-]

Just trying to collect all the possible team colors
Reply With Quote
  #4   Spotlight this post!  
Unread 18-01-2011, 21:26
Austin3324 Austin3324 is offline
Lead Programmer Team 3324
FRC #3324 (Metrobots)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2008
Location: Columbus, Ohio
Posts: 10
Austin3324 is an unknown quantity at this point
Re: XBox 360 Controller Programming in LabView

Quote:
Originally Posted by Brandon_L View Post
I do not remember which one it is, but it outputs the angle (such as 90, 45, 0, 180) if I remember correctly. Just make a bunch of displays and wire each to each of the available axis and see which one it is.
According to my research, you are correct, but I have no testing in this regard. The top DPad button is 0, and it goes in 45 degree increments from there until it gets back to 360 degrees/0 degrees.

EDIT:

I just talked with a teammate of mine who has an XBox 360 controller. He is going to bring it with him tomorrow so I can get some testing done with it. I'll post the results of my testing tomorrow and, if all goes well, a finalized VI with all the controls required to use one.
Reply With Quote
  #5   Spotlight this post!  
Unread 18-01-2011, 21:58
Brandon_L Brandon_L is offline
Someone told me there was food here
AKA: Brandon Liatys
FRC #2180 (Zero Gravity)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Newark, NJ
Posts: 1,202
Brandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond reputeBrandon_L has a reputation beyond repute
Re: XBox 360 Controller Programming in LabView

0 was forward and it goes by 45 degree increments if I remember correctly. For example 0 would be forward, 45 would be holding forward and right, 90 is right, and so on. I think -1 is when you pressing nothing. Again, this is all from memory.

Let me know what you find out!
__________________
FRC 2495 - Hamilton West Robotics [2007-2014] - whats a..."hive mind"?
FRC 3929 - Atomic Dragons [2012-2013]
FRC 2180 - Zero Gravity [2017-]

Just trying to collect all the possible team colors
Reply With Quote
  #6   Spotlight this post!  
Unread 18-01-2011, 22:23
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: XBox 360 Controller Programming in LabView

So it would be axis 6? I messed around with it in Java last year, and I dont remember getting anything. I'll try again though, since it would be excellent to get working!
Reply With Quote
  #7   Spotlight this post!  
Unread 18-01-2011, 23:33
imac256 imac256 is offline
Registered User
AKA: Ian McInerney
FRC #2022 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2009
Rookie Year: 2009
Location: Aurora, IL
Posts: 30
imac256 is a glorious beacon of lightimac256 is a glorious beacon of lightimac256 is a glorious beacon of lightimac256 is a glorious beacon of lightimac256 is a glorious beacon of light
Re: XBox 360 Controller Programming in LabView

My team experimented with the Xbox 360 controller last year and found the following mappings (C++ code is available here, some documentation, including the following mappings, can be found here):

The buttons on the controller follow this mapping

1: A
2: B
3: X
4: Y
5: Left Bumper
6: Right Bumper
7: Back
8: Start
9: Left Joystick
10: Right Joystick

The axis on the controller follow this mapping
(all output is between -1 and 1)
  • 1: Left Stick X Axis
    -Left:Negative ; Right: Positive
  • 2: Left Stick Y Axis
    -Up: Negative ; Down: Positive
  • 3: Triggers
    -Left: Positive ; Right: Negative
  • 4: Right Stick X Axis
    -Left: Negative ; Right: Positive
  • 5: Right Stick Y Axis
    -Up: Negative ; Down: Positive
  • 6: Directional Pad (Not recommended, buggy)
__________________
- Ian McInerney
Alumni & Mentor, Team 2022 Titan Robotics
Junior, Iowa State University majoring in Electrical Engineering
Reply With Quote
  #8   Spotlight this post!  
Unread 19-01-2011, 15:21
Austin3324 Austin3324 is offline
Lead Programmer Team 3324
FRC #3324 (Metrobots)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2008
Location: Columbus, Ohio
Posts: 10
Austin3324 is an unknown quantity at this point
Re: XBox 360 Controller Programming in LabView

Well, I got everything to work. All buttons, all of the axes (forward, backward, left, and right): Everything.

The only problem that I have is that I have to figure out how to interface the code that I have with the Project code, but that'll be solved in time. As I continue to go, I'll post my VI's here for all to see.

As of now, I hope that I can be of assistance to any team that is using LabView and is also considering using an XBox 360 controller to control their robot.

Thanks for all of your help thus far!

Austin

EDIT:

There was an error in the code that I corrected. I had accidentally set what should have been the X Axis Rotation to the Y Axis Rotation. (NOTE: X Axis Rotation is Left-Right on the right thumbstick and Y Axis Rotation is Up-Down on the right thumbstick.)


Here is the mapping that I have found out as I have listed in the VI:

X Axis: Left Thumbstick Left-Right
X Axis Rotation: Right Thumbstick Left-Right
Y Axis: Left Thumb Stick (Needs to be negated or else up-down controlls are inverted)
Y Axis Rotation: Right Thumb Stick (Needs to be negated or else up-down controlls are inverted)
Z Axis (>0): Left Trigger
Z Axis (<0): Right Trigger

1: A Button
2: B Button
3: X Button
4: Y Button
5: Left Bumper
6: Right Bumper
7: Stop/Back Button
8: Start Button
9: Left Thumbstick Button
10: Right Thumbstick Button

DPAD:
-1: No Thumbpad Button
0: North Thumbpad Button
45: North-East Thumbpad Button
90: East Thumbpad Button
135: South-East Thumbpad Button
180: South Thumbpad Button
225: South-West Thumbpad Button
270: West Thumbpad Button
315: North-West Thumbpad Button
Attached Files
File Type: vi XBox 360 Controller.vi (9.0 KB, 412 views)

Last edited by Austin3324 : 19-01-2011 at 19:45.
Reply With Quote
  #9   Spotlight this post!  
Unread 23-01-2011, 10:36
Austin3324 Austin3324 is offline
Lead Programmer Team 3324
FRC #3324 (Metrobots)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2008
Location: Columbus, Ohio
Posts: 10
Austin3324 is an unknown quantity at this point
Re: XBox 360 Controller Programming in LabView

Ok, well, in my attempts to interface my program with the FRC Project, I discovered one very important thing: This code only works on the host computer, not the cRIO.

I have started to muck around with trying to get LabView to read the controller using the WPI Joystick VIs and got some functionality. I was able to get it to read both thumbsticks in both the X and Y Axis, the triggers, and the X Axis on the thumbpad. The only downside is that, at least in my opinion, since all of those were from the six axes already built into the code, I opted to go in and modify the underlying WPI code to allow for a seventh axis (and, if it works, it will soon become more). I have no idea whether or not this will do anything nor whether I could do some serious damage to the program by modifying the VIs at such a base level.

It claims to be fully compatible and able to compiled, but I haven't been able to actually upload it and test my extra axis. I also don't even know if what I'm doing could help since I don't actually know if the controller communicates over more than six axes.

If anyone could help with these modifications, I would be most grateful, and if you just want to know how to actually get LabView to read the XBox 360 controller, then I am glad that I could help you.

Austin

Included as attachments are the version of the Teleop VI that I am using to test the controller, the WPI_JoystickGet VI that I have modified to get a seventh axis, and the WPI_JoystickCache VI that actually is where I created my seventh axis in.
Attached Files
File Type: vi Teleop.vi (16.9 KB, 514 views)
File Type: vi WPI_JoystickCache.vi (12.0 KB, 188 views)
File Type: vi WPI_JoystickGet.vi (16.6 KB, 221 views)
Reply With Quote
  #10   Spotlight this post!  
Unread 27-01-2011, 19:36
Simmers1912 Simmers1912 is offline
Registered User
FRC #1912
 
Join Date: Jan 2011
Location: Slidell
Posts: 1
Simmers1912 is an unknown quantity at this point
Re: XBox 360 Controller Programming in LabView

Hey, our team is also trying to controll our robot with an Xbox controller and we have been following your thread. We however wanted to know if you had found a way to incorporate the rumble pack in the Xbox 360 controller into the labview code. Thank you for your time.
Reply With Quote
  #11   Spotlight this post!  
Unread 18-01-2011, 20:17
davidalln's Avatar
davidalln davidalln is offline
World's Worst Coder
AKA: David Allen
FRC #2415 (The Westminster Wiredcats)
Team Role: Programmer
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Atlanta, GA
Posts: 108
davidalln is on a distinguished road
Send a message via AIM to davidalln
Re: XBox 360 Controller Programming in LabView

I *think* that the 360 controller maps the same way the Logitech joysticks do. Try using FIRST's Joystick VI and see if it magically works.

(Disclaimer: I'm going off secondhand information and C++ code. Results may vary)
__________________
SANTOSH ANDREW DECKER RICK WYNNIE SEAN DEREK MATT
(alamo (semis), p'tree (CHAMPS!), nc (CHAMPS!), newton (quarters))


Best four years of my life. Thanks to everyone who made it happen.
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 12:34.

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