You are here

Logging IMU Data over UART

7 posts / 0 new
Last post
stefan_novige
Offline
Last seen: 4 years 9 months ago
Joined: 2019-07-11 00:43
Posts: 3
Logging IMU Data over UART

Hey Guys, 

I recently picked up a VESC 6+ and I can see that it has a built in IMU. I have managed to write my own code to access and use all the commands built into the VESC  i.e. SetDuty, GetVals... etc...

However I have not managed to find any info on extracting the IMU Data. I would assume this to be straightforward as the VESC tool can do this over USB, however documentation is slim. Does anyone have any pointers to get me started? I am writing in python due to its ease for rapid prototyping.

I would like to be able to read in the IMU on my Raspberry PI over UART.

Thanks in advance for the help, 

Stefan

matrixgti
Offline
Last seen: 9 months 3 weeks ago
Joined: 2018-05-30 12:19
Posts: 7

Stefan , I have the same problem but over CAN , seems that some parameters are not still available on all protocols. Hope someone can point us . Flavio

frank
Offline
Last seen: 3 weeks 3 days ago
VESC BronzeVESC FreeVESC GoldVESC OriginalVESC PlatinumVESC Silver
Joined: 2016-12-27 20:19
Posts: 847

The position in space is shown in the mobile VESC-Tool, via BLE connection, via UART. Scroll to RT-Data, scroll all the way down.

I'm sure Benjamin can point you to the code that is usable for you.

pf26
Offline
Last seen: 2 days 8 hours ago
VESC FreeVESC Silver
Joined: 2018-12-04 08:44
Posts: 53

Did you try "COMM_SET_CHUCK_DATA" ?  This you return you something as per given in this function:  (in commands.cpp)

void Commands::setChukData(chuck_data &data)
{
    VByteArray vb;
    vb.vbAppendInt8(COMM_SET_CHUCK_DATA);
    vb.vbAppendUint8(data.js_x);
    vb.vbAppendUint8(data.js_y);
    vb.vbAppendUint8(data.bt_c);
    vb.vbAppendUint8(data.bt_z);
    vb.vbAppendInt16(data.acc_x);
    vb.vbAppendInt16(data.acc_y);
    vb.vbAppendInt16(data.acc_z);
    emitData(vb);
}

stefan_novige
Offline
Last seen: 4 years 9 months ago
Joined: 2019-07-11 00:43
Posts: 3

Thanks for the advice, and no I have not. I did not realise that CHUCK would have a correlation with the IMU. Also are you suggesting that a set command will in fact return the current IMU data? I see that there is also a command called COMM_GET_DECODED_CHUCK, however I am a little hesitant to use it as I did try COMM_GET_DECODED_PPM and fried the software, requiring a reflash of the whole VESC... thoughts?

 

Also thanks Frank! I will see if I can run a search on the git for the tools! Maybe there will be something that comes up while we wait for Benjamin's reply!

 

stefan_novige
Offline
Last seen: 4 years 9 months ago
Joined: 2019-07-11 00:43
Posts: 3

Actually whilst looking through the VESC_TOOL code (datatypes.h), I stumbled across the ENUM list shown below. It is an extended version of an ENUM list found in datatypes.h in the UART code repository. I would assume that this would mean that sending the VESC a command with ID65 would send COMM_GET_IMU_DATA and thus one could read the serial port and obtain it. Would be nice to get some clarification on this before I end up frying the software for the VESC again.

typedef enum {
    COMM_FW_VERSION = 0,
    COMM_JUMP_TO_BOOTLOADER,
    COMM_ERASE_NEW_APP,
    COMM_WRITE_NEW_APP_DATA,
    COMM_GET_VALUES,
    COMM_SET_DUTY,
    COMM_SET_CURRENT,
    COMM_SET_CURRENT_BRAKE,
    COMM_SET_RPM,
    COMM_SET_POS,
    COMM_SET_HANDBRAKE,
    COMM_SET_DETECT,
    COMM_SET_SERVO_POS,
    COMM_SET_MCCONF,
    COMM_GET_MCCONF,
    COMM_GET_MCCONF_DEFAULT,
    COMM_SET_APPCONF,
    COMM_GET_APPCONF,
    COMM_GET_APPCONF_DEFAULT,
    COMM_SAMPLE_PRINT,
    COMM_TERMINAL_CMD,
    COMM_PRINT,
    COMM_ROTOR_POSITION,
    COMM_EXPERIMENT_SAMPLE,
    COMM_DETECT_MOTOR_PARAM,
    COMM_DETECT_MOTOR_R_L,
    COMM_DETECT_MOTOR_FLUX_LINKAGE,
    COMM_DETECT_ENCODER,
    COMM_DETECT_HALL_FOC,
    COMM_REBOOT,
    COMM_ALIVE,
    COMM_GET_DECODED_PPM,
    COMM_GET_DECODED_ADC,
    COMM_GET_DECODED_CHUK,
    COMM_FORWARD_CAN,
    COMM_SET_CHUCK_DATA,
    COMM_CUSTOM_APP_DATA,
    COMM_NRF_START_PAIRING,
    COMM_GPD_SET_FSW,
    COMM_GPD_BUFFER_NOTIFY,
    COMM_GPD_BUFFER_SIZE_LEFT,
    COMM_GPD_FILL_BUFFER,
    COMM_GPD_OUTPUT_SAMPLE,
    COMM_GPD_SET_MODE,
    COMM_GPD_FILL_BUFFER_INT8,
    COMM_GPD_FILL_BUFFER_INT16,
    COMM_GPD_SET_BUFFER_INT_SCALE,
    COMM_GET_VALUES_SETUP,
    COMM_SET_MCCONF_TEMP,
    COMM_SET_MCCONF_TEMP_SETUP,
    COMM_GET_VALUES_SELECTIVE,
    COMM_GET_VALUES_SETUP_SELECTIVE,
    COMM_EXT_NRF_PRESENT,
    COMM_EXT_NRF_ESB_SET_CH_ADDR,
    COMM_EXT_NRF_ESB_SEND_DATA,
    COMM_EXT_NRF_ESB_RX_DATA,
    COMM_EXT_NRF_SET_ENABLED,
    COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP,
    COMM_DETECT_APPLY_ALL_FOC,
    COMM_JUMP_TO_BOOTLOADER_ALL_CAN,
    COMM_ERASE_NEW_APP_ALL_CAN,
    COMM_WRITE_NEW_APP_DATA_ALL_CAN,
    COMM_PING_CAN,
    COMM_APP_DISABLE_OUTPUT,
    COMM_TERMINAL_CMD_SYNC,
    COMM_GET_IMU_DATA,
    COMM_BM_CONNECT,
    COMM_BM_ERASE_FLASH_ALL,
    COMM_BM_WRITE_FLASH,
    COMM_BM_REBOOT,
    COMM_BM_DISCONNECT
} COMM_PACKET_ID;

 

pf26
Offline
Last seen: 2 days 8 hours ago
VESC FreeVESC Silver
Joined: 2018-12-04 08:44
Posts: 53

Yes, it needs clarification. To me, the COMM_SET_CHUCK code seem to refer to a read (=GET) of the IMU data through CAN bus (or UART ?). I would give it a try.

The datatypes.h code in VESC_tool also has a "COMM_GET_IMU_DATA", which might be usable. I couldn't find code using it (but possibly I don't have the same vesc_tool version as you have).

Otherwise, you may want to use a portmon (COM port spy) on the PC using VESC_tools to see the outgoing and incoming UART frames to check..