-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
base: master
Are you sure you want to change the base?
Added functionality to prevent activating smartrtl even for disarmed … #28284
Conversation
@@ -11,6 +11,13 @@ | |||
|
|||
bool ModeSmartRTL::init(bool ignore_checks) | |||
{ | |||
// Add check to prevent SmartRTL activation when disarmed | |||
if (!motors->armed()) { |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
BTW Thanks very much for this! |
…copter
fixes #22780
added the code functionality to prevent drone for getting on smartrtl even before getting armed