Skip to content

Enable D500 motion streaming on macOS - #15549

Draft
keskinonur wants to merge 1 commit into
realsenseai:developmentfrom
bilims:blms/macos-d555-imu-support
Draft

Enable D500 motion streaming on macOS#15549
keskinonur wants to merge 1 commit into
realsenseai:developmentfrom
bilims:blms/macos-d555-imu-support

Conversation

@keskinonur

@keskinonur keskinonur commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • enable the D500 motion module on macOS
  • use the existing RSUSB interrupt-transfer path for HID reports
  • remove the separate macOS HIDAPI implementation
  • stream accelerometer and gyroscope data without changing non-macOS behavior

Scope

This branch is based on development after #15550. The diff is limited to D500 motion discovery and streaming on macOS.

Validation

Tested on Apple Silicon with a D555 connected directly over USB-C at 5 Gbps.

The final branch was tested with Homebrew libusb 1.0.30 in two consecutive Viewer sessions without reconnecting the camera. Depth, color, accelerometer, and gyroscope ran together in both sessions. The following checks passed:

  • 2D depth, color, accelerometer, and gyroscope streams
  • 3D point cloud
  • Custom to High Density profile change while streaming
  • stream stop followed by normal Viewer shutdown
  • final UVC ownership restored to 5/5

The latest session received 532 depth, 553 color, 1,828 accelerometer, and 3,659 gyroscope callbacks.

This PR remains a draft while the new CI run completes.

@sysrsbuild-gh-agentic sysrsbuild-gh-agentic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Auto-generated review by rs-agentic bot

Two potential bugs flagged below.

Comment thread third-party/rsutils/include/rsutils/concurrency/concurrency.h
Comment thread src/libusb/darwin-device-capture.cpp Outdated
@jpswensen

Copy link
Copy Markdown

D455 motion validation on Intel macOS

Related to #15594.

I tested commit 4cc0dd623 from this PR applied to current development
(0476a351c) using:

  • Intel Mac
  • macOS 15.7.8
  • Homebrew libusb 1.0.30
  • RealSense D455
  • FORCE_RSUSB_BACKEND=ON

Baseline with PR #15549 only

  • realsense-viewer detected the Stereo and RGB modules.
  • The Motion Module was not exposed.
  • rs-motion reported Device supporting IMU not found.

PR #15549 replaces the macOS HIDAPI implementation with the generic RSUSB
HID path and enables that path for D500 devices. The equivalent D400 motion
code remains excluded on macOS.

D455 extension

The following patch enables the existing D400 HID motion path and restores
D455 gyro-sensitivity registration:

diff --git a/src/ds/d400/d400-factory.cpp b/src/ds/d400/d400-factory.cpp
--- a/src/ds/d400/d400-factory.cpp
+++ b/src/ds/d400/d400-factory.cpp
@@ -1071,9 +1071,7 @@ namespace librealsense
             , ds_thermal_tracking( d400_device::_thermal_monitor )
         {
             ds_advanced_mode_base::initialize_advanced_mode( this );
-#if !defined(__APPLE__) // Motion sensors not supported on macOS
             register_gyro_sensitivity();
-#endif
         }

diff --git a/src/ds/d400/d400-motion.cpp b/src/ds/d400/d400-motion.cpp
--- a/src/ds/d400/d400-motion.cpp
+++ b/src/ds/d400/d400-motion.cpp
@@ -171,7 +171,6 @@ namespace librealsense

             initialize_fisheye_sensor( dev_info->get_context(), dev_info->get_group() );

-#if !defined(__APPLE__) // Motion sensors not supported on macOS
             // Try to add HID endpoint
             auto hid_ep = create_hid_device( dev_info->get_context(), dev_info->get_group().hid_devices );
             if (hid_ep)
@@ -184,7 +183,6 @@ namespace librealsense
             //for FW >=5.16 the scale factor changes to 1000.0 since FW sends 32bit
             if (_fw_version >= firmware_version( 5, 16, 0, 0))
                 get_raw_motion_sensor()->set_gyro_scale_factor( 10000.0 );
-#endif
         }
         catch (const std::exception& e)
         {
@@ -203,21 +201,13 @@ namespace librealsense

     ds_motion_sensor & d400_motion::get_motion_sensor()
     {
-#if defined(__APPLE__)
-        throw std::runtime_error("Motion sensors are not supported on macOS");
-#else
         return dynamic_cast< ds_motion_sensor & >( get_sensor( _motion_module_device_idx.value() ) );
-#endif
     }

     std::shared_ptr<hid_sensor> d400_motion::get_raw_motion_sensor()
     {
-#if defined(__APPLE__)
-        return nullptr;
-#else
         auto raw_sensor = get_motion_sensor().get_raw_sensor();
         return std::dynamic_pointer_cast< hid_sensor >( raw_sensor );
-#endif
     }

Validation after the patch

  • The Viewer exposed the D455 Motion Module.
  • Accelerometer and gyroscope streaming worked.
  • rs-motion worked correctly.
  • The Gyro Sensitivity option appeared and could be changed.
  • Motion continued streaming after changing the option.
  • Depth and RGB continued working.

Scope

Only the D455 has been validated.

The endpoint implementation is shared by several HID-based D400 products, so
the change may affect those devices, but I am not claiming support for them
without hardware testing. In particular:

  • The existing D435i-specific gyro-sensitivity macOS guard is intentionally
    unchanged.
  • D435i support has not been tested or validated.
  • The separate d400_motion_uvc path used by D457/GMSL devices remains
    disabled on macOS.
  • D457/GMSL support has not been tested or validated.

Would you be willing to include this tested D455 extension in PR #15549?
I can submit it as a small follow-up PR if that is preferable.

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.

3 participants