-
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
Make DO_SET_SERVO work #10320
Make DO_SET_SERVO work #10320
Conversation
@4ert We need to separate the different actuator groups for good to make this easier. Could you join the PX4 dev call this week? |
|
Made a flight, the log is here: https://logs.px4.io/plot_app?log=8fb644ab-1fe4-449a-9b0f-c4656fdae029#Nav-Actuator-Outputs-AUX
|
@LorenzMeier my speaking english is not very good but I could try to join the devcall |
b6e11e3
to
4faedd1
Compare
4faedd1
to
9a86f38
Compare
@kpetrykin I'm currently trying to get this to work I've used your commit. So I have my Pixhawk connected to a servo and I'm trying to get the servo to move within the mavproxy shell by running servo set 1 1000. However the message I keep getting back is that the command was acknowledged but is unrecognised (result:3) . I can get the servo moving using nuttx shell, but I really want to be able to send a mavlink command to set the servo pwm is there any way of doing this? |
@MaithaM1 It looks like the MAV_CMD_DO_SET_SERVO is set in missions and handled here: I can't find the message being handled outside of missions. While that does not mean it isn't, the fact that you're getting "unrecognised" is indicative. There is quite a bit of discussion above about this. @dagar did the devcall come to any conclusions? Is there a short term recommendation on how people should approach this? |
@dagar regarding #10320 (comment) (your questions) there are some good points there. Below are "in my opinion".
Shouldn't this be defined at the MAVLink/message level by a convention? How about 1-n are the MAIN outputs as labeled on board, and n upwards are the AUX ports, if present?
IMO things screw up - it is up to the user of this tool to manage contention. See real use case below. Do we actually manage contention otherwise? ie does the system check that we don't have multiple control group inputs assigned to the same output?
The real use case is probably the hardware we haven't thought about. Someone has some magic hardware that they want to drive, and a free port. They just want to be able to plug in that hardware and send it a command via MAVLink. They don't want to care about mixers. They are happy to manage contention themselves - ie they know that nothing else is connected to the port, and if they screw up they screw up.
We currently have First Payload which is just a parachute. Yes we should probably define something for a gripper. Not sure it will address the above use case. I've read http://dev.px4.io/en/concept/mixing.html and I am not 100% confident that my understanding of how these work is complete. I think that control groups are implemented as UORB topics that something can set (ie a controller). A mixer defines what actuators are set and their values based on these inputs. So essentially you create a control group so that you can arbitrarily map a specific type of command to a physical output. For example to use a parachute you write a handler for it in MAVLink that sets the appropriate control group UORB topic. "Something" in the architecture then takes the mapping in the mixer file and based on that topic input sets the appropriate PWM output. Is that about right? This is good because your system does not need to know what plugs into the output to implement a parachute or gripper (say). But it does mean that you need a mixer. Question: Are mixer's additive? Ie I have an airframe which uses the main outputs. I add a parachute. Do I need a completely new mixer file, or can I add my mixer just for my parachute? You could implement this as a servo control group(s). But would be better if the mapping was transparent (ie no specific mixer required). |
@MaithaM1 this PR is generally about mission's DO_SET_SERVO command. |
@kpetrykin Thanks for getting back to me. I want to simply change pwm output from a script. |
@MaithaM1 so what is your goal of using servo? What you try to do with this? |
@kpetrykin I would like run certain tests to change servo positions, its a static test so nothings flying. I just want the ability to set servos to specific angles and motors to specific speeds within a python script. I don't intend to use it for flying. Its just for testing. Sending MAV_CMD_DO_SET_SERVO using pymavlink! |
So, @dagar, @LorenzMeier - what's with this PR? What could i do to improve it? |
Hey @kpetrykin Can you share your mixer that you are using for the AUX channel? I'm trying to follow yur route but cannot make the mixer properly maybe. |
@tubeme, sure, it's simple:
To make it work:
|
So, @tubeme, did you get the mixer to work? |
@kpetrykin How to make it work, bro? |
Is there any new update? |
@GaoGeolone what have you done already? |
@kpetrykin I think I have already make it work, thank you~I just want to trigger my servo at a certain position. And by making a change to the AUXMIXER pass file , as well as modifying the Formula in Mission_block.cpp. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @kpetrykin , I want to follow what you have done the flight for example takeoff, go to a waypoint and drop a cargo. Now, I am trying to follow and write a same mixer that you provide. But there are some questions that I want to ask: Q1) Why do we create a "extrats.txt" file with a command line "mixer load /dev/pwm_output1 /fs/microsd/etc/mixers/pass.aux.mix" ? Sorry for asking these silly questions. Thanks. |
@JamesChooWK The Extras.txt is documented here: https://dev.px4.io/master/en/concept/system_startup.html#customizing-the-system-startup It is used for system startup customisations - basically you're adding the mixer at runtime rather than as part of the firmware build. This is much easier for examples, testing, and when you're doing something that only applies to your setup. You can copy the files onto the card using whatever mechanism you like - ie File explorer on windows. The files need to be present on the SD card before booting PX4. Again, they are not part of firmware, but are loaded as though they were. |
@bkueng Who would I have to kill to get an implementation of this on your job queue? Yet another query on how to do this on slack today. |
@hamishwillee I'd be willing to take a look at this if someone could give me a couple pointers as to what needs to be done! |
Ok, I'm going to create a new PR that just maps the servo instance number from DO_SET_SERVO to actuator_group_6. It will still require the mixer to be setup as shown in https://dev.px4.io/master/en/concept/custom_mixer_payload.html, so there isn't any bypassing mixer or related weird junk. |
@coderkalyan I'm going to connect you do Beat. Wait before starting. Just composing my thoughts. . |
@bkueng We have a volunteer to work on this ^^^ @coderkalyan . Can you outline the solution you propose for this - or would it be best for you guys to set up a meeting or discuss in the dev call? The architectural issue you raised above is that MAV_CMD_DO_SET_SERVO isn't really fit for purpose. This has two fields, and two problems:
We can make a best effort to clarify that message better - e.g. we could state that that instance values of 1-8 map to MAIN and 9-16 map to AUX. UAVCAN not supported. Ultimately though, we should probably create a new message. Any thoughts on how we would do that? I'd be tempted by
|
@hamishwillee @bkueng I agree that a new message would be far less ambiguous, and allow a more flexible method of control. Maybe something on the lines of MAV_CMD_DO_SET_ACTUATOR or such, since this applies not just to servos but to generic auxiliary actuators (anything thats not part of main flight control and is not already part of its own setup, like gimbal). Just a few considerations that I'm bringing to the table:
Side note: I am actually quite interested in being able to use UAVCAN to control my actuators. It didn't come to mind before @hamishwillee brought it up, but in my use case, even with a PWM value (which is currently mapped to a mixer connected to an RC controller) I have another microcontroller on the receiving end which is reading the PWM values and deciding what to do, so UAVCAN seems like a good choice. I haven't used UAVCAN before though, so any clarification/pointers on how this would work are appreciated! |
@coderkalyan I'm keeping quite until @bkueng has a chance to talk. My 2 bits though:
|
Awesome, thanks @coderkalyan. I imagine something like this:
You're limited to 3 channels, but I think that is enough for the majority of the use-cases. Also I think if you need more advanced logic, you're better off adding some code to handle that specifically. Let me know if you have questions, you can also ping me on slack directly. |
Thanks for the clarification @bkueng! Seems reasonable, I'll get to work. |
Hi @coderkalyan , |
@hamishwillee It was brought to my attention that my PR for DO_SET_SERVO was in conflict with another open PR that @dayjaby is working on. However I haven't had a chance to look at what exactly is conflicting and sort that out yet. |
Thanks. I hope you can resolve this with @dayjaby and move forward! |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
Thanks for your earlier contribution. Unfortunately as the project has overall evolved quite a bit, this change doesn't apply any more. Closing stale pull requests like this one is part of us working aggressively to bring down the PR review time so that we will be able to merge or reject PRs in the future in a much more timely fashion. |
FYI @kpetrykin #16758 should cover the same intention as this PR. |
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/3 |
@kpetrykin @hamishwillee @bkueng |
@ahmedfarouk99 YOu have necrobumped an old closed issue. I don't look at those. If you have a technical support issue, ask on the support forums. If you have a bug, raise your own bug report. You should try MAV_CMD_DO_SET_ACTUATOR instead though, it works. |
Hello!
My goal was to make the mission command DO_SET_SERVO working with the possibility of triggering the servo with RC switch.
First, I have found that "vmount" module (when enabled) publishes its values to actuator_controls_2 topic all the time. This overwrites all other publications to this topic. That is why DO_SET_SERVO is not working.
I modified "vmount" module so that it would publish only if one of the actuator values were changed by RC. In other cases it stays silent.
Second, I have found that the formula, which translates PWM value from DO_SET_SERVO command parameters to -1..1 range for uORB, does not match the one which translates it back.
Original formula:
actuators.control[(int)item.params[0]] = 1.0f / 2000 * -item.params[1];
Formula, which translates value back:
effective_pwm[i] = control_value * (max_pwm[i] - min_pwm[i]) / 2 + (max_pwm[i] + min_pwm[i]) / 2;
New formula:
actuators.control[(int)item.params[0]] = (float)(((float)item.params[1] - (PWM_DEFAULT_MAX + PWM_DEFAULT_MIN) / 2)/((PWM_DEFAULT_MAX - PWM_DEFAULT_MIN) / 2));
I need to discuss two questions about the formula:
(int)item.params[0]
I have tested everything with 1.7.3 Firmvare (px4fmu-v2_default), but did not save the flight log.
I will test the last master in a few days.