File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ class VescHardware : public hardware_interface::SystemInterface {
189189 std::atomic<double > hw_state_velocity_;
190190 std::atomic<double > hw_avg_id_;
191191 std::atomic<double > hw_avg_iq_;
192+ std::atomic<double > hw_duty_cycle_;
192193
193194 // IMU state storage (atomic for thread-safe access from callback)
194195 std::atomic<double > hw_imu_orientation_x_;
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ constexpr char CUSTOM_HW_IF_SERVO[] = "servo";
4949// Motor current interface names
5050constexpr char CUSTOM_HW_IF_AVG_ID [] = " average_id" ;
5151constexpr char CUSTOM_HW_IF_AVG_IQ [] = " average_iq" ;
52+ constexpr char CUSTOM_HW_IF_DUTY_CYCLE [] = " duty_cycle" ;
5253
5354// IMU sensor interface names - Quaternion orientation
5455constexpr char CUSTOM_HW_IF_ORIENTATION_X [] = " orientation.x" ;
@@ -424,6 +425,10 @@ void VescHardware::populate_state_definitions()
424425 false ,
425426 [this ]() {return hw_avg_iq_.load (std::memory_order_relaxed);}
426427 };
428+ state_interfaces_[CUSTOM_HW_IF_DUTY_CYCLE ] = {
429+ false ,
430+ [this ]() {return hw_duty_cycle_.load (std::memory_order_relaxed);}
431+ };
427432
428433 // IMU state interfaces - Quaternion orientation
429434 state_interfaces_[CUSTOM_HW_IF_ORIENTATION_X ] = {
@@ -544,6 +549,9 @@ void VescHardware::processValuesPacket(
544549 hw_avg_id_.store (values_packet->avg_id (), std::memory_order_relaxed);
545550 hw_avg_iq_.store (values_packet->avg_iq (), std::memory_order_relaxed);
546551
552+ // Store duty cycle
553+ hw_duty_cycle_.store (values_packet->duty_cycle_now (), std::memory_order_relaxed);
554+
547555 // Publish telemetry data
548556 publishVescState (*values_packet);
549557}
You can’t perform that action at this time.
0 commit comments