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

Reload mission for RTL_TYPE 2 #23855

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Reload mission for RTL_TYPE 2 #23855

merged 1 commit into from
Nov 5, 2024

Conversation

potaito
Copy link
Contributor

@potaito potaito commented Oct 25, 2024

Solved Problem

When uploading missions to be flown with RTL_TYPE=2 as a return path, PX4 sometimes claims there is no mission when RTL is triggered:

# WARN  [navigator] No valid mission available, loitering	
# ERROR [dataman_client] readSync failed! status=3, item=2, index=4294967295, length=56
# WARN  [navigator] Mission item could not be set.	
# WARN  [navigator] No valid mission available, loitering	

Solution

Turns out that when these specific RTL handlers are initialized, they don't initialize their mission member variable. Because of that the RTL handlers essentially work with an empty mission where the index is -1, hence the dataman error.

The solution is to load the existing mission after initializing the handlers. I decided to pass the variables via constructor to contain the logic of obtaining the mission from the uORB queue all in rtl.cpp. This way the information flow is more visible in my opinion.

switch (new_rtl_mission_type) {
	case RtlType::RTL_DIRECT_MISSION_LAND:
		_rtl_mission_type_handle = new RtlDirectMissionLand(_navigator);
		_set_rtl_mission_type = RtlType::RTL_DIRECT_MISSION_LAND;
		// RTL type is either direct or mission land have to set it later.
		break;

	case RtlType::RTL_MISSION_FAST:
		_rtl_mission_type_handle = new RtlMissionFast(_navigator, new_mission);
		_set_rtl_mission_type = RtlType::RTL_MISSION_FAST;
		_rtl_type = RtlType::RTL_MISSION_FAST;
		break;

	case RtlType::RTL_MISSION_FAST_REVERSE:
		_rtl_mission_type_handle = new RtlMissionFastReverse(_navigator, new_mission);
		_set_rtl_mission_type = RtlType::RTL_MISSION_FAST_REVERSE;
		_rtl_type = RtlType::RTL_MISSION_FAST_REVERSE;
		break;

Changelog Entry

For release notes:

Bugfix: "No valid mission available" error with RTL_TYPE=2 
New parameter: -
Documentation: -

Test coverage

Tested with SITL where mission 1 is executed, mission 2 uploaded and then RTL triggered.

Bug on main branch: https://logs.px4.io/plot_app?log=6af3f82a-ec03-4f8e-95d7-f949697ecd00
Fix from this PR: https://logs.px4.io/plot_app?log=03c990f1-0601-4142-8a9b-f6b42b9cc1ef

@potaito
Copy link
Contributor Author

potaito commented Oct 25, 2024

@KonradRudin could you take a look? 🙏

@dakejahl dakejahl merged commit 098a337 into main Nov 5, 2024
57 checks passed
@dakejahl dakejahl deleted the potaito/fix-rtl-type-2 branch November 5, 2024 04:20
@potaito
Copy link
Contributor Author

potaito commented Nov 5, 2024

Thanks @dakejahl 😁

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