diff --git a/msg/ServoReport.msg b/msg/ServoReport.msg index 3f19624d90..3c81408dce 100644 --- a/msg/ServoReport.msg +++ b/msg/ServoReport.msg @@ -1,25 +1,32 @@ -uint64 timestamp # time since system start (microseconds) -uint8 servo_actuator_id # actuator id of current servo (in most cases 1-8) -uint8 servo_node_id # Node ID of device on CAN bus -float32 servo_position # meter or radian -float32 servo_force # Newton or Newton metre -float32 servo_speed # meter per second or radian per second -uint8 servo_power_rating_pct # 0 - unloaded, 100 - full load +# Servo report +# +# Contains information about a specific servo (position, force, speed, load). +# Also contains auxiliary power data (voltage, current) and temperature. -uint8 servo_function # servo output function +uint64 timestamp # [us] Time since system start -uint16 servo_temperature_counter # Incremented when new temperature data is stored -float32 servo_temperature # in kelvin -uint8 servo_temperature_error_flags +uint8 actuator_id # [-] DroneCAN actuator id of servo. Set to 0 for non DroneCAN servos +uint8 node_id # [-] DroneCAN node id of servo. Set to 0 for non DroneCAN servos +float32 position # meter or radian +float32 force # Newton or Newton metre +float32 speed # meter per second or radian per second +float32 power_rating_pct # [%] [@range 0, 100] Servo load + +uint8 function # [-] Servo output function + +uint16 temperature_counter # [-] Incremented when temperature data got updated +float32 temperature # [degC] Servo temperature. + +uint8 temperature_error_flags # [@enum ERROR_FLAG] Temperature error flags uint8 ERROR_FLAG_OVERHEATING = 1 uint8 ERROR_FLAG_OVERCOOLING = 2 -uint16 servo_power_counter # Incremented when new power data is stored -float32 servo_voltage # Volts -float32 servo_current # Amps -uint8 servo_power_error_flags +uint16 power_counter # [-] Incremented when power data got updated +float32 voltage # [V] Servo voltage +float32 current # [A] Servo current draw +uint8 power_error_flags # [@enum ERROR_FLAG] Power error flags uint8 ERROR_FLAG_OVERVOLTAGE = 1 uint8 ERROR_FLAG_UNDERVOLTAGE = 2 uint8 ERROR_FLAG_OVERCURRENT = 4 diff --git a/msg/ServoStatus.msg b/msg/ServoStatus.msg index daf48c15b5..93c4a2fd39 100644 --- a/msg/ServoStatus.msg +++ b/msg/ServoStatus.msg @@ -1,26 +1,21 @@ -uint64 timestamp # time since system start (microseconds) -uint8 CONNECTED_SERVO_MAX = 8 # The number of SERVOs supported via UAVCAN +# Servo status +# +# Overview message that contains general information about all servos. +# In addition it contains the reports of all individual servos. -uint8 SERVO_CONNECTION_TYPE_PPM = 0 # Traditional PPM SERVO -uint8 SERVO_CONNECTION_TYPE_SERIAL = 1 # Serial Bus connected SERVO -uint8 SERVO_CONNECTION_TYPE_ONESHOT = 2 # One Shot PPM -uint8 SERVO_CONNECTION_TYPE_I2C = 3 # I2C -uint8 SERVO_CONNECTION_TYPE_CAN = 4 # CAN-Bus -uint8 SERVO_CONNECTION_TYPE_DSHOT = 5 # DShot +uint64 timestamp # [us] Time since system start -uint16 counter # incremented by the writing thread everytime new data is stored -uint8 servo_count # number of connected servo's +uint8 count # [-] Number of connected servos +uint8 CONNECTED_SERVO_MAX = 8 -uint8 servo_connectiontype # how SERVOs connected to the system. Currently only CAN supports servo telemtry - -uint8 servo_online_flags # Bitmask indicating which SERVO is online/offline -# servo_online_flags bit 0 : Set to 1 if SERVO0 is online -# servo_online_flags bit 1 : Set to 1 if SERVO1 is online -# servo_online_flags bit 2 : Set to 1 if SERVO2 is online -# servo_online_flags bit 3 : Set to 1 if SERVO3 is online -# servo_online_flags bit 4 : Set to 1 if SERVO4 is online -# servo_online_flags bit 5 : Set to 1 if SERVO5 is online -# servo_online_flags bit 6 : Set to 1 if SERVO6 is online -# servo_online_flags bit 7 : Set to 1 if SERVO7 is online +uint8 online_flags # [-] Bitmask indicating which servo is online/offline +# online_flags bit 0 : Set to 1 if SERVO0 is online +# online_flags bit 1 : Set to 1 if SERVO1 is online +# online_flags bit 2 : Set to 1 if SERVO2 is online +# online_flags bit 3 : Set to 1 if SERVO3 is online +# online_flags bit 4 : Set to 1 if SERVO4 is online +# online_flags bit 5 : Set to 1 if SERVO5 is online +# online_flags bit 6 : Set to 1 if SERVO6 is online +# online_flags bit 7 : Set to 1 if SERVO7 is online ServoReport[8] servo diff --git a/src/drivers/uavcan/actuators/servo.cpp b/src/drivers/uavcan/actuators/servo.cpp index b59a1f9f49..733e7849d7 100644 --- a/src/drivers/uavcan/actuators/servo.cpp +++ b/src/drivers/uavcan/actuators/servo.cpp @@ -34,6 +34,7 @@ #include "servo.hpp" #include #include +#include #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) @@ -131,12 +132,12 @@ UavcanServoController::servo_temperature_sub_cb(const for (int i = 0; i < servo_status_s::CONNECTED_SERVO_MAX; i++) { auto &ref = _servo_status.servo[i]; - const bool is_servo_online = _servo_status.servo_online_flags & (1 << i); - const bool is_servo_matching = ref.servo_node_id == msg.getSrcNodeID().get(); + const bool is_servo_online = _servo_status.online_flags & (1 << i); + const bool is_servo_matching = ref.node_id == msg.getSrcNodeID().get(); if (is_servo_online && is_servo_matching) { _servo_temperature_counter[i] += 1; - _last_temperature[i] = msg.temperature; + _last_temperature[i] = msg.temperature + atmosphere::kAbsoluteNullCelsius; // Kelvin to Celsius; _last_temperature_error_flag[i] = msg.error_flags; break; } @@ -151,8 +152,8 @@ UavcanServoController::servo_circuit_status_sub_cb(const for (int i = 0; i < servo_status_s::CONNECTED_SERVO_MAX; i++) { auto &ref = _servo_status.servo[i]; - const bool is_servo_online = _servo_status.servo_online_flags & (1 << i); - const bool is_servo_matching = ref.servo_node_id == msg.getSrcNodeID().get(); + const bool is_servo_online = _servo_status.online_flags & (1 << i); + const bool is_servo_matching = ref.node_id == msg.getSrcNodeID().get(); if (is_servo_online && is_servo_matching) { _servo_power_counter[i] += 1; @@ -172,28 +173,26 @@ UavcanServoController::servo_status_sub_cb(const uavcan::ReceivedDataStructure