-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Add Support for DroneCAN Status Extended Message #23896
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
uint64 timestamp # time since system start (microseconds) | ||
|
||
uint8 CONNECTED_ESC_MAX = 8 # The number of ESCs supported. To be consistent with ESC Status, limit it to 8. | ||
|
||
DronecanEscStatusExtendedData[8] extended_esc_status_data # An array of up to CONNECTED_ESC_MAX DronecanEscStatusExtendedData instances | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
uint64 timestamp # time since system start (microseconds) | ||
|
||
# From the StatusExtended.uavcan message | ||
uint8 input_percent # Input command to ESC, in percent, which is commanded using the setpoint messages. Range 0% to 100%. | ||
uint8 output_percent # Output command from ESC to motor, in percent. Range 0% to 100%. | ||
int16 motor_temperature_deg_c # Temperature of connected motor, in Celsius. Range is -256 to +255 C. | ||
uint16 motor_angle # Measured angle of connected angle sensor, in degrees. Range is 0 to 360. | ||
uint32 status_flags # Manufacturer-specific status flags currently active. | ||
uint8 esc_index # Index of currently reporting ESC. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename DronecanEscStatusExtended.msg |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,12 +47,14 @@ | |
#include <uavcan/uavcan.hpp> | ||
#include <uavcan/equipment/esc/RawCommand.hpp> | ||
#include <uavcan/equipment/esc/Status.hpp> | ||
#include <uavcan/equipment/esc/StatusExtended.hpp> | ||
#include <lib/perf/perf_counter.h> | ||
#include <uORB/PublicationMulti.hpp> | ||
#include <uORB/topics/actuator_outputs.h> | ||
#include <uORB/topics/esc_status.h> | ||
#include <drivers/drv_hrt.h> | ||
#include <lib/mixer_module/mixer_module.hpp> | ||
#include <uORB/topics/dronecan_esc_status_extended.h> | ||
|
||
class UavcanEscController | ||
{ | ||
|
@@ -86,6 +88,12 @@ class UavcanEscController | |
*/ | ||
void esc_status_sub_cb(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::Status> &msg); | ||
|
||
/** | ||
* ESC status extended message reception will be reported via this callback. | ||
*/ | ||
void esc_status_extended_sub_cb(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::StatusExtended> | ||
&received_status_extended_msg); | ||
|
||
/** | ||
* Checks all the ESCs freshness based on timestamp, if an ESC exceeds the timeout then is flagged offline. | ||
*/ | ||
|
@@ -94,12 +102,18 @@ class UavcanEscController | |
typedef uavcan::MethodBinder<UavcanEscController *, | ||
void (UavcanEscController::*)(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::Status>&)> StatusCbBinder; | ||
|
||
typedef uavcan::MethodBinder<UavcanEscController *, | ||
void (UavcanEscController::*)(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::StatusExtended>&)> | ||
StatusExtendedCbBinder; | ||
|
||
typedef uavcan::MethodBinder<UavcanEscController *, | ||
void (UavcanEscController::*)(const uavcan::TimerEvent &)> TimerCbBinder; | ||
|
||
esc_status_s _esc_status{}; | ||
dronecan_esc_status_extended_s _status_extended{}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete |
||
|
||
uORB::PublicationMulti<esc_status_s> _esc_status_pub{ORB_ID(esc_status)}; | ||
uORB::Publication<dronecan_esc_status_extended_s> _status_extended_pub{ORB_ID(dronecan_esc_status_extended)}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change to PublicationMulti |
||
|
||
uint8_t _rotor_count{0}; | ||
|
||
|
@@ -110,6 +124,7 @@ class UavcanEscController | |
uavcan::INode &_node; | ||
uavcan::Publisher<uavcan::equipment::esc::RawCommand> _uavcan_pub_raw_cmd; | ||
uavcan::Subscriber<uavcan::equipment::esc::Status, StatusCbBinder> _uavcan_sub_status; | ||
uavcan::Subscriber<uavcan::equipment::esc::StatusExtended, StatusExtendedCbBinder> _uavcan_sub_status_extended; | ||
|
||
/* | ||
* ESC states | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ void LoggedTopics::add_default_topics() | |
add_topic("config_overrides"); | ||
add_topic("cpuload"); | ||
add_topic("distance_sensor_mode_change_request"); | ||
add_optional_topic("dronecan_esc_status_extended", 250); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. multi |
||
add_optional_topic("external_ins_attitude"); | ||
add_optional_topic("external_ins_global_position"); | ||
add_optional_topic("external_ins_local_position"); | ||
|
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.
remove this msg