Skip to content

Conversation

@PavelOlhovikov
Copy link

Summary

Add support for Hobbywing ESC control via UAVCAN with configurable ESC type parameter

Problem Description

Currently, PX4 lacks support for Hobbywing ESCs in UAVCAN ESC control configuration. Issue #24176 identifies the need for adding this ESC type to expand UAVCAN ESC compatibility.

- add hobbywing esc control
- add parametr UAVCAN_ESC_TYPE

Closes PX4#24176
@PavelOlhovikov PavelOlhovikov changed the title feature: feature: Add support for Hobbywing ESC Dec 17, 2025
Copy link
Contributor

@dakejahl dakejahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you break this out into its own file to keep a clean separation. You can check the UAVCAN_ESC_TYPE in uavcan_main.cpp. Also put it behind a KConfig option so we can selectively enable it (default to enabled).

@PavelOlhovikov
Copy link
Author

PavelOlhovikov commented Dec 20, 2025

Can you break this out into its own file to keep a clean separation. You can check the UAVCAN_ESC_TYPE in uavcan_main.cpp. Also put it behind a KConfig option so we can selectively enable it (default to enabled).

Yes, okay, let me know what is the right way and how you want me to do it correctly,When creating my module, I received a duplicate esc_status. Explain how to do it correctly and I will do it without any problems. I have two types of motors, Hobbywing X6 and X9, to actually use them. And what do you think about checking the subscription to all types of messages?

Copy link
Contributor

@dakejahl dakejahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a link to the HobbyWing DroneCAN spec? It's not clear to me how we determine the esc_index from these messages.


uint8_t _rotor_count{0};

int32_t _esc_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int32_t _esc_type;
EscInterfaceType _esc_type {};

Let's make this an enum

UavcanEscController::esc_status_msg2_cb(const uavcan::ReceivedDataStructure<com::hobbywing::esc::StatusMsg2> &msg)
{
if (msg.getSrcNodeID().get() < esc_status_s::CONNECTED_ESC_MAX) {
auto &ref = _esc_status.esc[msg.getSrcNodeID().get() - 1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work. The esc_status_s.esc is length 8. Node ID's are typically in the 120s.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I set ESC#1 NodeID = 1, ESC#2 NodeID = 2. If there is a better solution, I will be happy to consider it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ESCs must report from which ESC the data is originating, otherwise mapping to the array correctly is impossible. Let's see what the Hobbywing spec sheet tells us

ref.esc_address = msg.getSrcNodeID().get();
ref.esc_voltage = msg.input_voltage / 10;
ref.esc_current = msg.current;
ref.esc_temperature = (float)msg.temperature / 100; // In the Mavlink system, the temperature is multiplied by 100.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ref.esc_temperature = (float)msg.temperature / 100; // In the Mavlink system, the temperature is multiplied by 100.
ref.esc_temperature = msg.temperature

Both of these fields are degC. Please re-review the message definitions.

_esc_status.counter += 1;
_esc_status.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_CAN;
_esc_status.esc_online_flags = check_escs_status();
_esc_status.esc_armed_flags = (1 << _rotor_count) - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

armed status can't be known? It's not encoded in StatusMsg1.status?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm waiting for a response from Hobbywing support. I don't have a hobbywing message specification


uint8_t _rotor_count{0};

int32_t _esc_type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int32_t _esc_type;
EscInterfaceType _esc_type {};

Let's make this an enum

@PavelOlhovikov
Copy link
Author

I only added controls and display to QGC

@hamishwillee
Copy link
Contributor

FWIW when this goes in consider an update to ESC docs. At least the table in https://docs.px4.io/main/en/peripherals/esc_motors#supported-esc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants