-
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
Direct Motor Control Access #10863
Direct Motor Control Access #10863
Conversation
style check failed, please run a |
src/drivers/px4fmu/fmu.cpp
Outdated
@@ -63,6 +63,9 @@ | |||
#include <uORB/topics/multirotor_motor_limits.h> | |||
#include <uORB/topics/parameter_update.h> | |||
#include <uORB/topics/safety.h> | |||
#include <uORB/topics/vehicle_control_mode.h> | |||
#include <uORB/topics/vehicle_command.h> | |||
#include <uORB/topics/vehicle_status.h> |
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.
@bresch let me know if it looks good, and if I should rebase it now :) Thanks in advance! |
The main thing I'd like to consider here is adding an alternate interface (uORB) message that carriers the motor commands rather than overloading actuator controls. If we do this right it could also enable QGC motor testing (https://mavlink.io/en/messages/common.html#MAV_CMD_DO_MOTOR_TEST). We already have a Thoughts? |
I like the idea of having direct motor control vs mixers+actuator control+wtv! I can look further on it. |
I think there will be a conflict in the Mavlink receiver. If you use the actuator_control to control the AUX (group_mlx = 3), as it is not 99, it will set |
How so? If you use another group mlx, then the information follows its usual path, and the fmu verification for the direct control mode is false, and therefore it does not overwrite anything. Keep in mind that ignore_mixed_outputs was created on this PR, and so it will not conflict with previous implementations. |
You will be willing to send both actuator_control messages at the same time (controlling motors and AUX). In such case, you'll send a group 99, then 3, then 99. After each message, the |
Sorry @AlexisTM , what do you mean as sending group 3 and group 99, alternately? If the offboard mode is set to control motors directly, why would this happen? I think I understood you! You mean if you still want to use the same topic to control aux AND motors, is that it? |
Yes, in the current status, if you want to use AUX and RawPWM, you will end up with switching Also, it is missing a timeout for |
Yep, I didn't had the timeout yet - so yes, it would stay true. unless you receive a message with it being false - or, set it to false everywhere else. However, as discussed yesterday, the way for this PR will be to separate motor control and actuator control into different things, so that such problems do not arise. I will come back to this soon. |
I just listened to the podcast, indeed, I would love to have a separate control to avoid that other modules mess with the PWMs. |
+1, any news on the PR? |
I am overloaded with other things at the moment, however feel free to fork this! |
HI @Pedro-Roque, I've encountered a few problems with your implementation. Maybe you could help me figure it out.
The expected behaviour would be, that my system (quadrotor) stays
So my question would be, is this even the supposed way of using your changes? Or is it supposed to work in PS: If you feel like, I should open a separate issue for that, I'm more than willing to do so. I just feel like my issue is better fitted in here, mostly as this code is not yet part of the PX4-repo. |
@JohannLange That is wierd. On my tests on simulator I didn't have that problem. Did you try simulating your build on SITL? If this is a quadrotor, wouldn't those inputs mess up your system? Why would like to set such motor speeds? Also, keep in mind this is WIP, so expect the unexpected. I will come back to this from next week onwards... |
@Pedro-Roque I haven't tried SITL yet, but using it via a PX4 app works as expected. |
@JohannLange I can check it out on a UAV next week, because so far I've been testing it on SITL only, so I don't have a lot more info for you. Anyways, this PR code will be changed according to what was discussed. |
@JohannLange a friend noticed that the Commander changes are missing here, so maybe that's why it does not work for you. I'll try to look at that later this week! |
@dagar @TSC21 I've been thinking more and more about this setpoint method, but after discussing with some friends we got to the conclusion that, to properly control the vehicle with motor velocities, we need a high control rate that should be above 100HZ (ideally at least 500). I wonder if we can have such rates through serial on MAVROS... If not - maybe an Ethernet extension for Pixhawk V6? 💃 |
You can get those rates but you would probably have to limit some other message streams. |
In that case, I will implement the feature anyways and then we discuss the best way to interface it |
The standard PWM output frequency is "only" 400 Hz. Thus, I don't think there is any reason to try and achieve 500 Hz or more as a control rate, as long as you don't change the PWM rate.
Keep in mind, that mavros runs at
With: Honestly, I don't know what that would mean in terms of the bandwidth used by MAVLink, but it shouldn't be much higher if it even would be... So keep in mind, Also, if anyone knows how to check the real bandwidth used by MAVLink, I am happy to test that as well. Edit: according to the parameter description of |
@JohannLange The problem is that if you want to do direct motor control offboard, then you also need to stream the IMUs and other relevant data at high frequencies - if you do all that and then still need o send motor control that (from a theoretical stand-point, might need high frequencies), then the bandwidth of the serial port might not be enough. Anyhow, this is something that we can assess more surely afterwards... |
@dagar I will start addressing this for the next days, will come back with news . |
Closing this and working on it on my fork: github.com/Pedro-Roque/Firmware/tree/motor-ctl . When it is ready, I will do a PR. |
Hi, is this feature still planned to be implemented ? |
Not until we get a really fast connection to the FMU, otherwise not worth it :( |
That's a limitation that I expected. Also, I prefer the low-level algorithms to be onto the Pixhawk itself for latency [and robustness] reasons. I expect a drone to be self-sufficient to fly and have an onboard computer only to add nice to have features. |
Not yet as I am not going to work with something like that any time soon. The thing of all low level being in Pixhawk is half true: in my lab people develop algorithms for low level control, so most of the times they want to access the motor speeds, but not necessarily want to implement in the stack - they rather have some interface for it. I am eager to get the hands on the v6 and see if we can do something with it :) |
Is it possible to help? |
Hello, Can we directly run your PWMOut sim code to real time hardware? If not what changes do we need to send the PWM commands to motors on hardware? Also, I need to customize the firmware according to this repo? Is there any tutorial on customization of firmware? |
Hi @Jawad-RoboLearn - this was developed a while ago, so I didn't test it in recent versions of PX4. However, running this without a high-frequency control over the system will give you problems. That's important to keep in mind. |
I would also advise to use the higher level control if your app is outside of the Pixhawk. (aka Offboard control) |
Thank you for your response. Yes I am trying to write a python based mixer
file to directly integrate with the body rate and thrust commands on MAVROS
topic. Thanks once again.
…On Wed, 24 Nov 2021 at 16:10, Alexis Paques ***@***.***> wrote:
I would also advise to use the higher level control if your app is outside
of the Pixhawk. (aka Offboard control)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10863 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ2NPUVQLFHQCYCU5SKNWILUNSMXDANCNFSM4GEZBXBA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Please use PX4 Discuss or Slack to align on pull requests if necessary.
Test data / coverage
Tested with SITL, video shown below:
https://drive.google.com/open?id=1ojMMRyiiii7A6pIMROro7hTnzVVwQ9em
I can provide logs (is it possible to take them from SITL?)
Describe problem solved by the proposed pull request
This PR enables direct pwm control of the motors by bypassing the mixer results. A control mode flag is set when mavros ActuatorControl->group_mix = 99 (this shall be changed by something more convenient, maybe a change on the message definition to add a constant for that. This control flag is verified at the FMU level (and on PWMSim for the simulation part), and if true, then the actuator_controls from the mixer are overridden. This happens before the safety constraints, so the user inputs still go through them to make sure they are bounded and within the usual limits.
This is a desired feature from the Automatic Control standpoint, as there is the need to have a very low-level control on the vehicle. This solution also does not interfere with any other modules or safety measures/routines.
Minor: fixed a small leak on the FMU, where the _adc_sub was not being unsubscribed at the destructor.
Describe your preferred solution
Proposed solution.
Describe possible alternatives
Additional context