Ask Your Question
3

PNI Digital Compass Driver

asked 2011-07-09 10:43:11 -0600

mkoval gravatar image

updated 2012-04-16 10:40:17 -0600

I've recently acquired a PNI Fieldforce TCM-XB and would like to interface it with ROS. It communicates over serial using a binary protocol described in their datasheet. The protocol appears to be proprietary, but I am not familiar enough with the protocols used by other manufacturers to know for sure.

Basic searches in the ROS package database haven't turned up any existing packages. Before I take the time to write one, has anyone else written a ROS node for communicating with this compass?

Update: It's not completely polished, but here is the fieldforce_tcm node that I wrote. It is written in Python and publishes a nav_msgs/Imu message with the orientation field populated.

edit retag flag offensive close merge delete

5 answers

Sort by ยป oldest newest most voted
2

answered 2011-07-10 08:34:47 -0600

Chad Rockey gravatar image

I'm not aware of any PNI drivers. We would have had one for you, but I wrote that one for our custom FPGA solution. ;) No getting that one out.

It shouldn't be too difficult to write using pyserial or boost::asio. If you remember to make it generic for all their compasses, and reconfigurable (maybe even with dynamic reconfigure), you would make it very valuable to the community.

PS: my suggestion on an output message would be a geometry_msgs/QuaternionStamped. Our compass also output pitch and roll, although not filtered, so this message type could output all of those values at once.

edit flag offensive delete link more

Comments

Thanks for your response and the advice. We'll definitely release it to the community once it's working. mkoval ( 2011-07-10 11:11:23 -0600 )edit
1

answered 2012-05-02 09:10:59 -0600

Enrique gravatar image

With the new and latest version I have timeout problems with my PNI Prime. I also has a 0.5s timeout for almost all commands, but it seems to be actually more. This is the exception raised:

 File "pni_prime_imu.py", line 331, in <module>
    main()
  File "pni_prime_imu.py", line 327, in main
    raise e
pni_dev.TimeoutException: Did not recv frame_id (5,) within time limit.

Plesase, note that I've only changed the name of the driver to pni_dev, and create my own wrapper on top of it. Everything is the same. I increase the timeout to 1s in a >24h experiment, but at some point it wasn't enough.

Do you have any idea that could explain this behaviour?

Thanks in advance, Enrique

edit flag offensive delete link more

Comments

Hi, I'm not seeing a correspondence between the line numbers you've posted here and the ones in fieldforce_tcm/src/fieldforce_tcm.py (@ commit b3c270b ).Is pni_prime_imu.py a different file currently in the fieldforce_tcm package? Are there any edits to it? Is there any more to this exception?

Cody ( 2012-05-02 14:57:16 -0600 )edit

Well, this pni_prime_imu.py file is mine, just a wrapper over the driver fieldforce_tcm.py. Let's say it's an equivalent to compass.py. However, the problem is simply the fact that the timeout expires before something arrives. I set it to 1s, instead of 0.5s. This happens in recv.

Enrique ( 2012-05-02 22:19:37 -0600 )edit

I also have to say, that in this particular case of a >24h experiment, I run out of batteries, so that was the reason because the sensor didn't reply any longer. Anyway, please note the fact that I increased the timeout from 0.5s to 1s. That's what I don't understand. Do you have similar problems?

Enrique ( 2012-05-02 22:23:52 -0600 )edit

I can't do anything about the battery life :) . I have however written some code in the ros node that attempts to restart the compass if a timeout in data occurs (and increased the timeout). It'll be pushed to the main repo as soon as we test it (for now, it is in github.com/jmesmon/fieldforce_tcm).

Cody ( 2012-05-03 17:20:40 -0600 )edit

Sure ;) Thanks. Actually, those two things can be done: increase timeout, catch exception and retry. Anyway, it seems strange the documentation says only 0.5s, when it happens to be far more.

Enrique ( 2012-05-03 22:39:42 -0600 )edit
1

We've updated the driver with the code which attempts to reset it.

Cody ( 2012-05-11 14:34:04 -0600 )edit
0

answered 2012-04-19 12:33:33 -0600

Enrique gravatar image

updated 2012-04-25 22:59:16 -0600

Hi,

I can say it also works for the PNI Prime model.

For the source I downloaded (a few days ago), you might detect some problems with the (let's say) "k" and no "k" var names if you ask the device for more "components", e.g. accelerometer and magnetometer readings. It's straightforward to correct though, and maybe it's already fix in the repo (but didn't check, don't know). Let me know if you want to know the details.

UPDATE #1:

    Datum     = namedtuple('Datum', [
        'Heading', 'Temperature', 'Distortion', 'CalStatus',
        'PAligned', 'RAligned', 'IZAligned',
        'PAngle', 'RAngle', 'XAligned', 'YAligned', 'ZAligned'
    ])

instead of

    Datum     = namedtuple('Datum', [
        'Heading', 'Temperature', 'Distortion', 'CalStatus',
        'PAligned', 'RAligned', 'IZAligned',
        'PAngle', 'RAngle', 'KXAligned', 'KYAligned', 'KZAligned'
    ])

Only the 'K' has to be remove, for the last three items.

UPDATE #2:

I've detected some problem using your driver with my PNI Prime. When I stop the driver the sensor is left in a state such that when I re-start the driver again it fails. Then, I re-start again and it works. See below the call stack output (summarized):

    compass.setConfig(Configuration.kMountingRef, Orientation.kOrientationSTD0)
  File "pni_dev.py", line 311, in setConfig
    self._recvSpecificMessage(FrameID.kSetConfigDone)
  File "pni_dev.py", line 260, in _recvSpecificMessage
    raise IOError('Response has unexpected frame id: {0}.'.format(frame_id))
IOError: Response has unexpected frame id: 5.

Have you found this problem too? I've also tried to put a powerDown at the end. It only happens that the error changes. And, at the very beginning, I've also put powerUp and stopStreaming, to ensure config mode ---I guess. But still the same.

Thanks for this great contribution, mkoval! EnriquepowerDown

edit flag offensive delete link more

Comments

1

One of my colleagues and I made some changes to the "components" code earlier this week, so I am not surprised if there is a bug. Can you describe what the problem is in more detail?

mkoval ( 2012-04-19 20:23:49 -0600 )edit

I just edited the answer with the details, as well as a problem when I re-start the driver, for the PNI Prime.

Enrique ( 2012-04-25 23:00:07 -0600 )edit
1

@Enrique: Both of those problems should be fixed in the latest code in my repo. This update adds a script for limited tilt calibration (IRRC) and, most importantly, discards unexpected packets. Let me know if that fixes the issue.

mkoval ( 2012-04-26 21:18:36 -0600 )edit

@mkoval: I cannot try it now, but I'll let you know if it works. BTW: I also had to add this to the rosdep.yaml file: pyserial: ubuntu: python-serial

Enrique ( 2012-04-26 22:07:10 -0600 )edit

@mkoval: Also, pip install decorator is required in rosdep.yaml, i.e. it's installed the same way as crcmod.

Enrique ( 2012-04-29 23:31:23 -0600 )edit

@mkoval: To make it work with my PNI Prime I had to increase the timeout (pni_dev.py:421) to 1s, instead of 0.5s (the manual says 0.5s, but it seems to be not enough); I'm using an USB-serial adapter, btw. Also, when closing (Ctrl+C), the node it's not correctly "kill": it scales to SIGKILL!

Enrique ( 2012-04-30 00:00:25 -0600 )edit
0

answered 2012-02-20 19:59:13 -0600

TimElery gravatar image

I also have this exact same compass. Has anyone made progress towards a solid driver for this device?

Thank you, Tim

edit flag offensive delete link more

Comments

I updated my original post with a link to the (mostly) finished node.

mkoval ( 2012-04-16 10:41:02 -0600 )edit
0

answered 2011-09-26 10:18:20 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hello, I have the exact same compass and was wondering if you ever got those drivers done? Are you will to share them?

Thank you.

edit flag offensive delete link more

Comments

They weren't very high priority and we're working on them now. We'll definitely release them when they're done. mkoval ( 2012-01-03 01:42:48 -0600 )edit

I updated my original post with a link to the (mostly) finished node.

mkoval ( 2012-04-16 10:41:10 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Follow
2 followers

Stats

Asked: 2011-07-09 10:43:11 -0600

Seen: 484 times

Last updated: May 02 '12