Add APIs to inject IMU and pose to software_device - #2673
Conversation
|
Related to #1880. While not directly solving the request of recording external IMU, software device + recorder lets user combine any list of sensors and record them into a bag file. This API adds the ability to record IMU as well. |
ev-mp
left a comment
There was a problem hiding this comment.
The PR is C++ only.
Can you verify it with Python wrapper?
| rs2_intrinsics intrinsics; | ||
| } rs2_video_stream; | ||
|
|
||
| /** \brief All the parameters are requaired to defind motion stream*/ |
There was a problem hiding this comment.
...that are required to define...
| rs2_create_software_device | ||
| rs2_software_device_add_sensor | ||
| rs2_software_sensor_on_video_frame | ||
| rs2_software_sensor_on_motion_frame |
There was a problem hiding this comment.
Can this be achieved via refactoring the rs_software_sensor/stream/frame into class hierarchy and unifying the invocation calls into rs_software_sensor_on_frame(sw_frame_base) , the same way as with live devices?
Though this would introduce API breaking change but also will establish infra for future extensions.
It will also will minimize API impact
|
|
||
| if (exist) | ||
| { | ||
| LOG_WARNING("Stream unique ID already exist!"); |
| { | ||
| auto exist = (std::find_if(_profiles.begin(), _profiles.end(), [&](std::shared_ptr<stream_profile_interface> profile) | ||
| { | ||
| if (profile->get_unique_id() == motion_stream.uid) |
There was a problem hiding this comment.
Maybe "return profile->get_unique_id() == motion_stream.uid" for readability
|
|
||
| if (exist) | ||
| { | ||
| LOG_WARNING("Stream unique ID already exist!"); |
| continue; //stop adding metadata to frame | ||
| } | ||
| memcpy(data.metadata_blob.data() + data.metadata_size, &i.first, size_of_enum); | ||
| data.metadata_size += static_cast<uint32_t>(size_of_enum); |
There was a problem hiding this comment.
In case of "sizeof(rs2_frame_metadata_value)>32bit" data will be overrun
There was a problem hiding this comment.
I think it is safe to add values of any size, since the data.metadata_blob is a byte array,
| { | ||
| return; | ||
| } | ||
| auto mid_profile = dynamic_cast<motion_stream_profile_interface*>(software_frame.profile->profile); |
| return; | ||
| } | ||
| auto mid_profile = dynamic_cast<motion_stream_profile_interface*>(software_frame.profile->profile); | ||
| auto mid_frame = dynamic_cast<motion_frame*>(frame); |
| data.timestamp_domain = software_frame.domain; | ||
| data.frame_number = software_frame.frame_number; | ||
|
|
||
| data.metadata_size = 0; |
There was a problem hiding this comment.
Metadata initialization (Lines 281-296) looks identical with "on_motion_frame(...
|
@belkinirena could you please update CMake/realsense.def |
Added new API to software sensor:
Added support for IMU stream and recording IMU frames in software sensor:
Added support for pose stream and recording pose frames in software sensor: