Using Python to access Quaternion data from the RVR IMU

Hi, in looking through some of the RVR documentation, I noticed that the RVR IMU sensor provides quaternion data. Quaternions enable the fusion of magnetometer, accelerometer and gyroscopic sensor readings to provide accurate, three-axis, spatial information. With quaternions it is relatively easy to compute yaw and heading information. This is opposed to the more complex arctan2-based method that uses only magnetometer (and possibly) accelerometer data.

Given this, here are my questions:

  1. Does the latest python specific sphero_sdk (contained in the sphero-sdk-raspberry-pi-master from github) provide support for obtaining quaternion data from the RVR IMU?

  2. If quaternions are supported. Can you please reference the appropriate documentation and provide examples of how we can access quaternion data. Hopefully, you can provide both asyncio and observer based versions of the program that shows how to access quaternion data.

  3. If quaternions are not supported, are their any plans to provide support in a future python sdk? This last question is really important, in that future quaternion support will make it relatively “easy” for the RVR programmer to obtain accurate yaw and heading information.

Thanks in advance for your help with this question.

…Gary White

Quaternions are available through the streaming service API. See Sensor · Sphero Public SDK although it doesn’t provide a lot of detail. A list of the streaming tokens is at Working with the Sensors · Sphero Public SDK.

The Python code provides more information at common/sensors/ I didn’t look to see if there are examples.

If you understand C++17 my implementation and some example code is at Bitbucket The SensorStream.h and SensorStream.cpp are the C++ implementation. The “threading” program shows how the streaming is set up.

How it works is discussed in the Wiki at rmerriam / RVR CPP / wiki / Streaming — Bitbucket.

This is based on the first version of the software but there aren’t any changes mentioned in the release document for the new firmware.

It isn’t trivial but happy to answer any questions.

Hi @gbw48,

As Rud mentioned, you can stream quaternions from RVR, but you can also stream pitch, roll, and yaw angles and avoid the hassle of converting the quaternions.

If you follow the process used in the newer versions of, then yaw=0 (and heading=0) will be aligned with magnetic north.


SPHERO Email Marketing -