Skip to content
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 AP_Servo_Telem #28651

Merged
merged 12 commits into from
Dec 2, 2024
Merged

Add AP_Servo_Telem #28651

merged 12 commits into from
Dec 2, 2024

Conversation

IamPete1
Copy link
Member

This adds a servo telem library. Logging only at this stage. There are some benefits, DroneCAN servo logging can be rate limited, this is currently not possible as each instance is logged when it arrives, so it is rate limited individual rather than as a block of each instance.

In the longer term scripting bindings will be added to get and provide this data. That will allow servo health checking and failsafes.

@@ -343,7 +346,11 @@ class AP_DroneCAN : public AP_CANDriver, public AP_ESC_Telem_Backend {
Canard::ObjCallback<AP_DroneCAN, uavcan_protocol_debug_LogMessage> debug_cb{this, &AP_DroneCAN::handle_debug};
Canard::Subscriber<uavcan_protocol_debug_LogMessage> debug_listener{debug_cb, _driver_index};

#if AP_DRONECAN_VOLZ_FEEDBACK_ENABLED
#if AP_DRONECAN_HIMARK_SERVO_SUPPORT && AP_SERVO_TELEM_ENABLED
Canard::ObjCallback<AP_DroneCAN, com_himark_servo_ServoInfo> himark_servo_ServoInfo_cb{this, &AP_DroneCAN::handle_himark_servoinfo};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

himark servo was just broken, there was a function but the callback was never registered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must have been a regression, it worked when it went in

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the change of DroneCAN library I think, I fixed the same thing for the volz message, #27924 we should probably check all the rest....

Copy link
Member Author

@IamPete1 IamPete1 Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked the rest, we are OK no others missing.

Comment on lines +375 to +376
.command_position = servo.commandedPosition(),
.measured_position = servo.position(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly these are not the correct units, should be degrees. I'm not familiar enough with piccolo CAN to know if we can do a conversion.

@@ -131,7 +131,6 @@ class AP_PiccoloCAN : public AP_CANDriver, public AP_ESC_Telem_Backend
AP_Int16 _ecu_id; //!< ECU Node ID
AP_Int16 _ecu_hz; //!< ECU update rate (Hz)

HAL_Semaphore _telem_sem;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only ever called in one place, so its not needed.

telem.data[i].primary_current,
telem.data[i].secondary_current,
telem.data[i].primary_voltage,
telem.data[i].secondary_voltage,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do loose logging of the secondary current and voltage, they could be added as extra fields in the future.

@tridge
Copy link
Contributor

tridge commented Nov 18, 2024

@IamPete1 I have added simulation of DroneCAN actuator status and fixed some bugs in the PR here:
https://github.com/tridge/ardupilot/commits/servo_telem/

@@ -343,7 +346,11 @@ class AP_DroneCAN : public AP_CANDriver, public AP_ESC_Telem_Backend {
Canard::ObjCallback<AP_DroneCAN, uavcan_protocol_debug_LogMessage> debug_cb{this, &AP_DroneCAN::handle_debug};
Canard::Subscriber<uavcan_protocol_debug_LogMessage> debug_listener{debug_cb, _driver_index};

#if AP_DRONECAN_VOLZ_FEEDBACK_ENABLED
#if AP_DRONECAN_HIMARK_SERVO_SUPPORT && AP_SERVO_TELEM_ENABLED
Canard::ObjCallback<AP_DroneCAN, com_himark_servo_ServoInfo> himark_servo_ServoInfo_cb{this, &AP_DroneCAN::handle_himark_servoinfo};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must have been a regression, it worked when it went in

@IamPete1
Copy link
Member Author

@IamPete1 I have added simulation of DroneCAN actuator status and fixed some bugs in the PR here: https://github.com/tridge/ardupilot/commits/servo_telem/

Thanks, I have pulled in your changes.

@IamPete1 IamPete1 requested a review from tridge November 21, 2024 21:41
@@ -68,6 +68,7 @@ Please keep the names consistent with Tools/autotest/param_metadata/param.py:33
| 's' | "s" | seconds|
| 'q' | "rpm" | revolutions per minute| Not an SI unit, but sometimes more intuitive than Hertz|
| 'r' | "rad" | radians|
| 't' | "N.m" | Newton meters | torque |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "N-m" or "N m"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree, it's just matched the existing ones.
SmartSelect_20241125_142833_Chrome

Copy link
Collaborator

@andyp1per andyp1per left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@IamPete1
Copy link
Member Author

IamPete1 commented Nov 30, 2024

Some test results:
image

@tridge
Copy link
Contributor

tridge commented Dec 2, 2024

@IamPete1 nice work, thanks!

@tridge tridge merged commit 445c03c into ArduPilot:master Dec 2, 2024
99 checks passed
@Ryanf55
Copy link
Collaborator

Ryanf55 commented Dec 3, 2024

Unfortunately, this broke the DDS build.

libraries/AP_DDS/generated/ardupilot_msgs/msg/GlobalPosition.h:47:15: error: expected identifier before numeric constant
   47 | #define FORCE 512
      |               ^~~
../../libraries/AP_Servo_Telem/AP_Servo_Telem.h:45:13: note: in expansion of macro ‘FORCE’
   45 |             FORCE              = 1 << 2,
      |             ^~~~~
     

I'm not happy about the generator using global defines, but it's written for C... Is an easy fix to rename the enum in this class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants