-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
IMU with Motion topic #11990
Merged
Merged
IMU with Motion topic #11990
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b905151
add ROS2 Imu topics
maloel eaf77f8
added stream-configurations to device docs
maloel a7eaa4b
basic imu-msg impl
maloel 2e2d78a
move start_streaming impl from dds-stream-server to video- and motion-
maloel 6d55d77
IMU -> motion
maloel 1f9d75d
remove fisheye, pose streams; gyro+accel -> motion
maloel 78d60dd
send motion intrinsics in 2 parts; report gyro, auto activate accel
maloel d706bc2
move format to dds_video_stream_profile; remove MXYZ
maloel 35f8d56
additional docs
maloel 13076ae
add RS2_STREAM_MOTION and RS2_FORMAT_COMBINED_MOTION
maloel d894543
dds motion in librealsense side
maloel b9820a9
fixes
maloel 5a0e10b
update pyrealdds
maloel 3de25bf
adjust libCI outputs
maloel b4e6ca7
fix merge issues
maloel 6135477
fix intrinsics & extrinsics tests
maloel 7171e70
fix device-init test
maloel a6ea118
fix d455 libci server
maloel d4fbd63
fix librs-device-properties test
maloel 54ee7a1
fix librs-formats-conversion test
maloel dc986b1
fix stream-sensor-bridge test
maloel bf0f805
reduce dds device init timeout to 5 (from 30)
maloel 9fb84b7
add imu_msg to pyrealdds
maloel f0062fe
test.remote timeouts reduced 30 -> 10
maloel b522026
CR fixes
maloel 816537a
CR fixes
maloel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,19 +30,13 @@ static rs2_stream to_rs2_stream_type( std::string const & type_string ) | |
{ "depth", RS2_STREAM_DEPTH }, | ||
{ "color", RS2_STREAM_COLOR }, | ||
{ "ir", RS2_STREAM_INFRARED }, | ||
{ "fisheye", RS2_STREAM_FISHEYE }, | ||
{ "gyro", RS2_STREAM_GYRO }, | ||
{ "accel", RS2_STREAM_ACCEL }, | ||
{ "gpio", RS2_STREAM_GPIO }, | ||
{ "pose", RS2_STREAM_POSE }, | ||
{ "motion", RS2_STREAM_MOTION }, | ||
{ "confidence", RS2_STREAM_CONFIDENCE }, | ||
}; | ||
auto it = type_to_rs2.find( type_string ); | ||
if( it == type_to_rs2.end() ) | ||
{ | ||
LOG_ERROR( "Unknown stream type '" << type_string << "'" ); | ||
return RS2_STREAM_ANY; | ||
} | ||
throw invalid_value_exception( "unknown stream type '" + type_string + "'" ); | ||
|
||
return it->second; | ||
} | ||
|
||
|
@@ -92,7 +86,7 @@ static rs2_motion_stream to_rs2_motion_stream( rs2_stream const stream_type, | |
prof.index = sidx.index; | ||
prof.uid = sidx.sid; | ||
prof.fps = profile->frequency(); | ||
prof.fmt = static_cast< rs2_format >( profile->format().to_rs2() ); | ||
prof.fmt = RS2_FORMAT_COMBINED_MOTION; | ||
|
||
memcpy( prof.intrinsics.data, intrinsics.data.data(), sizeof( prof.intrinsics.data ) ); | ||
memcpy( prof.intrinsics.noise_variances, | ||
|
@@ -174,25 +168,26 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ | |
auto const & default_profile = profiles[stream->default_profile_index()]; | ||
for( auto & profile : profiles ) | ||
{ | ||
LOG_DEBUG( " " << profile->details_to_string() ); | ||
if( video_stream ) | ||
{ | ||
auto video_profile = std::static_pointer_cast< realdds::dds_video_stream_profile >( profile ); | ||
auto added_stream_profile = sensor.add_video_stream( | ||
to_rs2_video_stream( stream_type, | ||
sidx, | ||
std::static_pointer_cast< realdds::dds_video_stream_profile >( profile ), | ||
video_stream->get_intrinsics() ), | ||
to_rs2_video_stream( stream_type, sidx, video_profile, video_stream->get_intrinsics() ), | ||
profile == default_profile ); | ||
_stream_name_to_profiles[stream->name()].push_back( added_stream_profile ); // for extrinsics | ||
} | ||
else if( motion_stream ) | ||
{ | ||
auto added_stream_profile = sensor.add_motion_stream( | ||
auto motion_profile = std::static_pointer_cast< realdds::dds_motion_stream_profile >( profile ); | ||
auto raw_motion_profile = sensor.add_motion_stream( | ||
to_rs2_motion_stream( stream_type, | ||
sidx, | ||
std::static_pointer_cast< realdds::dds_motion_stream_profile >( profile ), | ||
motion_stream->get_intrinsics() ), | ||
motion_profile, | ||
motion_stream->get_gyro_intrinsics() ), | ||
profile == default_profile ); | ||
_stream_name_to_profiles[stream->name()].push_back( added_stream_profile ); // for extrinsics | ||
_stream_name_to_profiles[stream->name()].push_back( raw_motion_profile ); | ||
// NOTE: the raw motion profile will be cloned and overriden by the format converter! | ||
} | ||
} | ||
|
||
|
@@ -211,28 +206,43 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ | |
|
||
for( auto & sensor_info : sensor_name_to_info ) | ||
{ | ||
LOG_DEBUG( sensor_info.first ); | ||
sensor_info.second.proxy->initialization_done(); | ||
|
||
// Set profile's ID based on the dds_stream's ID (index already set). Connect the profile to the extrinsics graph. | ||
for( auto & profile : sensor_info.second.proxy->get_stream_profiles() ) | ||
{ | ||
sid_index type_and_index( profile->get_stream_type(), profile->get_stream_index()); | ||
if( auto p = std::dynamic_pointer_cast< librealsense::video_stream_profile_interface >( profile ) ) | ||
{ | ||
LOG_DEBUG( " " << get_string( p->get_stream_type() ) << ' ' << p->get_stream_index() << ' ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that framerate should follow the resolution and format after. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK :) |
||
<< p->get_width() << 'x' << p->get_height() << ' ' << get_string( p->get_format() ) | ||
<< " @ " << p->get_framerate() ); | ||
} | ||
else if( auto p = std::dynamic_pointer_cast<librealsense::motion_stream_profile_interface>( profile ) ) | ||
{ | ||
LOG_DEBUG( " " << get_string( p->get_stream_type() ) << ' ' << p->get_stream_index() << ' ' | ||
<< get_string( p->get_format() ) << " @ " << p->get_framerate() ); | ||
} | ||
sid_index type_and_index( profile->get_stream_type(), profile->get_stream_index() ); | ||
|
||
auto & streams = sensor_info.second.proxy->streams(); | ||
|
||
sid_index sidx = type_and_index_to_dds_stream_sidx[type_and_index]; | ||
sid_index sidx = type_and_index_to_dds_stream_sidx.at( type_and_index ); | ||
auto stream_iter = streams.find( sidx ); | ||
if( stream_iter == streams.end() ) | ||
{ | ||
LOG_DEBUG( "Did not find dds_stream of profile (" << profile->get_stream_type() << ", " | ||
<< profile->get_stream_index() << ")" ); | ||
LOG_DEBUG( " no dds stream" ); | ||
continue; | ||
} | ||
|
||
profile->set_unique_id( stream_iter->first.sid ); | ||
profile->set_unique_id( sidx.sid ); // Was lost on clone | ||
|
||
// NOTE: the 'initialization_done' call above creates target profiles from the raw profiles we supplied it. | ||
// The raw profile intrinsics will be overriden to call the target's intrinsics function (which by default | ||
// calls the raw again, creating an infinite loop), so we must override the target: | ||
set_profile_intrinsics( profile, stream_iter->second ); | ||
|
||
_stream_name_to_profiles[stream_iter->second->name()].push_back( profile ); // For extrinsics | ||
_stream_name_to_profiles.at( stream_iter->second->name() ).push_back( profile ); // For extrinsics | ||
|
||
tag_default_profile_of_stream( profile, stream_iter->second ); | ||
} | ||
|
@@ -250,17 +260,23 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ | |
} ); | ||
} | ||
|
||
// According to extrinsics_graph (in environment.h) we need 3 steps | ||
// According to extrinsics_graph (in environment.h) we need 3 steps: | ||
|
||
// 1. Register streams with extrinsics between them | ||
for( auto & from_stream : _stream_name_to_librs_stream ) | ||
if( _dds_dev->has_extrinsics() ) | ||
{ | ||
for( auto & to_stream : _stream_name_to_librs_stream ) | ||
for( auto & from_stream : _stream_name_to_librs_stream ) | ||
{ | ||
if( from_stream.first != to_stream.first ) | ||
for( auto & to_stream : _stream_name_to_librs_stream ) | ||
{ | ||
const auto & dds_extr = _dds_dev->get_extrinsics( from_stream.first, to_stream.first ); | ||
if( dds_extr ) | ||
if( from_stream.first != to_stream.first ) | ||
{ | ||
auto const dds_extr = _dds_dev->get_extrinsics( from_stream.first, to_stream.first ); | ||
if( ! dds_extr ) | ||
{ | ||
LOG_DEBUG( "missing extrinsics from " << from_stream.first << " to " << to_stream.first ); | ||
continue; | ||
} | ||
rs2_extrinsics extr = to_rs2_extrinsics( dds_extr ); | ||
environment::get_instance().get_extrinsics_graph().register_extrinsics( *from_stream.second, | ||
*to_stream.second, | ||
|
@@ -269,6 +285,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ | |
} | ||
} | ||
} | ||
|
||
// 2. Register all profiles | ||
for( auto & it : _stream_name_to_profiles ) | ||
{ | ||
|
@@ -277,6 +294,7 @@ dds_device_proxy::dds_device_proxy( std::shared_ptr< context > ctx, std::shared_ | |
environment::get_instance().get_extrinsics_graph().register_profile( *profile ); | ||
} | ||
} | ||
|
||
// 3. Link profile to it's stream | ||
for( auto & it : _stream_name_to_librs_stream ) | ||
{ | ||
|
@@ -348,7 +366,7 @@ void dds_device_proxy::set_motion_profile_intrinsics( std::shared_ptr< stream_pr | |
std::shared_ptr< realdds::dds_motion_stream > stream ) const | ||
{ | ||
auto msp = std::dynamic_pointer_cast< motion_stream_profile >( profile ); | ||
auto & stream_intrinsics = stream->get_intrinsics(); | ||
auto & stream_intrinsics = stream->get_gyro_intrinsics(); | ||
rs2_motion_device_intrinsic intr; | ||
memcpy( intr.data, stream_intrinsics.data.data(), sizeof( intr.data ) ); | ||
memcpy( intr.noise_variances, stream_intrinsics.noise_variances.data(), sizeof( intr.noise_variances ) ); | ||
|
@@ -369,20 +387,23 @@ std::shared_ptr< dds_sensor_proxy > dds_device_proxy::create_sensor( const std:: | |
|
||
|
||
// Tagging converted profiles. dds_sensor_proxy::add_video/motion_stream tagged the raw profiles. | ||
void dds_device_proxy::tag_default_profile_of_stream( const std::shared_ptr<stream_profile_interface> & profile, | ||
const std::shared_ptr< const realdds::dds_stream > & stream ) const | ||
void dds_device_proxy::tag_default_profile_of_stream( | ||
const std::shared_ptr< stream_profile_interface > & profile, | ||
const std::shared_ptr< const realdds::dds_stream > & stream ) const | ||
{ | ||
auto const & dds_default_profile = stream->default_profile(); | ||
|
||
if( profile->get_stream_type() == to_rs2_stream_type( stream->type_string() ) && | ||
profile->get_format() == dds_default_profile->format().to_rs2() && | ||
profile->get_framerate() == dds_default_profile->frequency() ) | ||
{ | ||
auto vsp = std::dynamic_pointer_cast< video_stream_profile >( profile ); | ||
auto dds_vsp = std::dynamic_pointer_cast< realdds::dds_video_stream_profile >( dds_default_profile ); | ||
if( vsp && dds_vsp && | ||
( vsp->get_width() != dds_vsp->width() || vsp->get_height() != dds_vsp->height() ) ) | ||
return; // Video profiles of incompatible resolutions | ||
if( vsp && dds_vsp ) | ||
{ | ||
if( vsp->get_width() != dds_vsp->width() || vsp->get_height() != dds_vsp->height() | ||
|| vsp->get_format() != dds_vsp->format().to_rs2() ) | ||
return; // Video profiles of incompatible resolutions | ||
} | ||
|
||
profile->tag_profile( PROFILE_TAG_DEFAULT ); | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not call this
raw_stream_profile
? And the comment can apply to both motion and videoThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, changing