(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Testing a Phidget Accelerometer

Description: This tutorial shows you how to connect a Phidget accelerometer and view axes data changes published to a ROS topic.

Keywords: phidgets, accelerometer

Tutorial Level: BEGINNER

One Time Setup Instructions

The phidgets_ros package calls phidgets_py_api which loads the Phidgets C Api (phidgetspp_c_api). On linux, by default, USB devices are not writeable by anybody but root. This can be solved by following the udev ruleset instructions in the phidgetspp_c_api package. You will need to build this package to get the instructions and the rule file:

$ roscd phidgetspp_c_api
$ rosmake

Following the udev instructions in build/Phidgetlinux/README file.

$ sudo cp build/Phidgetlinux/phidget21/udev/*.rules /etc/udev/rules.d/.

then restart udev:

$ sudo /etc/init.d/udev restart

You will also need to set up one last environment variable so that libusb will look at /dev/bus/usb instead of /proc/bus/usb.

$ export USB_DEVFS_PATH=/dev/bus/usb

After this, you should be able to connect your Phidget.


Start by compiling the driver:

$ rosmake phidgets_ros

To Run

Run the Accelerometer node. (You might be prompted to start roscore in another shell if it is not already running.)

$ rosrun phidgets_ros accelerometer.py

You should see something like this:

  • Please attach Accelerometer now. (waiting 15 seconds)

Connect a Phidget Accelerometer using a USB cable to your PC.

Confirming Accelerometer Output

Move the accelerometer to create data changes. To monitor the changes, echo the accelerometer ROS topic:

$ rostopic list
$ rostopic echo /accelerometer

You should see something like this:

  • ---
    index: 2
    acceleration: 1.74697995186
    index: 2
    acceleration: 0.960539996624
    index: 2
    acceleration: 0.413670003414
    index: 1
    acceleration: 0.547490000725
    index: 2
    acceleration: 1.27319002151
    index: 0
    acceleration: 0.571290016174

Note: Index 0, 1 and 2 are the x, y and z axes. Which axes the index numbers coorespond to will vary depending on how you mount the accelerometer.

Wiki: phidgets_ros/Tutorials/Testing a Phidget Accelerometer (last edited 2010-03-05 21:11:16 by CaraS)