Go to Post 217 would never collaborate with 1114 because they are crazy and they talk funny. - Paul Copioli [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 15-04-2014, 15:19
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
How To: Xbox Controller Vibration

I have noticed a lot of question regarding how to access the vibration controls of an Xbox controller connected to the driver station.

So I started investigating and found LabVIEW can use DLLs, and remembered that Xbox controllers use the xinput DLL to control this feature of the controllers.

This is the function definition of XInputSetState in the Xinput DLL found on most, if not all Windows computers. I am using the Xinput9_1_0.dll found in C:\Windows\System32. If you do not have this DLL, install the latest directx available.
http://msdn.microsoft.com/en-us/libr...=v s.85).aspx

dwUserIndex is the controller index of the controller you want to use, you can identify the number by seeing which "player" light is lit on the controller.

pVibration is a struct in C++ but a cluster in the LabVIEW code attached. The vibration value is from 0 to 65536, higher means more vibration.

The attached code is a LabVIEW library that you place in the user.lib directory of your LabVIEW install. For example mine is
Code:
C:\Program Files (x86)\National Instruments\LabVIEW 2013\user.lib
Unzip the folder Xinput9_1_0 to that directory and open up LabVIEW with either a new VI or your current Dashboard Project. The example pictures below is a new, default Dashboard Project.


  1. Start by dragging the XinputSetState VI to you block diagram.
  2. Right click on the pVibration terminal, go to create, then click constant
  3. delete the wire branch connecting the constant to XInputSetState
  4. create a bundle by name and place it on the diagram
  5. connect the cluster constant to the bundle by name
  6. create controls, constants, or what ever to the input terminals of wLeftMotorSpeed or wRightMotorSpeed
    Left Motor is the 'rough' vibration while the Right Motor is the 'smooth' vbration
  7. Run the project and give it a value between 0 and 65536
  8. Your controller is Vibrating!

Here is a small video demonstrating the library (Note the controller in the video is wireless, this library will work just the same with wired controllers): https://www.dropbox.com/s/swrerlsmom...415_141309.mp4

Remember to set the vibration value to 0 before exiting, or your controller will vibrate until you do set it!

The controller will be pulling power from your driver station's USB hub. Be sure it does not go over the limit for your hub or your may lose connectivity to other devices connected to the same hub.

This method of interfacing with the XInput DLL should transfer to the SmartDashboard as well. If anyone accomplishes this, send me a private message with instructions and I will update the thread.
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer

Last edited by MDAWG25 : 15-04-2014 at 16:23.
  #2   Spotlight this post!  
Unread 15-04-2014, 15:50
JamesTerm's Avatar
JamesTerm JamesTerm is offline
Terminator
AKA: James Killian
FRC #3481 (Bronc Botz)
Team Role: Engineer
 
Join Date: May 2011
Rookie Year: 2010
Location: San Antonio, Texas
Posts: 298
JamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to behold
Re: How To: Xbox Controller Vibration

This is pretty cool. I believe, and Greg please jump in if I am wrong... only labview teams can use this kind of solution. If c++ and java teams could use xinput there is not anything that I have seen to do so in short of having to write our own application (e.g. make a wedge proxy to the dashboard with its own networking solution). IIRC I believe direct input had some preliminary functionality for that for rumble, but I have never tested using that so it is hard to say... The driver station uses direct input, but the c++ and java interface is limited to certain controls because all the controls and submitted in a packet and it is packed tight, so I am somewhat surprised that labview is not subjected to the same functionality.
  #3   Spotlight this post!  
Unread 15-04-2014, 16:01
Johnbot's Avatar
Johnbot Johnbot is offline
Es Brokein!
AKA: John Westhoff
FRC #4791 (Pandroids)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Horsham, PA
Posts: 92
Johnbot is just really niceJohnbot is just really niceJohnbot is just really niceJohnbot is just really niceJohnbot is just really nice
Re: How To: Xbox Controller Vibration

That's actually pretty neat - I didn't know LabVIEW was that extendable.

Last year, team 2607 used a separate Java application running on the driver-station to add rumble functionality to our Xbox controllers.
We just read the button states from the application to trigger the hard and soft rumbles, but you could easily integrate it into your dashboard to communicate with the robot (which would also allow for other nifty things, like reading the triggers separately, etc.)
__________________

2011-2014 - FRC 2607 - Student
2012-2012 - FLL 2249 - Coach
2015- ???? - FRC 4791 - Mentor
  #4   Spotlight this post!  
Unread 15-04-2014, 16:05
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by JamesTerm View Post
This is pretty cool. I believe, and Greg please jump in if I am wrong... only labview teams can use this kind of solution. If c++ and java teams could use xinput there is not anything that I have seen to do so in short of having to write our own application (e.g. make a wedge proxy to the dashboard with its own networking solution). IIRC I believe direct input had some preliminary functionality for that for rumble, but I have never tested using that so it is hard to say... The driver station uses direct input, but the c++ and java interface is limited to certain controls because all the controls and submitted in a packet and it is packed tight, so I am somewhat surprised that labview is not subjected to the same functionality.
The XInput DLL is loaded from the dashboard separately. The Smartdashboard should be able to load the xinput.dll just like the labview dashboard is.
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer
  #5   Spotlight this post!  
Unread 15-04-2014, 16:18
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by Johnbot View Post
That's actually pretty neat - I didn't know LabVIEW was that extendable.

Last year, team 2607 used a separate Java application running on the driver-station to add rumble functionality to our Xbox controllers.
We just read the button states from the application to trigger the hard and soft rumbles, but you could easily integrate it into your dashboard to communicate with the robot (which would also allow for other nifty things, like reading the triggers separately, etc.)
If I were to further extend the access to the DLL, I could in theory read every button on the controller and the triggers individually more like how PC games do.
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer
  #6   Spotlight this post!  
Unread 15-04-2014, 16:25
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by JamesTerm View Post
This is pretty cool. I believe, and Greg please jump in if I am wrong... only labview teams can use this kind of solution.
The method Matt is talking about has nothing to do with how the robot is programmed. The code runs on the computer which has the controller plugged into it. The xinput DLL ought to be usable from any language.
  #7   Spotlight this post!  
Unread 15-04-2014, 17:42
JamesTerm's Avatar
JamesTerm JamesTerm is offline
Terminator
AKA: James Killian
FRC #3481 (Bronc Botz)
Team Role: Engineer
 
Join Date: May 2011
Rookie Year: 2010
Location: San Antonio, Texas
Posts: 298
JamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to behold
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by Alan Anderson View Post
The method Matt is talking about has nothing to do with how the robot is programmed. The code runs on the computer which has the controller plugged into it. The xinput DLL ought to be usable from any language.
Yeah.. that makes sense... the method doesn't but... the final problem to solve should be, and that was what I was trying to address. It sounds like labview would have to send a signal from robot to the customized NI Dashboard, and that would take the message and pass it to xinput to implement the rumble set interface.
  #8   Spotlight this post!  
Unread 15-04-2014, 17:49
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by JamesTerm View Post
Yeah.. that makes sense... the method doesn't but... the final problem to solve should be, and that was what I was trying to address. It sounds like labview would have to send a signal from robot to the customized NI Dashboard, and that would take the message and pass it to xinput to implement the rumble set interface.
Yes, that is how it would have to happen. You can compare the flow to the PSOC board interface. To output a signal on the PSOC I/O board, the robot must generate the signal, pass it to the driver station, which then tells the PSOC board to set pin X high/low etc.
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer
  #9   Spotlight this post!  
Unread 15-04-2014, 20:02
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by JamesTerm View Post
It sounds like labview would have to send a signal from robot to the customized NI Dashboard, and that would take the message and pass it to xinput to implement the rumble set interface.
LabVIEW is not required, and you don't need to use the default Dashboard as a starting point. The robot can be running a program written in any language, and so can the computer hosting the rumble-capable controller.

Minimal UDP communication from cRIO to computer is simple, but if you don't want to roll your own, there are well-supported implementations of Network Tables (and thus Smart Dashboard variables) for LabVIEW, C++ and Java.
  #10   Spotlight this post!  
Unread 16-04-2014, 02:05
JamesTerm's Avatar
JamesTerm JamesTerm is offline
Terminator
AKA: James Killian
FRC #3481 (Bronc Botz)
Team Role: Engineer
 
Join Date: May 2011
Rookie Year: 2010
Location: San Antonio, Texas
Posts: 298
JamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to beholdJamesTerm is a splendid one to behold
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by Alan Anderson View Post
LabVIEW is not required, and you don't need to use the default Dashboard as a starting point. The robot can be running a program written in any language, and so can the computer hosting the rumble-capable controller.

Minimal UDP communication from cRIO to computer is simple, but if you don't want to roll your own, there are well-supported implementations of Network Tables (and thus Smart Dashboard variables) for LabVIEW, C++ and Java.
Thanks for wording this clearer than what I was trying to do in my initial post... the confusion for me was... where the labview code was being applied.. I thought it was part of the robot code, but now I know it is a part of the custom dashboard.

When I was talking about doing this "(e.g. make a wedge proxy to the dashboard with its own networking solution). " I was hinting toward this solution. This wedges a proxy by being the main app that uses ShellExecute() to launch the SmartDashboar.jar. This way I can make my own code while still having full use of the Java client. In this project the compositor plugin has its own direct input implementation that runs parallel to the driver station's use of direct input. So yeah I could, and most likely will flip over to xinput. I'll want to use the same platform as the driver station for the sake of integrity... I know one day they'll switch and it may be next year.
On that note... they may indeed have full HID support and if so then all of this method will no longer be needed to gain full access of joystick support, but I'd still need it for the compositor. There is no confirmation on that, but I know it is a possibility as I've requested for it to do things like acquiring the joystick's name on any slot, and POV axis support etc... during beta.

Thanks for saying "well-supported" as the description of Network Tables.

Last edited by JamesTerm : 16-04-2014 at 06:17.
  #11   Spotlight this post!  
Unread 16-04-2014, 02:16
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by Alan Anderson View Post
LabVIEW is not required, and you don't need to use the default Dashboard as a starting point. The robot can be running a program written in any language, and so can the computer hosting the rumble-capable controller.

Minimal UDP communication from cRIO to computer is simple, but if you don't want to roll your own, there are well-supported implementations of Network Tables (and thus Smart Dashboard variables) for LabVIEW, C++ and Java.
I appreciate you explaining this better than myself.
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer
  #12   Spotlight this post!  
Unread 20-04-2014, 00:51
rpatel3001's Avatar
rpatel3001 rpatel3001 is offline
former programming/electrical chair
AKA: Rajan
FRC #1089 (Team Mercury)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2012
Location: East Windsor
Posts: 9
rpatel3001 is just really nicerpatel3001 is just really nicerpatel3001 is just really nicerpatel3001 is just really nicerpatel3001 is just really nice
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by Johnbot View Post
Last year, team 2607 used a separate Java application running on the driver-station to add rumble functionality to our Xbox controllers.
We just read the button states from the application to trigger the hard and soft rumbles
Johnbot, would you be willing to post that code? I wouldn't want to reinvent the wheel for no reason.
  #13   Spotlight this post!  
Unread 23-04-2014, 11:20
MDAWG25's Avatar
MDAWG25 MDAWG25 is offline
FRC Capability Developer LabVIEW
AKA: Matt
FRC #2614 (MARS)
Team Role: Engineer
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Morgantown, WV
Posts: 47
MDAWG25 is on a distinguished road
Re: How To: Xbox Controller Vibration

My fault, thank you Invictus3593, the library did not upload with the original post. The library *should be attached to this post.
Attached Files
File Type: zip XInput9_1_0.zip (36.4 KB, 70 views)
__________________
Mountaineer Area RoboticS (MARS) Team 2614



2015-???
2014-Driver
2013-Driver
2012-Driver
2011-Programmer
  #14   Spotlight this post!  
Unread 23-04-2014, 17:45
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: How To: Xbox Controller Vibration

Quote:
Originally Posted by MDAWG25 View Post
My fault, thank you Invictus3593, the library did not upload with the original post. The library *should be attached to this post.
Thanks!
__________________
Per Audacia Ad Astra
  #15   Spotlight this post!  
Unread 26-04-2014, 08:09
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 158
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: How To: Xbox Controller Vibration

Can I use the XInput DLLs to send controller data to the robot?
Will it be as responsive as the joystick library of WPIlib?
Closed Thread


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 06:45.

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