How to use SpaceExplorer as Flight Controls to fly aircraft

Post questions, comments and feedback to our 3Dconnexion UNIX and Linux Development Team.

Moderator: Moderators

Post Reply
aero_engineer
Posts: 5
Joined: Thu Feb 05, 2009 1:36 pm
Location: NY

How to use SpaceExplorer as Flight Controls to fly aircraft

Post by aero_engineer »

Hi,

I would like some help in using the USB SpaceExplorer to fly my aircraft simulator running on RedHawk (RedHat) Linux.

Ideally, I could find some example source code (C++) that has function calls that return the values of the 6dof SpaceExplorer cap, as well as the state of all the buttons. I would call these functions from my real time simulation that runs at 60Hz.

I have no interest in anything graphical (no cubes to draw or anything), just the values (like -1.0 to 1.0 for the cap, and TRUE/FALSE for the buttons)

I've already installed the SpaceExplorer on my system and it all seems happy since "xcube" and "xvalues" seem to behave as expected.

Since it's USB, do I need to do any initializing or closing when the simulation starts/stops?


Some system specs:

"uname -a"
Linux 2.6.23.17-RedHawk-5.1.2-trace #1 SMP PREEMPT Tue Sep 16 12:33:37 EDT 2008 i686 i686

i386 GNU/Linux


"g++ -v"
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)

"/etc/3DxWare/daemon/3dxsrv -v"
3DxWareUNIX = V1.2.17, ID 3493
pyalot
Posts: 13
Joined: Thu Jan 22, 2009 5:05 am

Post by pyalot »

You could follow the evdev examples, it works (somewhat).

If udev doesn't mount it as readable for users, add such a rule:

Code: Select all

KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="3Dconnexion SpaceNavigator", MODE="0666"
To a /etc/udev/rules.d/99-joysticks.rules

Also take care you've disabled xorg hotplug or exempted your device, because there are issues with hotplug.
aero_engineer
Posts: 5
Joined: Thu Feb 05, 2009 1:36 pm
Location: NY

Post by aero_engineer »

Thank you, pyalot, for your quick reply. Unfortunately, all your info will take a while for me to digest. I was hoping for something easier to understand (for a rookie).

Is there any way I can get the source code for the application "xvalues"? Seems that that's exactly what I want (minus the display part of it, but adding the button state part of it.

I wonder though, if using "evdev" violates the recommendation to use 3dconnexion's driver and SDK (as stated in viewtopic.php?t=1792&sid=df40b88217559e ... 7c88c98137
I would prefer to keep things standard so that it's easier to integrate new 3dconnexion products in the future without having to modify my code.
pyalot
Posts: 13
Joined: Thu Jan 22, 2009 5:05 am

Post by pyalot »

The evdev stuff is rather simple, plus if you do it with evdev you get support for any Human Interface Device, not just space pilots etc. (Joysticks, gamepads and whatnot too).

Sure the "official" recommendation would be to use the "official" SDK and the "official" usbfs driver adapter (that opens an annoying non working window).

I think the space pilot is nothing else then a six axis two button joystick, and that works pretty well for me over evdev.

To require users to use some proprietary custom software blobs and methods just to get a HID working that should be plug&play is just plain silly.
UtaSH
Moderator
Moderator
Posts: 3754
Joined: Mon Nov 27, 2006 10:34 am
Location: Munich, Germany
Contact:

Post by UtaSH »

Hi aero_engineer,
aero_engineer wrote:Is there any way I can get the source code for the application "xvalues"? Seems that that's exactly what I want (minus the display part of it, but adding the button state part of it.
The example xapp.c in the SDK is exactly the xvalue demo. :wink:
aero_engineer wrote:I wonder though, if using "evdev" violates the recommendation to use 3dconnexion's driver and SDK (as stated in viewtopic.php?t=1792&sid=df40b88217559e ... 7c88c98137
I would prefer to keep things standard so that it's easier to integrate new 3dconnexion products in the future without having to modify my code.

You are right: if you use the SDK you will be prepared for all future 3Dconnexion devices that are supported on your Linux. No need to adapt any source, any scripts, ... :)

Uta Ludwig
3Dconnexion
pyalot
Posts: 13
Joined: Thu Jan 22, 2009 5:05 am

Post by pyalot »

@uludwig

there seems to be some 3dconnexion terminal reality disconnect.

1) you recommend using the "official" broken way of doing things in the linux developer forum
2) you get thread upon thread in the linux user forum about how utterly hard it is to configure and use the device with any application

I mean, you know...

Whatever happend to USB HID plug&play (which btw. DOES work on linux vor a whole variety of devices)
aero_engineer
Posts: 5
Joined: Thu Feb 05, 2009 1:36 pm
Location: NY

Post by aero_engineer »

Just wanted to provide an update: I've decided to go with a nice prepackaged solution provided by nuclear, it's been working great:
- no annoying X11 window to deal with
- simple inteface, once you learn how to use it properly (study the API as defined in the .h file)
- unplug the USB plug, then plug it back in again and it all starts working again automatically

see
viewtopic.php?t=1310&highlight=
and
http://spacenav.sourceforge.net/

The 3Dconnexion SDK was just too difficult, I gave up on it.
aero_engineer
Posts: 5
Joined: Thu Feb 05, 2009 1:36 pm
Location: NY

Post by aero_engineer »

Another little tidbit of info to add:

My application wasn't terminating cleanly (I always had to do a CTRL-C to get my terminal back), then I realized that I needed to put in a sleep(0.1) right after my call to spnav_close in my termination logic. Not sure how/why this works, but it did.
Post Reply