Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve RTCM3 parsing performance #177

Merged
merged 3 commits into from
Mar 25, 2025
Merged

Improve RTCM3 parsing performance #177

merged 3 commits into from
Mar 25, 2025

Conversation

alexcekay
Copy link
Member

@alexcekay alexcekay commented Mar 18, 2025

Solved Problem

This is the first follow up to: PX4/PX4-Autopilot#24491. The NAV + RTCM3 parser can block each other as both parsers are integrated into the same state machine. This can cause significant delay until the parser gets in sync again.

As can be seen in the attached screenshots, the remaining timeout is in general higher now and the deepest drop is not as low as before. This was the worst case scenario of many tests.

Worst without change

Screenshot from 2025-03-18 16-38-44

Worst with change

Screenshot from 2025-03-18 16-39-07

Solution

  • Forward input data to both NAV + RTCM3 parser and keep their states separate, so they can not block each other
  • Use CRC24 to verify if RTCM3 data is valid before forwarding it to the callback
  • When either NAV or RTCM3 parsing is successful, reset both parsers to start sync again

I would like to keep the increased timeout until all remaining drops are removed, which will be done in follow-up PRs.

Testing

  • Tested with and without RTK on the bench
  • Checked gps_dump data to ensure PPK still works

@alexcekay alexcekay marked this pull request as ready for review March 18, 2025 17:38
@alexcekay alexcekay requested review from niklaut and bkueng March 18, 2025 17:38
@alexcekay
Copy link
Member Author

alexcekay commented Mar 21, 2025

Hi @niklaut, @bkueng,
could you guys have a look at this PR? Thanks.

src/ubx.cpp Outdated

default:
break;
if (_rtcm_parsing && ret > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reset here in any case
if (_rtcm_parsing) {
to be independent from whether a message was handled or not.

And then move the block from below to above:

	if (_rtcm_parsing) {
		if (_rtcm_parsing->addByte(b)) {
			gotRTCMMessage(_rtcm_parsing->message(), _rtcm_parsing->messageLength());
			decodeInit();
			_rtcm_parsing->reset();
			return 0;
		}
	}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the input. I updated it.

@alexcekay alexcekay requested a review from bkueng March 24, 2025 15:00
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice work

@bkueng bkueng merged commit 4cea5de into main Mar 25, 2025
@bkueng bkueng deleted the pr-rtcm-crc branch March 25, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants