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

Added functionality to prevent activating smartrtl even for disarmed … #28284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

harsh839
Copy link

@harsh839 harsh839 commented Oct 2, 2024

…copter
fixes #22780
added the code functionality to prevent drone for getting on smartrtl even before getting armed

@@ -11,6 +11,13 @@

bool ModeSmartRTL::init(bool ignore_checks)
{
// Add check to prevent SmartRTL activation when disarmed
if (!motors->armed()) {
Copy link
Contributor

@rmackay9 rmackay9 Oct 3, 2024

Choose a reason for hiding this comment

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

In copter we always allow users to switch to any mode while the vehicle is disarmed. We do not allow users to arm in SmartRTL though so users are forced to be in a different mode when it comes time to arm.

@@ -174,8 +181,12 @@ void ModeSmartRTL::pre_land_position_run()
// save current position for use by the smart_rtl flight mode
void ModeSmartRTL::save_position()
{
const bool should_save_position = motors->armed() && (copter.flightmode->mode_number() != Mode::Number::SMART_RTL);
// Prevent saving positions when the drone is disarmed
if (!motors->armed()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We've already got a "should_save_position" below so I don't think we need this extra armed check.

I suspect the issue is not that a point is being saved but that home is being saved while the vehicle is disarmed. This means that if the user moves the vehicle after arming SmartRTL may move to the original position. Could you confirm this is the issue you're seeing?

Copy link
Author

Choose a reason for hiding this comment

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

Yes this is the issue i was seeing so that it should not go to smartrtl mode before arming the copter that's why i added that thanks for reviewing!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @harsh839,

OK thanks for that. I think a better solution then would be to modify the AP_SmartRTL::update() function so that it takes a "save_home" argument that is set to true if the vehicle is disarmed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually after looking at the code a bit more, I see that when the vehicle arms it calls copter.g2.smart_rtl.set_home(copter.position_ok()) so there shouldn't be any need to do what I've mentioned above.

I'm sorry @harsh839, I don't see the problem. Are you sure that you've reproduced a problem and shown that this PR fixes it? Could you please share some logs or screen shots showing the before and after?

Copy link
Author

Choose a reason for hiding this comment

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

ohk i will be posting here just check my another PR which fixes #17419

@rmackay9
Copy link
Contributor

rmackay9 commented Oct 3, 2024

BTW Thanks very much for this!

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.

Copter: SmartRTL causing Internal Error 100000
2 participants