Space Navigator + LabVIEW pseudodriver (OS X 10.7)

Questions and answers about 3Dconnexion devices on macOS.

Moderator: Moderators

Post Reply
iklln6
Posts: 4
Joined: Thu Aug 04, 2011 8:43 am
Location: USA

Space Navigator + LabVIEW pseudodriver (OS X 10.7)

Post by iklln6 »

[Motivation]
So I wanted to use the Space Navigator to control a 3-rotor UAV with an interface made in LabVIEW. Unfortunately, LabVIEW's VISA wizard sucks, and doubly so on OS X. So I loaded up the example program in XCode, tinkered with it to get it to compile (its settings are still configured for the old 10.4 SDK), and changed the code to operate globally.

[Theory of Operation]
The program takes readings and writes them to a .csv file (no append) so the 7 values in the .csv file are always the latest readings. LabVIEW simply runs a loop reading the values from that file. This simple method can be extended to build an interface with any programming language and on any version of OS X...

[Files]
I have bundled up my LabVIEW VI (program), the updated xcode project, screenshots of the VI (in case it doesn't load on your version of LabVIEW), and screenshots of my 3DConnexion preference panel pane tabs -- configurations will have to be set to default (as pictured) and with the sensitivity all way up for good starting results.

[Basic Use]
[+--Building the 3DX Application]
Unzip the .zip file and go to the 3DX_LabVIEW_Client folder and unzip 3DxValuesCocoa.zip. You'll also see 3DxClientTest.app but it probably won't work right unless you happen to have a /Users/Nash/Desktop/ directory... Load the xcode project. Go to 3DxClientTest.m and change the definition for "myFile" to a good location. Build the app and copy it to wherever for easy access.
[+--Setting up LabVIEW]
Open LabVIEW and throw together a quick VI (or load mine). Have your program load the file that you defined in myFile during the 3DX Application building step. You want LabVIEW to poll that file each iteration while it's running, and parse the 7 data integers from it
[+--Making them interact]
Execute the 3DX Application and minimize it or put it to the side. Running in the background it will continue to collect data to write to the myFile. myFile should NOT grow -- it will only contain the latest readings. Navigate over to LabVIEW and run the VI. It should successfully read the .csv file and parse data appropriately.

[Key changes in the Xcode Project]
As stated above, you'll have to add some lines to the .m file. You will also have to modify the registered ConnexionClient. In my .m file you'll also see I have created a struct to hold the readings for code-readability. At the end of the TestMessageHandler is the fprintf function which writes to the file. The file is opened each iteration with "w", so new data is NOT appended.

[Final-Product Implementation/Improvements]
I am not very familiar with Xcode, otherwise I would have bundled some of this together myself... If you want to package this little thing up then it'll make life easier to make a .cfg file that holds the path to the middle-man ("myFile") file. Or, just have the app create a tmp file at its directory and execute the VI from that same directory...
Assuming the location of the middle-man file is sorted out, a simple LabVIEW driver could be made by bundling the 3DX Application along with the driver VI's. Use LabVIEW's "System Exec" subVI to execute the 3DX Application, minimized or hidden, and use it again to kill the app's process afterward.

[Use as a serial-line controller for robotic applications]
If you don't like LabVIEW, you could just write a python program to read the values and write appropriate commands over the serial line using pySerial. This could be extended to stream over a bluetooth serial modem, IR serial modem, or whatever. Could even pipe it to an http client.

The zip file is in the me.com link, and will be there indefinitely. download, distribute, and improve.

[img]http://i1102.photobucket.com/albums/g44 ... tpanel.png
[/img]

https://files.me.com/iklln6/3tq3uq[/url]
iklln6
Posts: 4
Joined: Thu Aug 04, 2011 8:43 am
Location: USA

picture

Post by iklln6 »

sure would have been neat if the image posted. i'll try again

Image
jwick
Moderator
Moderator
Posts: 3340
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

Very inventive!!
iklln6
Posts: 4
Joined: Thu Aug 04, 2011 8:43 am
Location: USA

Post by iklln6 »

thank you :) the S/s rate is plenty fast enough for real-time operation of a tri-rotor UAV, and let me just say that control of a UAV with the 3dconnexion space navigator is by far the best human interface device i've ever used with an RC vehicle. It definitely blows the old sticks out of the water.
sm_demon
Posts: 7
Joined: Tue Jan 20, 2015 12:52 pm

Re: Space Navigator + LabVIEW pseudodriver (OS X 10.7)

Post by sm_demon »

Hi,

Can someone help me with getting the zip file, the link seems to re-direct to my own account not to the original users...

I am implementing something similar and this kind of leads me in the right direction.

Thanks
Post Reply