44 #define MOTOR_BIT(x) (1<<(x)) 50 _uavcan_pub_raw_cmd(node),
51 _uavcan_sub_status(node),
68 PX4_ERR(
"ESC status sub failed %i", res);
82 if (num_outputs > uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize) {
83 num_outputs = uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize;
86 if (num_outputs > esc_status_s::CONNECTED_ESC_MAX) {
87 num_outputs = esc_status_s::CONNECTED_ESC_MAX;
93 const auto timestamp =
_node.getMonotonicTime();
105 uavcan::equipment::esc::RawCommand
msg;
107 for (
unsigned i = 0; i < num_outputs; i++) {
109 msg.cmd.push_back(static_cast<unsigned>(0));
112 msg.cmd.push_back(static_cast<int>(outputs[i]));
127 if (msg.cmd[index] != 0) {
145 if (msg.esc_index < esc_status_s::CONNECTED_ESC_MAX) {
150 ref.esc_voltage = msg.voltage;
151 ref.esc_current = msg.current;
152 ref.esc_temperature = msg.temperature;
153 ref.esc_rpm = msg.rpm;
154 ref.esc_errorcount = msg.error_count;
173 int esc_status_flags = 0;
176 for (
int index = 0; index < esc_status_s::CONNECTED_ESC_MAX; index++) {
179 esc_status_flags |= (1 << index);
184 return esc_status_flags;
uavcan::MonotonicTime _prev_cmd_pub
rate limiting
struct esc_report_s esc[8]
uavcan::MethodBinder< UavcanEscController *, void(UavcanEscController::*)(const uavcan::ReceivedDataStructure< uavcan::equipment::esc::Status > &)> StatusCbBinder
UavcanEscController(uavcan::INode &node)
uint8_t esc_connectiontype
UAVCAN <–> ORB bridge for ESC messages: uavcan.equipment.esc.RawCommand uavcan.equipment.esc.RPMCommand uavcan.equipment.esc.Status.
uORB::PublicationMulti< esc_status_s > _esc_status_pub
uavcan::Publisher< uavcan::equipment::esc::RawCommand > _uavcan_pub_raw_cmd
High-resolution timer with callouts and timekeeping.
static constexpr int MAX_ACTUATORS
uint8_t check_escs_status()
Checks all the ESCs freshness based on timestamp, if an ESC exceeds the timeout then is flagged offli...
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
void esc_status_sub_cb(const uavcan::ReceivedDataStructure< uavcan::equipment::esc::Status > &msg)
ESC status message reception will be reported via this callback.
static constexpr unsigned MAX_RATE_HZ
XXX make this configurable.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
uavcan::TimerEventForwarder< TimerCbBinder > _orb_timer
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
uavcan::Subscriber< uavcan::equipment::esc::Status, StatusCbBinder > _uavcan_sub_status
static constexpr uint16_t DISARMED_OUTPUT_VALUE
void update_outputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], unsigned num_outputs)
static constexpr unsigned UAVCAN_COMMAND_TRANSFER_PRIORITY
0..31, inclusive, 0 - highest, 31 - lowest
void orb_pub_timer_cb(const uavcan::TimerEvent &event)
ESC status will be published to ORB from this callback (fixed rate).
bool publish(const T &data)
Publish the struct.
static constexpr unsigned ESC_STATUS_UPDATE_RATE_HZ
uint8_t _max_number_of_nonzero_outputs
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
uavcan::MethodBinder< UavcanEscController *, void(UavcanEscController::*)(const uavcan::TimerEvent &)> TimerCbBinder