vedderb / bldc

The VESC motor control firmware
2.18k stars 1.35k forks source link

COMM_GET_IMU_DATA controller_id not set #663

Closed anscipione closed 11 months ago

anscipione commented 11 months ago

I'm implementing a driver to use vesc inside ros2.

I noticed that the COMM_GET_IMU_DATA It has a 16-bit mask line

uint32_t mask = buffer_get_uint16(data, &ind2);

but the controller_id will only be obtained with a bit mask 1 0000 0000 which is not compatible with unit16

line if (mask & ((uint32_t)1 << 16)) {

I think the mask should be:

uint32_t mask = buffer_get_uint32(data, &ind2);

is it correct?

vedderb commented 11 months ago

Good observation!

Here is an attempt at a fix https://github.com/vedderb/bldc/commit/e0bc115454cf4027d88de0c3692a616a314faa1b

Rather than changing the size of mask I now always add the id to the end. That will keep working with old code that uses the 16-bit mask and actually saves space in the message as one byte for the id is less than two extra bytes for the larger mask on the reply.

anscipione commented 11 months ago

It seems correct to me. thus the IMU data of several VESC connected via CANBUS would be recognisable.

In my configuration I have 4 vesc connected to each other via canbus which I would like to control from one of them via USB.