How robotis-japan-git/dynamixelhandler-ros2 works
• “dynamixel_handler” – the core package that implements the main ROS2 node for communicating with Dynamixel servos over USB (via a serial interface) and performing initialization, periodic polling (read/write), and state publishing via a number of ROS topics.
• “dynamixel_handler_examples” – a package containing example nodes (like example1) to demonstrate how to command the dynamixel_handler node and process returned state data.
• “dynamixel_handler_msgs” – a package that defines the various ROS messages used for commands and states (for example, messages for different control modes, status, goal, gain, limits, etc.).
Main Components / Nodes
– Core Control Node: “dynamixel_handler” node
◦ Handles the low-level communication with connected Dynamixel servos.
◦ Implements functionalities such as servo auto-search, initialization (torque and baudrate setting, etc.), periodic read/write loops, and publishes state information.
◦ Subdivides its responsibilities internally—for initialization, handling subscriptions (commands) and publishing (servo states and debug information).
– Example Node(s): “dynamixel_handler_examples” (for example1)
◦ Acts as a client node that sends commands (position, velocity, current, etc.) to the “dynamixel_handler” via predefined topics.
– Message Definitions: “dynamixel_handler_msgs”
◦ Contains all the message types exchanged between the handler and the client nodes (for commands and states).
Interfaces / Topic Communications
– Command Topics (Subscribers in the dynamixel_handler node):
◦ Standard command topics such as:
• /dynamixel/command/x (and its sub-topics for PWM, current, velocity, position, etc.)
• /dynamixel/command/p (for P-series servos)
• /dynamixel/command/status, /dynamixel/command/gain, /dynamixel/command/limit, and /dynamixel/shortcut
– State Topics (Publishers from the dynamixel_handler node):
◦ /dynamixel/states (which aggregates servo status, present values, goal data, gain, limit, error, etc.)
◦ Additional topics such as /dynamixel/debug and /dynamixel/external_port/read for extended monitoring
Underlying Communication Flow and Architectural Patterns
– Initialization Phase:
◦ The node reads configurations from YAML files (under the config directory) and launches via provided launch files.
◦ It detects and auto-scans available Dynamixel servos, performs optional error clearing and torque enabling, and then enters its main communication loop.
– Main Loop / Periodic Cycle:
◦ Uses a loop rate (configured via ROS parameters) to coordinate synchronized read and write operations.
◦ Topics for commands are subscribed to and based on their timing, the node writes goal parameters to the servos.
◦ The node reads various types of state information (current, velocity, position, etc.) at rates determined by individual "pub_ratio" parameters and publishes these by aggregating them under consistent message types.
– Abstraction and Modularity:
◦ The separation into a core control package, examples, and message definitions demonstrates a layered architecture. The handler abstracts away low-level serial communications so that users (or additional nodes) need only interact via high-level ROS topics.
◦ The design adopts principles of modularity and decoupling (for instance, the dynamixel_handler node works as an intermediary that manages the conversion between physical values—like degree and current in mA—and the servo’s native pulse values).
Technologies, Frameworks, and Libraries
– The project is built in C++ with ROS2 (Humble version or later) and utilizes ROS2’s messaging system.
– It leverages standard build scripts (CMakeLists.txt) provided in each package.
– Libraries under “mylib_dynamixel” and various utility headers indicate a modularized approach for repeated functions (logging, formatting, iterator utility).
– The communication with hardware is performed using a serial pipeline (with attention to USB parameters and latency settings).