From cf2e4ac146f094390a1ff11728f8dbca8ced2fb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 2 Feb 2025 15:30:50 +0200 Subject: [PATCH 1/3] rs-depth set default depth_scale value --- examples/C/depth/rs-depth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/C/depth/rs-depth.c b/examples/C/depth/rs-depth.c index d191e12d2e..88bdd2600b 100644 --- a/examples/C/depth/rs-depth.c +++ b/examples/C/depth/rs-depth.c @@ -36,7 +36,7 @@ float get_depth_unit_value(const rs2_device* const dev) int num_of_sensors = rs2_get_sensors_count(sensor_list, &e); check_error(e); - float depth_scale = 0; + float depth_scale = 0.001f; // Default to mm int is_depth_sensor_found = 0; int i; for (i = 0; i < num_of_sensors; ++i) @@ -50,7 +50,8 @@ float get_depth_unit_value(const rs2_device* const dev) if (1 == is_depth_sensor_found) { - depth_scale = rs2_get_option((const rs2_options*)sensor, RS2_OPTION_DEPTH_UNITS, &e); + if( rs2_supports_option((const rs2_options*)sensor, RS2_OPTION_DEPTH_UNITS, &e) ) + depth_scale = rs2_get_option((const rs2_options*)sensor, RS2_OPTION_DEPTH_UNITS, &e); check_error(e); rs2_delete_sensor(sensor); break; From 4e86cca16c04b31458ef335d52f43efbf49a4d4f Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 2 Feb 2025 15:31:58 +0200 Subject: [PATCH 2/3] rs-motion support combined motion format --- examples/motion/rs-motion.cpp | 53 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/examples/motion/rs-motion.cpp b/examples/motion/rs-motion.cpp index c280d62074..48cbd162ea 100644 --- a/examples/motion/rs-motion.cpp +++ b/examples/motion/rs-motion.cpp @@ -190,8 +190,7 @@ class rotation_estimator } }; - -bool check_imu_is_supported() +bool check_accel_gyro_are_supported() { bool found_gyro = false; bool found_accel = false; @@ -218,13 +217,48 @@ bool check_imu_is_supported() return found_gyro && found_accel; } +bool check_combined_motion_is_supported() +{ + rs2::context ctx; + + for (auto dev : ctx.query_devices()) + { + for (auto sensor : dev.query_sensors()) + { + for (auto profile : sensor.get_stream_profiles()) + { + if (profile.stream_type() == RS2_STREAM_MOTION) + return true; + } + } + } + + return false; +} + int main(int argc, char * argv[]) try { + // Declare RealSense pipeline, encapsulating the actual device and sensors + rs2::pipeline pipe; + // Create a configuration for configuring the pipeline with a non default profile + rs2::config cfg; + // Before running the example, check that a device supporting IMU is connected - if (!check_imu_is_supported()) + if (check_accel_gyro_are_supported()) + { + // Add streams of gyro and accelerometer to configuration + cfg.enable_stream(RS2_STREAM_ACCEL, RS2_FORMAT_MOTION_XYZ32F); + cfg.enable_stream(RS2_STREAM_GYRO, RS2_FORMAT_MOTION_XYZ32F); + } + else if (check_combined_motion_is_supported()) { - std::cerr << "Device supporting IMU not found"; - return EXIT_FAILURE; + // Add combined gyro and accelerometer to configuration + cfg.enable_stream(RS2_STREAM_MOTION, RS2_FORMAT_COMBINED_MOTION); + } + else + { + std::cerr << "Device supporting IMU not found"; + return EXIT_FAILURE; } // Initialize window for rendering @@ -234,15 +268,6 @@ int main(int argc, char * argv[]) try // Register callbacks to allow manipulation of the view state register_glfw_callbacks(app, app_state); - // Declare RealSense pipeline, encapsulating the actual device and sensors - rs2::pipeline pipe; - // Create a configuration for configuring the pipeline with a non default profile - rs2::config cfg; - - // Add streams of gyro and accelerometer to configuration - cfg.enable_stream(RS2_STREAM_ACCEL, RS2_FORMAT_MOTION_XYZ32F); - cfg.enable_stream(RS2_STREAM_GYRO, RS2_FORMAT_MOTION_XYZ32F); - // Declare object for rendering camera motion camera_renderer camera; // Declare object that handles camera pose calculations From d0f24d20dcf322a4a6f4b6dff07155877f05f2d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 2 Feb 2025 15:32:57 +0200 Subject: [PATCH 3/3] rs-sensor-control show ROI values --- examples/sensor-control/api_how_to.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/sensor-control/api_how_to.h b/examples/sensor-control/api_how_to.h index 305b443118..fb00101d54 100644 --- a/examples/sensor-control/api_how_to.h +++ b/examples/sensor-control/api_how_to.h @@ -171,9 +171,16 @@ class how_to std::cout << " Description : " << description << std::endl; // Get the current value of the option - float current_value = sensor.get_option(option_type); - std::cout << " Current Value : " << current_value << std::endl; - + if (option_type != RS2_OPTION_REGION_OF_INTEREST) + { + float current_value = sensor.get_option(option_type); + std::cout << " Current Value : " << current_value << std::endl; + } + else + { + rs2_option_rect current_value = sensor.get_option_value(option_type)->as_rect; + std::cout << " Current Value : [(" << current_value.x1 << "," << current_value.y1 << "), (" << current_value.x2 << "," << current_value.y2 << ")]" << std::endl; + } //To change the value of an option, please follow the change_sensor_option() function } else @@ -307,6 +314,12 @@ class how_to return; } + if (option_type == RS2_OPTION_REGION_OF_INTEREST) + { + std::cerr << "Setting ROI is not demonstrated in this example. Check `set_region_of_interest` API" << std::endl; + return; + } + // Each option provides its rs2::option_range to provide information on how it can be changed // To get the supported range of an option we do the following: