Increase stream rate of HIGHRES_IMU message

I want to increase stream rate of HIGHRES_IMU message to 200 Hz for streaming to companion board via telem2 connecting to odroid via USB FTDI, and use a sample code from c_uart_interface_example.

I have done with editing mavlink_main.cpp in Firmware as follow

  case MAVLINK_MODE_ONBOARD:
		configure_stream("SYS_STATUS", 5.0f);
		configure_stream("EXTENDED_SYS_STATE", 5.0f);
        configure_stream("HIGHRES_IMU",200.0f); //Default is 50.0f
		configure_stream("ATTITUDE", 50.0f); //Default is 250.0f
		configure_stream("ATTITUDE_QUATERNION", 50.0f);
		configure_stream("RC_CHANNELS", 20.0f);
		configure_stream("SERVO_OUTPUT_RAW_0", 10.0f);
		configure_stream("ALTITUDE", 10.0f);
		configure_stream("GPS_RAW_INT", 5.0f);
		configure_stream("ADSB_VEHICLE", 10.0f);
		configure_stream("COLLISION", 10.0f);
		configure_stream("DISTANCE_SENSOR", 10.0f);
		configure_stream("OPTICAL_FLOW_RAD", 10.0f);
		configure_stream("VISION_POSITION_ESTIMATE", 10.0f);
		configure_stream("ESTIMATOR_STATUS", 1.0f);
		configure_stream("NAV_CONTROLLER_OUTPUT", 10.0f);
		configure_stream("GLOBAL_POSITION_INT", 50.0f);
		configure_stream("LOCAL_POSITION_NED", 30.0f);
		configure_stream("POSITION_TARGET_GLOBAL_INT", 10.0f);
		configure_stream("ATTITUDE_TARGET", 10.0f);
		configure_stream("HOME_POSITION", 0.5f);
		configure_stream("NAMED_VALUE_FLOAT", 10.0f);
		configure_stream("VFR_HUD", 10.0f);
		configure_stream("WIND_COV", 10.0f);
		configure_stream("POSITION_TARGET_LOCAL_NED", 10.0f);
		configure_stream("SYSTEM_TIME", 1.0f);
		configure_stream("TIMESYNC", 10.0f);
		configure_stream("CAMERA_CAPTURE", 2.0f);
		//camera trigger is rate limited at the source, do not limit here
		configure_stream("CAMERA_TRIGGER", 50.0f);
		configure_stream("CAMERA_IMAGE_CAPTURED", 5.0f);
		configure_stream("ACTUATOR_CONTROL_TARGET0", 10.0f);
		break;

First, I changed only value for HIGHRES_IMU but leave the other as default.

        configure_stream("HIGHRES_IMU",200.0f); //Default is 50.0f
		configure_stream("ATTITUDE", 250.0f); 

it result to higher streaming rate of HIGHRES_IMU (result is only 10 Hz)

Then I reduce the value of ATTITUDE (I assume that there is no space left to increase imu message) but the result is the same (10 Hz).

        configure_stream("HIGHRES_IMU",200.0f); //Default is 50.0f
		configure_stream("ATTITUDE", 50.0f); //Default is 250.0f

I have tried with MAV_CMD_SET_MESSAGE_INTERVAL, but nothing change, I still not able to get 200 Hz at this point.

 mavlink_command_long_t com;
    com.target_system    = system_id;
    com.target_component = autopilot_id;
    com.command          = 	MAV_CMD_SET_MESSAGE_INTERVAL;
    com.confirmation = 0;
    com.param1 = MAVLINK_MSG_ID_HIGHRES_IMU;
    com.param2 = 5000;

    // Encode
    mavlink_message_t message;
    mavlink_msg_command_long_encode(system_id, companion_id, &message, &com);

    // Send the message
    int len = serial_port->write_message(message);

Does anyone know how to increase stream rate of a message (especially HIGHRES_IMU) please help me. or If there is a limitation please advice me.

Thank you,

Which board is this and what’s SYS_COMPANION set to? There are proper ways to configure these rates by sending mavlink messages, but it’s easy enough to hack.

This is how mavlink is started differently. https://github.com/PX4/Firmware/blob/master/ROMFS/px4fmu_common/init.d/rcS#L600

Depending on the autopilot you’re using the telem2 buffer (a nuttx board configuration) might be too small.

1 Like

I am using Pixhawk, and SYS_COMPANION is set to 'Companion Link(921600 baud,8N1), Should I increase baudrate? and what is an optimal number of baudrate to achieve 200 hz?

@dagar Please suggest me a bit more, Isn’t it mean that I can’t achieve 200Hz for telem2 on pixhawk? or there is another possible way for this. follow the usage from here, I try to add command mavlink stream -d ${MAVLINK_COMPANION_DEVICE} -s HIGHRES_IMU -r 200 under mavlink start. This result to < 1Hz of HIGHRES_IMU.

I also try with extras.txt referred here and here , , This method isn’t work also. Do I have to do something else apart from create exteas.txt in /fs/sdcard/etc/

my extras.txt

#!nsh
mavlink start -d /dev/ttyS2 -b 921600 -m onboard -r 80000
mavlink stream -d /dev/ttyS2 -s HIGHRES_IMU -r 200

What’s your full setup (companion computer, cabling, etc)? Something else must be wrong if you’re only getting 1Hz updates.

@dagar I have tried two ways. First, using Odroid XU4 as a companion board connect to Pixhawk via GPIO. Second, using a laptop as a companion computer connect to Pixhawk via UART FTDI. Both connect to Telem 2 on baud rate = 921600. Both option I can get messages but in the low streaming rate.

PX4 Firmware cloned from stable branch (link)
Airframe: Quadrotor X : 3DR DIY Quad
Firmware version: 1.6.5dev

Result of version check in NuttShell

NuttShell (NSH)
nsh> 
ver all
HW arch: PX4FMU_V2
FW git-hash: d928fd3bb9c7cd264a8587346d49df9ecbee8782
FW version: 1.6.5 0 (17171712)
OS: NuttX
OS version: 0.0.0 c0 (192)
OS git-hash: 8b81cf5c7ece0c228eaaea3e9d8e667fc4d21a06
Build datetime: Nov 15 2017 16:55:15
Build uri: localhost
Toolchain: GNU GCC, 5.4.1 20160609 (release) [ARM/embedded-5-branch revision 237715]
MFGUID: 333735383335510900500035
MCU: STM32F42x, rev. 3
UID: 500035:33355109:33373538 
nsh> config /dev/accel0 check
WARN  [config] accel calibration and self test OK
WARN  [config] accel: 
	device id:	0x13040A	(calibration is for device id 0x13040A)
	sample rate:	1000 Hz
	read rate:	1000 Hz
	range:	16 G
nsh> config /dev/accel1 check
WARN  [config] accel calibration and self test OK
WARN  [config] accel: 
	device id:	0x11020A	(calibration is for device id 0x13040A)
	sample rate:	800 Hz
	read rate:	800 Hz
	range:	8 G
nsh> config /dev/gyro1 check
WARN  [config] gyro calibration and self test OK
WARN  [config] gyro: 
	device id:	0x22010A	(calibration is for device id 0x21040A)
	sample rate:	760 Hz
	read rate:	760 Hz
	range:	2000 dps
nsh> config /dev/gyro0 check
WARN  [config] gyro calibration and self test OK
WARN  [config] gyro: 
	device id:	0x21040A	(calibration is for device id 0x21040A)
	sample rate:	1000 Hz
	read rate:	1000 Hz
	range:	2000 dps
nsh> 

What’s the output of mavlink status? If you connect in QGC what rate does the mavlink inspector show?

The result of mavlink status

nsh> mavlink status

instance #0:
	mavlink chan: #0
	type:		3DR RADIO
	rssi:		34
	remote rssi:	0
	txbuf:		100
	noise:		32
	remote noise:	0
	rx errors:	0
	fixed:		0
	flow control:	OFF
	rates:
	tx: 0.738 kB/s
	txerr: 0.000 kB/s
	rx: 0.034 kB/s
	rate mult: 0.381
	accepting commands: YES
	MAVLink version: 1
	transport protocol: serial (/dev/ttyS1 @57600)

instance #1:
	GCS heartbeat:	630756 us ago
	mavlink chan: #1
	type:		GENERIC LINK OR RADIO
	flow control:	OFF
	rates:
	tx: 3.803 kB/s
	txerr: 0.000 kB/s
	rx: 0.017 kB/s
	rate mult: 0.138
	accepting commands: YES
	MAVLink version: 1
	transport protocol: serial (/dev/ttyS2 @921600)

the result of Mavlink Inspector

That’s very odd, you can see that it’s crawling at 3.8 kB/s and scaled down to 0.138 of the rate you asked for. It should easily be many times higher than this.

As a quick test you could try stopping all mavlink and connecting telem1 (/dev/ttyS1) to the odroid, then manually starting again. If it’s still this slow then I’m fairly certain the problem is on the odroid side.

Thank you so much, I finally got 189 Hz (setting is 200HZ) by editing rcS and add mavlink stream -d ${MAVLINK_COMPANION_DEVICE} -s HIGHRES_IMU -r 200 under mavlink start and I have to remove extras.txt from SD card also.

Hi! Where did you find the rcS file? Thank you very much

Hi @im.rasp,
Did you find a way to increase the stream rate to 200 Hz or more?
I add mavlink stream -d ${MAVLINK_COMPANION_DEVICE} -s HIGHRES_IMU -r 200 in the extras.txt. But only got the outputs around 185 Hz. Thanks in advance.

3 Likes

I was also looking into this issue as well. We are using a Holybro Pixhawk 4 and are setting the IMU rate trough the extras file as well (only because we could not find an option to properly set it trough mavlink).

mavlink stream -d /dev/ttyS2 -s HIGHRES_IMU -r 300

However, we would like to read IMU messages at 300-400 Hz but with the setting above (300Hz) we only receive messages at a rate of 180-200Hz. I don’t think that this is a hardware limitation - I remember the AscTec autopilot did provide IMU readings at 400Hz and above trough UART, depending on the rate of other messages (Magnetometer, pressure etc.).

Is there a software limitation or setting that I need to adapt to archive higher IMU rates trough UART?