PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

improve cyphal esc

Open PonomarevDA opened this issue 2 years ago • 4 comments

Solved Problem

This PR includes Cyphal ESC improvements and some fixes to simplify configuration with Yukon. It is based on notes mentioned in the forum and in the previous Cyphal PR.

I've started with a draft PR, so you can track the progress and give a earlier feedback.

  • [x] Fix setpoint wrong scale. it is from 0 to 8192, but it should be from 0 to 1.0.
  • [x] Use actual time instead of transfer id in uptime field of heartbeat. Now the time is reset every 256 seconds.
  • [x] Add port.list.
  • [x] Add *type registers.
  • [x] Add ESC feedback. I am thinking of starting with zubax.telega.CompactFeedback.0.1.
  • [x] Separate setpoint and readiness (now these 2 topics are related to a single register, which is not what we expect on the Yukon side).
  • [x] Optimize the setpoint. Now we always send 31 commands, which is not efficient for a simple quadcopter case. We should only send as many commands as we actually use, because the zero implicit rule allows that. I'm currently looking at the hack in RawCommand.

Test coverage

I will attach it when it is ready.

PonomarevDA avatar Apr 14 '23 15:04 PonomarevDA

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/zubax-myxa-and-cyphal-integration/31404/6

DronecodeBot avatar Apr 14 '23 16:04 DronecodeBot

I'll take a closer look as this develops, but so far looks good.

dagar avatar May 01 '23 01:05 dagar

Done.

Few notes

The implementation supports up to 8 ESC feedbacks because of the EscStatus.msg limitation. So we have 8 identifier and 8 type registers for this feature. I've opened the RFC that may add a way to significantly reduce the number of registers, but it may have drawbacks, so it should be carefully considered. If you are here, it might be interesting to check this proposal.

I estimate the number of ESC for esc_status message by the number of feedback subscriptions. Please, check if this logic is wrong.

The port.List implementation is based purely on nanuvut output. It consumes a lot of RAM because it allocates an array of the maximum possible size (8466 bytes). Since we know exactly the maximum number of publishers and subscribers, it may be possible to optimize it significantly manually.

Test coverage

I tried all features in Yukon and Yakut including ESC feedback boundary cases (-409.6,+409.4 ampere, -39114, +39104 rpm, etc). Below you can see a screenshot from Yukon. It actually illustrate what should be configured from the PX4 Cyphal side.

image

Here is mavlink console output: image

I tried this branch with a real devices (Myxa ESC and MN805-S KV170) using Actuator Panels in QGC. I configured Myxa in Ratiometric voltage control mode. The yakut screen with PX4 and Myxa is shown below:

image

I also tried this with the Cyphal HITL simulator (this branch + few Cyphal sensors).

QGC in HITL branch is shown below: image

The flight log in the simulator: https://review.px4.io/plot_app?log=87b148a5-2441-4a96-ac8d-47ed9823d569

PonomarevDA avatar May 17 '23 06:05 PonomarevDA

Field Tests

Hi, I have tried this branch (+ gnss mag baro: link) with my custom drone. Here are the results including flight logs and videos.

Here is my setup:

drawing

Is there any information on when this branch will be merged?

I can provide any tests or flights on my own drone on request.

olegogogo avatar May 22 '24 04:05 olegogogo

@dagar is there any hope getting this looked at?

pavel-kirienko avatar Jul 03 '24 11:07 pavel-kirienko

Sorry, I wasn't in a position to test this, but at a glance the change looks fine. I'll rebase and bring it into main.

Thanks everyone.

dagar avatar Jul 03 '24 17:07 dagar