diff --git a/libraries/AP_DroneCAN/AP_DroneCAN.cpp b/libraries/AP_DroneCAN/AP_DroneCAN.cpp index ffd411d4a2..ab97d496d7 100644 --- a/libraries/AP_DroneCAN/AP_DroneCAN.cpp +++ b/libraries/AP_DroneCAN/AP_DroneCAN.cpp @@ -113,7 +113,7 @@ const AP_Param::GroupInfo AP_DroneCAN::var_info[] = { // @Param: OPTION // @DisplayName: DroneCAN options // @Description: Option flags - // @Bitmask: 0:ClearDNADatabase,1:IgnoreDNANodeConflicts,2:EnableCanfd,3:IgnoreDNANodeUnhealthy,4:SendServoAsPWM,5:SendGNSS + // @Bitmask: 0:ClearDNADatabase,1:IgnoreDNANodeConflicts,2:EnableCanfd,3:IgnoreDNANodeUnhealthy,4:SendServoAsPWM,5:SendGNSS,6:UseHimarkServo // @User: Advanced AP_GROUPINFO("OPTION", 5, AP_DroneCAN, _options, 0), @@ -261,6 +261,9 @@ void AP_DroneCAN::init(uint8_t driver_index, bool enable_filters) esc_raw.set_timeout_ms(2); esc_raw.set_priority(CANARD_TRANSFER_PRIORITY_HIGH); + himark_out.set_timeout_ms(2); + himark_out.set_priority(CANARD_TRANSFER_PRIORITY_HIGH); + rgb_led.set_timeout_ms(20); rgb_led.set_priority(CANARD_TRANSFER_PRIORITY_LOW); @@ -347,7 +350,11 @@ void AP_DroneCAN::loop(void) const uint32_t servo_period_us = 1000000UL / unsigned(_servo_rate_hz.get()); if (now - _SRV_last_send_us >= servo_period_us) { _SRV_last_send_us = now; - SRV_send_actuator(); + if (option_is_set(Options::USE_HIMARK_SERVO)) { + SRV_send_himark(); + } else { + SRV_send_actuator(); + } sent_servos = true; for (uint8_t i = 0; i < DRONECAN_SRV_NUMBER; i++) { _SRV_conf[i].servo_pending = false; @@ -469,6 +476,38 @@ void AP_DroneCAN::SRV_send_actuator(void) } while (repeat_send); } +/* + Himark servo output. This uses com.himark.servo.ServoCmd packets + */ +void AP_DroneCAN::SRV_send_himark(void) +{ + WITH_SEMAPHORE(SRV_sem); + + // ServoCmd can hold maximum of 17 commands. First find the highest pending servo < 17 + int8_t highest_to_send = -1; + for (int8_t i = 16; i >= 0; i--) { + if (_SRV_conf[i].servo_pending && ((1U< arming_status{canard_iface}; Canard::Publisher rtcm_stream{canard_iface}; Canard::Publisher notify_state{canard_iface}; + Canard::Publisher himark_out{canard_iface}; #if AP_DRONECAN_SEND_GPS Canard::Publisher gnss_fix2{canard_iface}; @@ -322,6 +325,7 @@ private: void handle_actuator_status(const CanardRxTransfer& transfer, const uavcan_equipment_actuator_Status& msg); void handle_actuator_status_Volz(const CanardRxTransfer& transfer, const com_volz_servo_ActuatorStatus& msg); void handle_ESC_status(const CanardRxTransfer& transfer, const uavcan_equipment_esc_Status& msg); + void handle_himark_servoinfo(const CanardRxTransfer& transfer, const com_himark_servo_ServoInfo &msg); static bool is_esc_data_index_valid(const uint8_t index); void handle_debug(const CanardRxTransfer& transfer, const uavcan_protocol_debug_LogMessage& msg); void handle_param_get_set_response(const CanardRxTransfer& transfer, const uavcan_protocol_param_GetSetResponse& rsp);