-
Notifications
You must be signed in to change notification settings - Fork 14.9k
feature: Add support for Hobbywing ESC #26137
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
base: main
Are you sure you want to change the base?
feature: Add support for Hobbywing ESC #26137
Conversation
dakejahl
left a comment
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.
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? |
dakejahl
left a comment
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.
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; |
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.
| 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]; |
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.
This won't work. The esc_status_s.esc is length 8. Node ID's are typically in the 120s.
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.
Yes, I set ESC#1 NodeID = 1, ESC#2 NodeID = 2. If there is a better solution, I will be happy to consider it.
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.
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. |
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.
| 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; |
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.
armed status can't be known? It's not encoded in StatusMsg1.status?
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.
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; |
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.
| int32_t _esc_type; | |
| EscInterfaceType _esc_type {}; |
Let's make this an enum
|
I only added controls and display to QGC |
|
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 |
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.