Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
DESCRIPTION:
query_motion_devices() is returns a list of all devices that have motion sensors.
HOWTOUSE:
std::vector<rs2::device> motion_devices;
query_motion_devices( motion_devices );
if( motion_devices.empty ){
throw std::runtime_error( "could not find devices that have motion sensors." );
return -1;
}
rs2::config config;
const std::string serial_number = devices.front().get_info( rs2_camera_info::RS2_CAMERA_INFO_SERIAL_NUMBER );
config.enable_device( serial_number );
rs2::pipeline pipeline;
pipeline.start( config );
*/
#ifndef __QUERY_MOTION_DEVICES__
#define __QUERY_MOTION_DEVICES__
#include <librealsense2/rs.hpp>
#include <vector>
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 );
}
}
}
}
}
#endif // __QUERY_MOTION_DEVICES__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.