Skip to content

Add initialize_communication_on_configure to open port - #119

Open
Michi-Tsubaki wants to merge 1 commit into
ROBOTIS-GIT:mainfrom
Michi-Tsubaki:defer-communication-to-on-configure
Open

Michi-Tsubaki wants to merge 1 commit into
ROBOTIS-GIT:mainfrom
Michi-Tsubaki:defer-communication-to-on-configure

Conversation

@Michi-Tsubaki

Copy link
Copy Markdown

Why this PR is needed?

The port is opened and the Dynamixels are initialized in on_init().

As a result:

  • controller_manager fails to load the component if the motors are off or the U2D2 is unplugged at startup.
  • cleanup does not release the port, and configure does not reconnect. Recovering from a power cycle requires restarting controller_manager.

ros2_control expects communication to be set up in on_configure().

Changes

  • Add the hardware parameter initialize_communication_on_configure (default false). When it is true, the port is opened and the Dynamixels are initialized in on_configure() instead of on_init().
  • Split on_init() so that the handlers are built from the URDF without communication. The existing communication code moves unchanged into InitDxlCommunication().
  • Add on_configure() (init), on_cleanup() (close port) and on_shutdown() (torque off and close port).
  • Guard the services and the destructor while the component is not configured.

Minimal Example to show advantage

<param name="initialize_communication_on_configure">true</param>
controller_manager:
  ros__parameters:
    hardware_components_initial_state:
      unconfigured: [dynamixel_system]
# controller_manager starts even with the motors powered off
ros2 control set_hardware_component_state dynamixel_system active        # open port
ros2 control set_hardware_component_state dynamixel_system unconfigured  # close port (e.g. power-cycle)
ros2 control set_hardware_component_state dynamixel_system active        # reconnect, no restart

Backward Compatibility

  • The default is false, so existing URDFs behave as before. No existing public API is removed.
  • cleanup now closes the port, and the next configure reinitializes the Dynamixels. Previously both were no-ops.
  • reboot_dxl no longer rebuilds the handlers. Rebuilding them invalidated the pointers already exported to ros2_control.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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.

2 participants