-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
actuator: add support for MAV_CMD_DO_SET_ACTUATOR #16758
Conversation
Hold tight, we're very close to finally having a good solution to this problem. FYI @JacobCrabill |
actuator_controls_s actuator_group_3{}; | ||
// copy in previous actuator control setpoint in case aux{1, 2, 3} isn't changed | ||
_actuator_controls_3_sub.update(&actuator_group_3); |
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.
It's almost always a bad idea to publish the same topic from multiple sources simultaneously.
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.
Hmm ok. I implemented the deconfliction logic that Beat recommended but I see how it could cause problems.
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.
And then you copy control group 6 here if published and changing and overwrite group 3? That would allow you to default the output of group 3 to the last active from either manual or external control. And someone just interested in external can map the mixer straight to group 6 and never have manual intervention.
591553a
to
45209f5
Compare
@dagar Ok 😄 Do you mean a good solution that will solve the deconfliction or something that circumvents my PR completely? |
I fixed the format issues but CI seems to be overflowing flash space on fmuv2. Is this something I need to account for, and how? |
Note before any merging can take place: I haven't checked how mission mode handles this command yet, if its different. |
Adds support for using the MAVLink command MAV_CMD_DO_SET_ACTUATOR to update the actuator values on control group 3 aux{1, 2, 3}. A simple deconfliction with rc_update is implemented: when a MAVLink command is sent, RC is disabled for that channel until a major stick movement is detected.
45209f5
to
2e5ad58
Compare
// if there is a major stick movement to re-activate RC mode | ||
bool major_movement[3] = {false, false, false}; | ||
|
||
// detect a big stick movement |
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.
This will not detect a big, but a fast stick movement.
} | ||
|
||
if (updated) { | ||
_actuator_controls_pubs[3].publish(actuator_controls); |
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.
How about you publish control group 6 (might need to be defined) here, so it's conflict-free? https://docs.px4.io/master/en/concept/mixing.html#control-group-6-first-payload
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.
@LorenzMeier I think the rationale @bkueng had with using control group 3 was that it would work OOTB (mixers would not have to be modified by the user) and RC override is also possible. If group 6 is still preferable I can update
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.
@coderkalyan I was suggesting to handle the vehicle_command MAV_CMD_DO_SET_ACTUATOR
directly in rc_update.cpp
to avoid conflicts and then it would also just work for navigator.
actuator_controls_s actuator_group_3{}; | ||
// copy in previous actuator control setpoint in case aux{1, 2, 3} isn't changed | ||
_actuator_controls_3_sub.update(&actuator_group_3); |
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.
And then you copy control group 6 here if published and changing and overwrite group 3? That would allow you to default the output of group 3 to the last active from either manual or external control. And someone just interested in external can map the mixer straight to group 6 and never have manual intervention.
@@ -489,8 +489,39 @@ void MavlinkReceiver::handle_message_command_both(mavlink_message_t *msg, const | |||
send_ack = true; | |||
} | |||
|
|||
} else { | |||
} else if (cmd_mavlink.command == MAV_CMD_DO_SET_ACTUATOR) { | |||
// since we're only paying attention to 3 AUX outputs, the |
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.
This also needs to be added to navigator.
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.
Yep, will do.
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.
To avoid code duplication, you could move it to the commander. This handles commands in a mission as well as MAVLink commands. Compare with the code and successful tests in #14809
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.
since we're only paying attention to 3 AUX outputs
What is the rational behind this? This is very confusing, and is not obvious unless you dig into the code
I actually am working on a more general solution with @dagar that should solve this problem as a subset of the much broader control allocation / output mapping topic... will share more details once it's a little more complete, but as of right now I can arbitrarily map a DO_SET_SERVO command to any output you'd like, simply by setting a parameter on that output. More details to come soon! |
@JacobCrabill sounds cool! Keep me updated as soon as you have details/a PR 😄 |
It's still very much a WIP, but see here for how to control up to 8 arbitrary actuators via DO_SET_SERVO: #16808 |
@coderkalyan I expect the more general approach to take more time, so I would like to get this here in for 1.12. Please disregard my earlier comments regarding the control groups, I would keep this as-is at it seems like a good solution for 1.12. But could you please take note of the comment from @dayjaby regarding the command handling? His PR is indeed pretty good and should be included: |
Closing in favor of #16808 |
@mrpollo This should not have been closed without the alternative being actually merged. I'm merging this now. @dagar @JacobCrabill we need to make sure to not impair the usage of PX4 by trying to do the right thing. This has been going on as a pattern, effectively pushing away users because it leads to six-month long delays where people can't use the project. |
@LorenzMeier thanks for merge, over the last developer call we decided to close it in favor of #16808, at the time it seemed ready to be merged. |
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/using-do-set-actuator-to-releasing-the-payload/28686/5 |
Adds support for using the MAVLink command MAV_CMD_DO_SET_ACTUATOR to
update the actuator values on control group 3 aux{1, 2, 3}. A simple
deconfliction with rc_update is implemented: when a MAVLink command is
sent, RC is disabled for that channel until a major stick movement is
detected.
Closes what was attempted in #10320 and #15281.
The following MAVSDK script can be used to test (minor modification might be necessary based on your setup):