Skip to content

Jazzy version of changes to support present temperature, current, voltage, and load#107

Open
bueche wants to merge 1 commit intoROBOTIS-GIT:jazzyfrom
bueche:jazzy
Open

Jazzy version of changes to support present temperature, current, voltage, and load#107
bueche wants to merge 1 commit intoROBOTIS-GIT:jazzyfrom
bueche:jazzy

Conversation

@bueche
Copy link

@bueche bueche commented Feb 24, 2026

his PR is meant to address Issue #104 by enabling the ros2 /dynamixel_hardware_interface/dxl_state state to return servo values of "Present Temperature", "Present Input Voltage", "Present Current", and/or "Present Load". Some servo's return "Present Current" (XL330's) while others "Present Load" (e.g., XL430's). Whether or not they return these depends on the model files.

This PR is for the jazzy version (a separate PR was created for the humble branch). This has been tested in an environment in which both XL330's and XL430's are present to confirm that the Present current is always zero for XL430's and Present Load is always zero for XL330s. This is shown below with the slightly annotated output. In this example id's 1 & 2 are XL430's and id's 3 - 6 are XL330's.

The return values are not adjusted in any way, the consumer will need to do so (e.g., convert the Present Load from its raw value by dividing by 10 .. to change 146 to 14.6% and to divide by 10 do adjust the voltage values 121 becomes 12.1 v.

Example use:

$ ros2 topic echo /dynamixel_hardware_interface/dxl_state --once
header:
  stamp:
    sec: 1770579229
    nanosec: 459868213
  frame_id: ''
comm_state: 0
id:
- 1
- 2
- 3
- 4
- 5
- 6
torque_state:
- false
- false
- false
- false
- false
- false
dxl_hw_state:
- 0
- 0
- 0
- 0
- 0
- 0
present_temperature:
- 32
- 41
- 21
- 20
- 20
- 23
present_input_voltage:
- 121
- 121
- 57
- 56
- 57
- 56
present_current:
- 0  <--- ALWAYS ZERO FOR XL430's
- 0 <--- ALWAYS ZERO FOR XL430's
- -19
- 15
- -12
- 21
present_load:
- 0 
- 146
- 0 <--- ALWAYS ZERO FOR XL330's 
- 0 <--- ALWAYS ZERO FOR XL330's
- 0 <--- ALWAYS ZERO FOR XL330's
- 0 <--- ALWAYS ZERO FOR XL330's
---

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bueche, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the dynamixel_hardware_interface by integrating support for reading and publishing additional telemetry data from Dynamixel servos. It addresses Issue #104 by enabling the dxl_state ROS2 message to include "Present Temperature", "Present Input Voltage", "Present Current", and "Present Load". The changes involve introducing a flexible mechanism to process these values, including specific scaling factors, and ensuring they are correctly populated for both XL330 and XL430 models, providing more comprehensive servo state information to consumers.

Highlights

  • New Telemetry Data Support: Added support for 'Present Temperature', 'Present Input Voltage', 'Present Current', and 'Present Load' telemetry data to the dxl_state ROS2 message, addressing Issue DynamixelState.msg doesn't return temperature, voltage, load, or current #104.
  • Flexible Telemetry Processing: Introduced a processTelemetryInterface method to dynamically handle and scale various telemetry data types, ensuring proper conversion before updating the state message fields.
  • Message Field Initialization and Population: Ensured that new telemetry fields within the DynamixelHardware class are properly initialized to zero and then populated during the read cycle based on available servo data.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • include/dynamixel_hardware_interface/dynamixel_hardware_interface.hpp
    • Declared processTelemetryInterface method.
  • src/dynamixel_hardware_interface.cpp
    • Defined TelemetryInterfaces constants for various telemetry types.
    • Created TelemetryHandler struct to manage scaling and message field assignment.
    • Resized dxl_state_msg_ arrays for new telemetry fields (present_temperature, present_input_voltage, present_current, present_load) during initialization.
    • Implemented processTelemetryInterface to map interface names to their respective handlers, apply scaling, and update the corresponding fields in dxl_state_msg_.
    • Modified the read method to initialize new telemetry fields to zero and then iterate through state interfaces to extract and process telemetry values using processTelemetryInterface.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for reporting 'Present Temperature', 'Present Input Voltage', 'Present Current', and 'Present Load' from Dynamixel servos, addressing Issue #104. The changes include defining new constants for telemetry interface names, a TelemetryHandler struct for processing, and a processTelemetryInterface method to manage data scaling and message field updates. The on_init and read methods have been appropriately modified to initialize and populate these new telemetry fields. A minor issue was identified regarding the scaling factor for 'Present Load', which could lead to incorrect values being reported in the dxl_state message.

Comment on lines +584 to +587
{1.0, // No scaling needed
[](DynamixelHardware* hw, int16_t val, size_t idx) {
hw->dxl_state_msg_.present_load.at(idx) = val;
}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The scale_factor for TelemetryInterfaces::LOAD should be 10.0 to match the example output and the description in the pull request body. The description states that the consumer needs to divide by 10 to get the percentage (e.g., 146 -> 14.6%), implying the message should store the raw integer 146. If the value parameter to processTelemetryInterface is already the physical value (e.g., 14.6), then multiplying by 10 will restore the raw integer 146 for storage in dxl_state_msg_.present_load.

Currently, with scale_factor = 1.0, if value is 14.6, converted_value becomes 14, which is a loss of precision and does not match the expected output.

    {TelemetryInterfaces::LOAD,
     {10.0,  // Scale to 0.1% units (e.g., 14.6% -> 146)
      [](DynamixelHardware* hw, int16_t val, size_t idx) {
        hw->dxl_state_msg_.present_load.at(idx) = val;
      }}}

@bueche bueche changed the base branch from main to jazzy February 25, 2026 14:49
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.

1 participant