Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to find devices with motion sensors (IMU)? #2899

Closed
UnaNancyOwen opened this issue Dec 15, 2018 · 8 comments
Closed

How to find devices with motion sensors (IMU)? #2899

UnaNancyOwen opened this issue Dec 15, 2018 · 8 comments
Assignees

Comments

@UnaNancyOwen
Copy link
Contributor

UnaNancyOwen commented Dec 15, 2018

Required Info
Camera Model D400
SDK Version 2.17.0
Language C++

Issue Description

Do you know how to find devices with motion sensors (IMU)?
For example case, I want to query only D435i devices.
I think it is able to do that, but it require to write a many lines code (about 10-15 lines). I want more easy way.
If there is no easy way to do that, I suggest adding a mask to rs2::context::query_devices().

// I wish I want do it like this. What do you think?
rs2::context;
const rs2::device_list device_list = context.query_devices( RS2_PRODUCT_LINE_D400 | RS2_HAVE_IMU ); // return d435i devices
@MartyG-RealSense
Copy link
Collaborator

Each RealSense model has a PID identification code. D435i's is RS435I_PID

const uint16_t RS435I_PID = 0x0b3a; // D435i

@UnaNancyOwen
Copy link
Contributor Author

Yes, It will be able to identify RealSense D435i. However, It is hard coding.
It will be troublesome when another RealSense with IMU is released in the future.
Is there a way to not require hard coding?

// The example that I showed was misleading. This is what I want to do.
rs2::context;
const rs2::device_list device_list = context.query_devices( RS2_PRODUCT_LINE_ANY_INTEL | RS2_HAVE_IMU ); // return devices with imu

@UnaNancyOwen
Copy link
Contributor Author

This is what I want to do. However, I want to write it more easily.

void query_motion_devices( std::vector<rs2::device>& motion_devices )
{
    rs2::context context;
    const rs2::device_list device_list = context.query_devices( RS2_PRODUCT_LINE_ANY_INTEL );
    for( const rs2::device& device : device_list ){
        const std::vector<rs2::sensor> sensors = device.query_sensors();
        for( const rs2::sensor& sensor : sensors ){
            const std::vector<rs2::stream_profile> profiles = sensor.get_stream_profiles();
            for( const rs2::stream_profile& profile : profiles ){
                if( profile.is<rs2::motion_stream_profile>() ){
                    motion_devices.push_back( device );
                }
            }
        }
    }
}

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Dec 16, 2018

I would imagine that the IMU component has some kind of individual recognition code so that a program can detect whether the sensor is present (like with the 'sensor-control' sample program that lists the sensor details).

sensor-control iterates through the available sensors on a camera using a command called get_sensor_name. You could probably modify the terms of the search to only react positively to the name of the IMU sensor component (which would presumably be the same between different cameras using the same IMU component) and not allow the program to run if the search condition does not detect the sensor name.

https://github.com/IntelRealSense/librealsense/blob/master/examples/sensor-control/api_how_to.h#L131

You could likely find out what the name of the IMU component is by running sensor-control- since it is apparently not hard-wired to look for specific pre-programmed sensor names.

@dorodnic
Copy link
Contributor

Hi @UnaNancyOwen
Yes, we need to add this (either via PRODUCT_LINE or as a device extension)

@RealSense-Customer-Engineering

This comment has been minimized.

@dorodnic
Copy link
Contributor

@RealSense-Customer-Engineering let's not close issues market enhancement, these should propagate to backlog as change-requests

@dorodnic dorodnic reopened this Jan 12, 2019
@ev-mp
Copy link
Collaborator

ev-mp commented Jan 7, 2020

The capability to query the motion sensor has been addressed with #5468
Added to v2.32.0

@ev-mp ev-mp closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants