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

Swift UAVCAN servo actuation #12984

Closed
wants to merge 19 commits into from
Closed

Swift UAVCAN servo actuation #12984

wants to merge 19 commits into from

Conversation

m1kelyons
Copy link

@m1kelyons m1kelyons commented Sep 18, 2019

This allows airframes that use a combination of UAVCAN ESCs and UAVCAN servo motors to be configured, scaled, and trimmed via PX4 parameters by allowing the aux mixer to be mapped to either PWM outputs or to UAVCAN outputs. If mapped to UAVCAN outputs, the firmware in this PR enables mapping of each aux mixer channel to any combination of UAVCAN ESCs and/or UAVCAN servo motors (actuators) on a channel by channel basis.

Test data / coverage
The firmware in this PR has been tested both on a HIL setup and on the Swift Engineering 021_trailsitter airframe. Both the HIL setup and the 021 tailsitter airframe use adapter PCBs that convert UAVCAN actuator commands to RS485 to drive Dynamixel RS485 smart servo motors. The servo motors are used to control elevon deflection.

Validation:

The mapping of the aux mixer to PWM outputs or UAVCAN outputs is controlled by the UAVCAN_ENABLE parameter.

A new UAVCAN servo class takes an actuator ID and a value between -1.0 and 1.0 for normalized deflection. The new UAVCAN_TRIMx and UAVCAN_SCALEx PX4 paramaters are applied to this value and the value is published as a UAVCAN message using the actuator.ArrayCommand. The actuator_id field is assigned based on the position in the aux mixer.

The UavcanNode::run() method uses the parameters UAVCAN_MAP_CHx to determine where to map a particular channel of the aux mixer. ESC mixer channels are mapped to the UAVCAN ESC publisher and control surface channels are mapped to the UAVCAN servo publisher. In addition, the UAVCAN_MAP_CHx parameters can be used to disable an aux mixer channel. If the airframe uses UAVCAN servo motors, but no UAVCAN ESCs, the new logic in the UavcanNode::run() method detects this and disables the UAVCAN ESC publisher. This prevents filling UAVCAN bus bandwidth unnecessarily.

@dagar
Copy link
Member

dagar commented Sep 18, 2019

Awesome!

@dagar dagar self-requested a review September 18, 2019 14:21
@dagar dagar requested a review from davids5 September 18, 2019 15:30
@m1kelyons
Copy link
Author

All checks were passed before last master merge. [px4.rosunit-pub_test/test_hz] [FAILURE]
no messages before timeout. Any suggestions?

@dagar
Copy link
Member

dagar commented Sep 22, 2019

@PX4/testflights do you currently have a UAVCAN test vehicle?

@Tony3dr
Copy link

Tony3dr commented Sep 27, 2019

@dagar we tried with this PR but the vehicle does not arm, we get a message that one or more ESC's are not online. It doesn't detect them. We tried it with Master and vehicle arms and flies fine.
WhatsApp Image 2019-09-27 at 1 49 40 PM
Log:
https://review.px4.io/plot_app?log=f187bbca-715d-4ede-9853-6bb5e794cca3

@Tony3dr
Copy link

Tony3dr commented Jan 9, 2020

@Tony3dr, can you give us some details on your setup. F450 frame, but which ESCs, FCU, etc.? I'd like to replicate this on the bench. @KSP-Kirby, we should rebase on our "free" time.

@m1kelyons m1kelyons
Pixhawk 4 UAV CAN Setup
Frame: DJI F450
Type: Multirotor
Diagonal Wheelbase: 450mm
Flight Controller: Pixhawk 4(Holybro)
GPS: Zubax GNSS 2
Motors: T Motor 2212-920kv
Receiver: FrSky D4R-II 2.4G 4CH ACCST Telemetry Receiver
Telemetry: Holibro Telemetry, 100mW Telemetry Radio V3 915MHz
ESC: Zubax Myxa
Battery: 3S 5200mAh(Hobbyking)
74709217_512776159301517_7728513333816459264_n (1)
75266220_423019898391358_3783246187771985920_n (1)
75220685_973077466394332_7900273890641838080_n (1)

@frontw
Copy link

frontw commented Mar 28, 2020

Hi!
Why this request is not approved?
Is there another way to use UAVCAN servos or another plan on this?

@stale
Copy link

stale bot commented Jun 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Jun 26, 2020
@TSC21
Copy link
Member

TSC21 commented Jun 26, 2020

We should try to keep this alive. @dagar

@stale stale bot removed the stale label Jun 26, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Oct 4, 2020
@Etruscian
Copy link
Contributor

What is the status of this pr? I'm also very interested in being able to use UAVCAN servos!

@stale stale bot removed the stale label Oct 5, 2020
@dagar
Copy link
Member

dagar commented Oct 5, 2020

What is the status of this pr? I'm also very interested in being able to use UAVCAN servos!

It needs to be rebased and tested. The per actuator configuration (and mixing) is where things got a little sidetracked last time.

Do you have UAVCAN servos? Which model?

@Etruscian
Copy link
Contributor

I do have UAVCAN capable servos available. I currently have the HITEC MD950TW-CAN and pixhawk 2 to test with. I was looking into how the ESC is implemented to see if I could adapt that to work with the servos before I found this pull request. Given all the changes done to the mixing in the mean time, it might almost be worth it to start over while taking this PR as heavy inspiration, but that is just a gut feeling.

@RicardoM17
Copy link
Contributor

We should be getting some UAVCAN servos soon so I'll try to find the bandwidth to take this for a spin. We have this in our roadmap but not necessarily short term but if we can get this working and merged sooner, the better. :)

@max11gen
Copy link

max11gen commented Jan 21, 2021

Sometimes the PX4 documentation is really confusing me. As far as I understand this PX4 does already support controlling Servos via UAVCAN. But the fact that this pull request exists and is not yet merged makes me believe that it is not yet possible. Can you shed some light into my dark here, @TSC21, @dagar ?

@RicardoM17
Copy link
Contributor

RicardoM17 commented Jan 21, 2021

Sometimes the PX4 documentation is really confusing me. As far as I understand t

PX4 supports UAVCAN ESCs, not Servos. I believe it is quite clear from that documentation page no?

I guess this

UAVCAN ESCs have a number of advantages over PWM ESCs and Servos:

is not 100% clear and could be

UAVCAN ESCs have a number of advantages over PWM ESCs

but other than that there's no other mention of servos in that page. Where else did you get that idea from, so that we can correct it.

EDIT: Perhaps it is more clear with PX4/PX4-user_guide#1007

@max11gen
Copy link

max11gen commented Jan 21, 2021

@RicardoM17 Obrigado pela sua resposta!

Yes, exactly the sentence you quoted was one of the things, that made me believe that it works with actuators as well. Another thing is further down in the article there is a mention of UC4H's esc_actuator_node. This also makes it sound like it can be used for servos, too.
However, even more importantly, when you go to this section https://docs.px4.io/master/en/concept/mixing.html#control-pipeline it's clearly written, that the MAIN outputs can be published/accessed on any output driver explicitly mentioning UAVCAN without any constraints. And I can't remember exactly where, but I'm pretty sure, that I have read the same thing elsewhere, too.

Regardless of all this confusion: Did you already make any progress on this topic? As you mentioned before that you were going to test/work on it?

EDIT: Your edit of the doc indeed makes it a lot more clear. Thanks.

@RicardoM17
Copy link
Contributor

Regardless of all this confusion: Did you already make any progress on this topic? As you mentioned before that you were going to test/work on it?

@max11gen

Not yet. The servo that I can use will be bought this week still. So I'm hoping to start with this next week, or worst case in two weeks I should be firing this.

I've already started the rebase to get ahead of things. It was quite straightforward apart from the changes in uavcan_main.cpp which has changed a lot in the meantime and I still haven't found where things went or if I should still replicate the logic somewhere there. That's where I feel I might struggle for a bit. Perhaps @dagar you can give me some pointers here?

@max11gen
Copy link

max11gen commented Jan 21, 2021

@RicardoM17 Allright, this sounds good. If you need a collaborator feel free to contact me. I'd be willing to help you in your endeavors. I'm not sure if I can be much of a help since I am not yet very experienced with the whole PX4 stack, but I'd give it my best

@RicardoM17
Copy link
Contributor

Thanks @max11gen I'll take that into account. Do you have any UAVCAN servos to test with? And if so what model?

Let me know also if you are on the PX4 Slack as I might reach out to you there to coordinate.

@max11gen
Copy link

max11gen commented Jan 22, 2021

@RicardoM17 No, unfortunately I don't. I am planning to use NXP UCANS32K146 as a UAVCAN node and have them control my servos. Alternatively, I was considering to use Arduinos and build the UAVCAN nodes myself based on 107-Arduino-UAVCAN. The servos I have are FUTABA HPS A700 Air Servos.

I am on slack. However, I just registered there at some point and haven't used it since.

@hamishwillee
Copy link
Contributor

Thanks @RicardoM17 for updating the docs to reflect that servos not yet supported. When this goes in, can someone please remove that note in http://docs.px4.io/master/en/peripherals/uavcan_escs.html#uavcan-escs-motor-controllers - or raise an issue in the docs repo.

@RicardoM17
Copy link
Contributor

Hi @hamishwillee I will make sure to mention that in the coming PR, or I'll track it down if someone else ends up doing it.

@rligocki
Copy link

rligocki commented Feb 8, 2021

What is current blocker to implement UAVCAN servos? Few months ago I get one sample of MD245MW-UAVCAN for testing. These servos listen to uavcan.equipment.actuator.ArrayCommand. I was thinking, that it would be easy to made support for UAVCAN servos by sending uavcan.equipment.actuator.ArrayCommand with same payload as uavcan.equipment.esc.RawCommand message. uavcan.equipment.esc.RawCommand payload is created based on ESC enumeration in QGC or autopilot mixer?

I don't know if I will be able to help with code, but I can offer my time to test any implementation.

@RicardoM17
Copy link
Contributor

What is current blocker to implement UAVCAN servos? Few months ago I get one sample of MD245MW-UAVCAN for testing. These servos listen to uavcan.equipment.actuator.ArrayCommand. I was thinking, that it would be easy to made support for UAVCAN servos by sending uavcan.equipment.actuator.ArrayCommand with same payload as uavcan.equipment.esc.RawCommand message. uavcan.equipment.esc.RawCommand payload is created based on ESC enumeration in QGC or autopilot mixer?

I don't know if I will be able to help with code, but I can offer my time to test any implementation.

hi @rligocki. The current blocker is people to work on this issue. I intend to do this task but there has been some setbacks when it comes to ordering the servos at my company so I haven't started. Hopefully within this week and the next there will be some progress.

I already rebased most of this PR so I hope that it won't take too long to get this in a testable state but let's see. If that happens I'll make sure to ping you for testing but like I said I can't progress much until I have a servo I can use.

@dagar dagar deleted the branch PX4:master June 27, 2022 14:40
@dagar dagar closed this Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.