Skip to content

Enable headless mode on ROS2 Humble#157

Open
griffinaddison wants to merge 1 commit intoros-controls:mainfrom
griffinaddison:fix/humble-headless-support
Open

Enable headless mode on ROS2 Humble#157
griffinaddison wants to merge 1 commit intoros-controls:mainfrom
griffinaddison:fix/humble-headless-support

Conversation

@griffinaddison
Copy link
Copy Markdown

@griffinaddison griffinaddison commented Mar 28, 2026

Summary

Fixes headless mode on ROS2 Humble, which currently silently fails and falls through to GLFW (crashing on headless machines like Jetson).

Two small changes:

  • CMakeLists.txt: Add ROS_DISTRO_HUMBLE cmake define. The #if ROS_DISTRO_HUMBLE guard for get_hardware_info() already exists in the header but was never activated.
  • mujoco_system_interface.cpp: Add MUJOCO_HEADLESS environment variable fallback for cases where the URDF hardware param path is unreliable on Humble.

Problem

On Humble, get_hardware_info() doesn't exist in hardware_interface::SystemInterface. The header already has a compatibility shim at line 114:

#if ROS_DISTRO_HUMBLE
  const hardware_interface::HardwareInfo& get_hardware_info() const { return info_; }
#endif

But ROS_DISTRO_HUMBLE was never defined in cmake, so this shim is dead code. Without it, the headless hardware parameter can't be read, and the plugin always takes the GLFW path — crashing on headless machines.

Testing

Tested on Jetson AGX Orin (aarch64, Ubuntu 22.04, ROS2 Humble, MuJoCo 3.6.0):

  • Before: ERROR: could not initialize GLFW → process dies
  • After: Running in HEADLESS mode. → robot initializes, controllers activate

Changes

  • mujoco_ros2_control/CMakeLists.txt: +5 lines (detect Humble, set define)
  • mujoco_ros2_control/src/mujoco_system_interface.cpp: +4 lines (env var fallback)

🤖 Generated with Claude Code

Two fixes for headless mode on Humble:

1. Add ROS_DISTRO_HUMBLE cmake define. The #if ROS_DISTRO_HUMBLE guard
   for get_hardware_info() already exists in the header (line 114 of
   mujoco_system_interface.hpp) but was never activated because the
   cmake define wasn't set. This caused the headless hardware param
   to not be read on Humble, falling through to GLFW which crashes
   on headless machines (e.g., Jetson).

2. Add MUJOCO_HEADLESS environment variable fallback. On Humble, the
   hardware_parameters map population from URDF <param> tags can be
   unreliable. The env var provides a robust alternative:
     MUJOCO_HEADLESS=1 ros2 launch ...

Tested on Jetson AGX Orin (aarch64, Ubuntu 22.04, ROS2 Humble) with
MuJoCo 3.6.0. Both arms initialize correctly in headless mode.
Copy link
Copy Markdown
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

I don't think there is an issue with the Humble part as we also have the CI to test it. Can you walk me through the process of how you found this issue?

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