YAMSPy icon indicating copy to clipboard operation
YAMSPy copied to clipboard

How to communicate with FC fast?

Open yrik opened this issue 1 year ago • 5 comments

When I'm running commands like MSP_BOARD_INFO it takes good 5-10 seconds to process each command. Is that normal? What is the proper way to get fast accel/gyro values from FC? Say 100 times per second.

yrik avatar Oct 01 '23 13:10 yrik

My first suggestion is to try this branch: https://github.com/thecognifly/YAMSPy/tree/yb/stable Then check the Examples folder.

ricardodeazambuja avatar Oct 02 '23 15:10 ricardodeazambuja

@ricardodeazambuja hi, I am using this library for an autonomous drone project, I am trying to understand how fast I can read accelerometer and gyroscope readings and send RC commands. So far it seems that the MSP communication with the flight controller maxes out at about 62.5Hz. I tested this using the script in Examples/RPI0-OF/test_serial.py where I obtain a read speed around 15.6Hz (since it is performing 4 operations per iteration the overall frequency of communication is 62.5Hz). On my flight controller I set the baudrate to be 5e5 and I even increased the frequency of the serial task with the CLI command set serial_update_rate_hz=2000. Is this expected or am I missing something? Ideally I would like to be able to send commands at about 40Hz and read the IMU (accelerometer+gyro) at 30Hz.

Tuxliri avatar May 20 '24 13:05 Tuxliri

Hi @Tuxliri. The max frequency you can get depends on many factors. What is the microcontroller that your FC uses? Is it F7 or F4? You can also have a look at the frequencies reported by the inav-configurator to have an idea. We use debug messages to speed things up (example from yb/stable branch: https://github.com/thecognifly/YAMSPy/blob/yb/stable/Examples/test_debug_pos_est.py). It's quite easy to modify inav to create new custom debug messages (https://github.com/thecognifly/inav/commit/8da90c9a4beb618ebe2ed798eb7e2db6e1f1c3af) I prefer to use messages as high level as possible instead of directly reading the acc+gyro (I'm considering inav, not betaflight) because the FC has already done the heavy lifting for you (filtering...).

ricardodeazambuja avatar May 22 '24 00:05 ricardodeazambuja

Thanks for the quick reply @ricardodeazambuja , I have been using Betaflight on an F4 board (SPEEDYBEEF405V3), did you manage to achieve high-frequency communication with it?

I am considering moving to iNAV or Arducopter (using MAVLink) if this is not possible.

Tuxliri avatar May 29 '24 10:05 Tuxliri

If you want to use MSP and cheap flight controllers, iNAV is the best option.

ricardodeazambuja avatar May 30 '24 23:05 ricardodeazambuja