Jump to content

Pb IMU Brick 2.0 with Python 3.6

Recommended Posts

Hello ,


I'm using Python 3.6.


I can run the example to emunerate my device.

When I'm using example_simple.py from IMU brick 2.0.

I have an error message from  imu.get_quaternion()


in get_quaternion

    return GetQuaternion(*self.ipcon.send_request(self, BrickIMU.FUNCTION_GET_QUATERNION, (), '', 'f f f f'))


  File "C:\Users\JPannetier\Anaconda3\lib\site-packages\tinkerforge\ip_connection.py", line 1194, in send_request

    return unpack_payload(response[8:], form_ret)


  File "C:\Users\JPannetier\Anaconda3\lib\site-packages\tinkerforge\ip_connection.py", line 251, in unpack_payload

    x = struct.unpack(f, data[:length])


error: unpack requires a buffer of 4 bytes


Thank you

Best regard

Share this post

Link to post
Share on other sites

But it says "BrickIMU.FUNCTION_GET_QUATERNION" in your pasted error message. It should be "BrickIMUV2". Are you sure you are not using the IMU 1.0 example?

Share this post

Link to post
Share on other sites

I'm using a Brick IMU 2.0 with its example :



When I opened the source of Brick IMU 2.0, i can notice :

Into communication.c :


void get_quaternion(const ComType com, const GetQuaternion *data) {

GetQuaternionReturn gqr;


gqr.header        = data->header;

gqr.header.length = sizeof(GetQuaternionReturn);

gqr.x            = sensor_data.qua_x;

gqr.y            = sensor_data.qua_y;

gqr.z            = sensor_data.qua_z;

gqr.w            = sensor_data.qua_w;


send_blocking_with_timeout(&gqr, sizeof(GetQuaternionReturn), com);



And into communication.h


typedef struct {

MessageHeader header;

int16_t w;

int16_t x;

int16_t y;

int16_t z;

} __attribute__((__packed__)) GetQuaternionReturn;





Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...