Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.

How to Use a SpaceNavigator with the spacenav_node

Description: This tutorial is an introduction to using the 3DConnexion SpaceNavigator connected to a desktop. After reading this, you should be able to bring up the spacenav_node and display the data.

Keywords: spacenavigator, 3DConnexion, joystick, driver

Tutorial Level: BEGINNER

Next Tutorial: Writing a Teleoperation Node for the SpaceNavigator

Compiling

Start by getting the dependencies and compiling the driver.

$ rosdep install spacenav_node
$ rosmake spacenav_node

Plugged In

Make sure that your SpaceNavigator is plugged into the USB port.

Start the Spacenav Driver

$ roscd spacenav/spacenav_svn/spacenavd
$ sudo ./spacenavd -d -usb

The -d option causes the driver to run in the foreground so that you can Ctrl-C the driver later. Without -d, the driver would launch as a daemon and you would have to use the kill command to kill it.

You will see the blue light of the spacenavigator turn on, and you should see something similar to:

  • Spacenav daemon svn-r87
    failed to open config file /etc/spnavrc: No such file or directory. using defaults.
    using device: /dev/input/event8
    device name: 3Dconnexion SpaceNavigator

Starting a roscore

For the spacenav_node to work properly, a core must be running. In a new terminal:

$ roscore

Running the spacenav_node

In another new terminal, run the imu_node:

rosrun spacenav_node spacenav_node

Viewing the data

The spacenav_node publishes four topics:

rostopic list

You will see something similar to:

  • /spacenav/joy
    /spacenav/offset
    /spacenav/rot_offset
    /spacenav/twist
  • /spacenav/joy - publishes the linear motion on a scale of [-1, 1]
  • /spacenav/offset - publishes the unscaled linear motion
  • /spacenav/rot_offset - publishes the unscaled rotational motion
  • /spacenav/twist - publishes a twist of unscaled linear and rotational motion

To see that everything is working and data is being published to ROS, in a new terminal:

$ rostopic echo /spacenav/joy

You will see something similar to:

  • ---
    axes: (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
    buttons: (0, 0)
    ---
    axes: (-0.021484375, 0.009765625, -0.009765625, 0.0, 0.0, 0.0)
    buttons: (0, 0)
    ---
    axes: (-0.005859375, 0.02734375, -0.009765625, 0.0, 0.0, 0.0)
    buttons: (0, 0)
    ---
    axes: (-0.005859375, 0.02734375, -0.009765625, -0.0234375, 0.0, 0.0)
    buttons: (0, 0)

Move the spacenavigator around to see the data change.


Wiki: spacenav_node/Tutorials/UsingTheSpacenavNode (last edited 2011-01-21 22:32:14 by MeloneeWise)