LIGHTHOUSE

Section: FreeVR Usage (7fv)
Updated: 5 December 2013
Index Return to Main Contents

 

NAME

Lighthouse — A How-to document for interfacing Vive Lighthouse tracking with FreeVR  

DESCRIPTION

The Vive Lighthouse ...

NOTE: Presently all the methods presented are for use with the Linux operating system. As methods are ascertained

 

HOWTO

Each of the following subsections provide instructions on how each of the interfaces listed above can be used to accomplish Wiimote interaction with FreeVR.

 

Vive Tracking

The Vrui toolsuite includes the RunViveTracker.sh shell script.

For CAVE-style VR, we don't have an HMD, so the Vrui interface to Lighthouse tracking was altered to allow a non-HMD version.

    % /home/wrs1/local/bin/RunViveTrackerNoHMD.sh
    VRDeviceDaemon: Reading configuration file
    VRDeviceDaemon: Initializing device manager
    VRDeviceManager: Loading device Vive of type OpenVRHost
    VRDeviceManager: Managing 4 trackers, 14 buttons, 6 valuators
    VRDeviceManager: Managing 4 virtual devices
    VRDeviceManager: Initializing 1 device driver modules
    VRDeviceDaemon: Initializing device server
    VRDeviceServer: Listening for incoming connections on TCP port 8555

After this, there will be various updates on the status of the tracker devices, including the battery levels.

NOTE: there will be many lines that report:

    ioctl (SFEATURE): Broken pipe
these can be safely ignored.

Configuration File

The Vrui system reports values in the unit of meters. So to convert those values to feet, multiply (scale) by 3.28.

For example:

    # Button mappings:

For configuration on the FreeVR side, there is a difference as to

    control "print_struct" = "2switch(key[Home])";
    input "2switch[1]" = "2switch(key[Prog1])";

Thus, both of the following will work:

    input "2switch[2]" = "2switch(button[A])";
    input "2switch[3]" = "2switch(key[Btn:B])";

And for valuators:

    input "wii-roll" = "valuator(abs[X])";
    input "wii-elev" = "valuator(abs[Y])"; 

Troubleshooting
There are a handful of common problems which can be easily resolved with the following instructions.
1)
You get the error — "ImportError: No module named cwiid".
If you see this error, this means that the "CWiid package was compiled with the Python option. Using the Python option is fine, it just requires that the PYTHONPATH environment variable be set accordingly to point to the location of the "cwiid.so" shared object:
    # export PYTHONPATH=<...>/python/build/lib.linux-x86_64-2.6
2)
Your Wiimote events are generating inputs to the X11 input system. Depending on your Linux configuration, initiating new input devices will sometimes link them to the X11 input system. The "xinput" command can be used to verify and fix this problem.

First, find it's input id:

    % xinput list --short | grep Wiimote
         Nintendo Wiimote            id=10   [slave  keyboard (3)]

The next step is determine the property number for the "Device Enabled property of the input device with the id above (e.g. "10" in this example):

    % xinput list-props 10 | grep "Device Enabled"
            Device Enabled (117):   1

With the id ("10") and enable/disable property code ("117"), the device's effect on the X11 input system can now be turned off. The command to change a property also takes arguments for the number of bits of the datum as well as the value. As the enable/disable flag only requires one byte (which is in effect the minimum), the command is (along with verification):

    % xinput set-int-prop 10 117 8 0
    % xinput list-props 10 | grep "Device Enabled"
        Device Enabled (117):   0
 

VRPN

The VRPN (Virtual Reality Peripheral Network) is an input device (really an I/O device) server system that can interface with a wide variety of devices, old and new. The Nintendo Wiimote is one of the many devices handled. And as FreeVR can interface directly with VRPN, all that is needed is to install VRPN and configure the "WiiMote" interface.

VRPN is not generally included with Linux distributions, but it is easy to download and compile.

Enabling the basic "WiiMote" input is straightforward:

    % cat wiimote_vrpn.cfg
    vrpn_WiiMote           WiiMote0 1 0 0 1
    % vrpn_server -f wiimote_vrpn.cfg

There is also a tracking form of VRPN interface with the WiiMote which involves the use of the IR sensor information along with some post-processing (all handled within VRPN):

    % cat wiimote_vrpn.cfg
    vrpn_WiiMote              WiiMote0 1 1 1 1
    vrpn_Tracker_WiimoteHead  Tracker0 WiiMote0@localhost
    % vrpn_server -f wiimote_vrpn.cfg
NOTE: that the middle two flags ("useMotionSensing" and "useIR") must be enabled to create tracking output.

Here are the VRPN configuration arguments for the two input types:

    for vrpn_WiiMote:
        1) name_of_this_device (string)
        2) Player number (int)
        3) Use motion Sensing (bool/int) — from the base Wiimote, not motion sensor   
        4) Use IR tracking (bool/int)
        5) Reorder the buttons (bool/int)
        6) [optional] Bluetooth address — provided in all uppercase with colons

    for vrpn_Tracker_WiimoteHead
        1) name_of_this_device (string)
        2) name_of_vrpn_WiiMote_device (string)
        3) [optional] min_update_rate (default=60) (float) [Hz]
        4) [optional] led_distance (default=0.205) (float) [meters]

On the FreeVR side, these can be mapped into inputs with configuration settings similar to:
    input "2switch[A]" = "2switch(WiiMote0:button[1])";
    input "2switch[B]" = "2switch(WiiMote0:button[2])";
    input "2switch[3]" = "2switch(WiiMote0:button[3])";

    input "val[x]" = "Valuator(WiiMote0:analog[ 1])";   # roll/twist
    input "val[y]" = "Valuator(WiiMote0:analog[-2])";   # pitch/elevation
    input "val[u]" = "Valuator(WiiMote0:analog[ 3])";   # right-side-upidness
    input "val[b]" = "Valuator(WiiMote0:analog[ 0])";   # battery level

    input "wand2" = "6sensor(Tracker0:tracker[0])";

NOTE: Analog values 1 and 3 are specifically the ...  

Vrui's VRDeviceDaemon

The Vrui "VRDeviceDaemon" server can handle a variety of input devices, much like VRPN. And the Nintendo Wii™ remote is one input device it can handle.

In fact it is fairly straightforward. The only real requirement is that the Vrui system be compiled with the Bluetooth feature enabled.

Once Vrui is compiled, a "VRDevices.cfg" configuration file for the VRDeviceDaemon program must be created. To collect button and valuator inputs only (valuators with an attached Nunchuk of course), use this configuration (replacing the hostname with the correct value):

section "<hostname>"
    section DeviceManager
    deviceNames (Wiimote1)
    section Wiimote1
    deviceType WiimoteTracker

    # Set this to the Bluetooth ID of the Wiimote
    devicename "00:24:1E:7A:CC:2D"

    # Set the LED pattern for this Wiimote (any 4-bit value)
    ledMask 1

    # Disable motion tracking using the Wiimote's camera
    enableTracker false
    endsection
    endsection
endsection

and then run the Vrui VRDeviceDaemon:

    % bin/VRDeviceDaemon
    VRDeviceDaemon: Reading configuration file
    VRDeviceDaemon: Initializing device manager
    VRDeviceManager: Loading device Wiimote1 of type WiimoteTracker
    WiimoteTracker: Connecting to first compatible Bluetooth device.
    WiimoteTracker: Please press buttons 1 and 2 to initiate connection... done
    WiimoteTracker: Connected wiimote's battery level is 145%
    VRDeviceManager: Managing 0 trackers, 13 buttons, 2 valuators
    VRDeviceManager: Managing 0 virtual devices
    VRDeviceDaemon: Initializing device server
    VRDeviceServer: Waiting for client connection

In another shell, the inputs can be tested with the FreeVR "vruiddtest" program:

    % ./vruiddtest

For position tracking, there are a handful of additional options that must be specified. However, position tracking with the Vrui system only works with physical LED configurations that have four LED markers rather than the customary two. So this system does not work with the standard Wii sensor bar.

The additional configuration options are:

    cameraCenter (512, 384)
    cameraFocalLength 1280

    targetPoints ((-2.0, 0.0, 0.0), (0.0, -1.0, 2.0), (2.0, 0.0, 0.0), (0.0, -1.0, -2.0))
    targetTransformation identity

    homeTransform identity
 

BUGS

For the wminput method, in some configurations the
"event<N>" device is not readable without superuser permissions, requiring a permission change.
Especially for the VRPN mothod, when using the Wiimote
as a 6-dof position tracker, the scale factor will need to be adjusted, and FreeVR does not yet provide this option in the VRPN interface.
 

TODO

Consider intregrating a Wiimote interface directly into FreeVR.
Note that this would then require all FreeVR applications to be linked with the Bluetooth library.
Consider writing enhancements to the "wminput" program. Most
importantly, to handle joystick valuator values of the Nunchuk, but also other small by handy improvements.
 

SEE ALSO

xinput(1), wminput(1), eviotest(1fv)

The sample FreeVR configuration file for VRPN:

$FREEVR_HOME/etc/rc_sample_vrpn

Web sites:

http://www.freevr.org
https://en.wikipedia.org/wiki/Wii_Remote
https://wiki.archlinux.org/index.php/Wiimote

Video:

"Head Tracking for Desktop VR Displays using the WiiRemote" by Johnny Lee:
    https://www.youtube.com/watch?v=Jd3-eiid-Uw

 

COPYRIGHT

Copyright 2022, Bill Sherman, All rights reserved.


 

Index

NAME
DESCRIPTION
HOWTO
Vive Tracking
VRPN
Vrui's VRDeviceDaemon
BUGS
TODO
SEE ALSO
COPYRIGHT

This document was created by man2html, using the manual pages.
Time: 06:06:20 GMT, March 05, 2024