20 using namespace device_serializer;
24 LOG_INFO(
"Compression while record is set to " << (compress_while_record ?
"ON" :
"OFF"));
26 if (compress_while_record)
42 for (
auto&& sensor_extension_snapshot : sensors_snapshot.get_sensor_extensions_snapshots().get_snapshots())
128 std::tie(reference_id, ext) =
dev.get_extrinsics(*frame->
get_stream());
141 auto secs = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::duration<double, std::nano>(n.
timestamp));
159 catch (std::exception
const&
e)
161 LOG_WARNING(
"Failed to write frame metadata for " << stream_id.
stream_type <<
". Exception: " << e.what());
168 catch (std::exception
const& e)
170 LOG_WARNING(
"Failed to write stream extrinsics for " << stream_id.
stream_type <<
". Exception: " << e.what());
178 assert(vid_frame !=
nullptr);
182 image.
step =
static_cast<uint32_t>(vid_frame->get_stride());
185 auto size = vid_frame->get_stride() * vid_frame->get_height();
186 auto p_data = vid_frame->get_frame_data();
187 image.
data.assign(p_data, p_data +
size);
189 std::chrono::duration<double, std::milli> timestamp_ms(vid_frame->get_frame_timestamp());
203 throw io_exception(
"Null frame passed to write_motion_frame");
207 std::chrono::duration<double, std::milli> timestamp_ms(
frame.
frame->get_frame_timestamp());
211 auto data_ptr =
reinterpret_cast<const float*
>(
frame.
frame->get_frame_data());
227 throw io_exception(
"Unsupported stream type for a motion frame");
259 throw io_exception(
"Null frame passed to write_motion_frame");
317 stream_info_msg.
fps = profile->get_framerate();
326 camera_info_msg.
width = profile->get_width();
327 camera_info_msg.
height = profile->get_height();
334 LOG_ERROR(
"Error trying to get intrinsc data for stream " << profile->get_stream_type() <<
", " << profile->get_stream_index());
340 camera_info_msg.
K[8] = 1;
358 LOG_ERROR(
"Error trying to get intrinsc data for stream " << profile->get_stream_type() <<
", " << profile->get_stream_index());
374 const auto ignored = 0u;
389 auto info = SnapshotAs<RS2_EXTENSION_INFO>(snapshot);
410 auto options = SnapshotAs<RS2_EXTENSION_OPTIONS>(snapshot);
417 auto l500_depth_sensor_data = SnapshotAs<RS2_EXTENSION_L500_DEPTH_SENSOR>(snapshot);
431 auto profile = SnapshotAs<RS2_EXTENSION_VIDEO_PROFILE>(snapshot);
437 auto profile = SnapshotAs<RS2_EXTENSION_MOTION_PROFILE>(snapshot);
443 auto profile = SnapshotAs<RS2_EXTENSION_POSE_PROFILE>(snapshot);
449 auto filters = SnapshotAs<RS2_EXTENSION_RECOMMENDED_FILTERS>(snapshot);
463 if (info_snapshot->supports_info(camera_info))
467 msg.
value = info_snapshot->get_info(camera_info);
489 option_msg_desc.
data = description;
502 if (options->supports_option(option_id))
507 catch (std::exception&
e)
509 LOG_WARNING(
"Failed to get or write option " << option_id <<
" for sensor " << sensor_id.
sensor_index <<
". Exception: " << e.what());
516 auto intrinsics = l500_depth_sensor->get_intrinsic();
519 intrinsics_data.
data.push_back(
intrinsics.resolution.num_of_resolutions);
520 for (
auto i = 0;
i <
intrinsics.resolution.num_of_resolutions;
i++)
522 auto intrins =
intrinsics.resolution.intrinsic_resolution[
i];
523 intrinsics_data.
data.push_back(intrins.raw.pinhole_cam_model.width);
524 intrinsics_data.
data.push_back(intrins.raw.pinhole_cam_model.height);
525 intrinsics_data.
data.push_back(intrins.raw.zo.x);
526 intrinsics_data.
data.push_back(intrins.raw.zo.y);
528 intrinsics_data.
data.push_back(intrins.world.pinhole_cam_model.width);
529 intrinsics_data.
data.push_back(intrins.world.pinhole_cam_model.height);
530 intrinsics_data.
data.push_back(intrins.world.zo.x);
531 intrinsics_data.
data.push_back(intrins.world.zo.y);
534 intrinsics_data.
data.push_back(l500_depth_sensor->read_baseline());
540 #define RETURN_IF_EXTENSION(E, T)\ 541 if (Is<ExtensionToType<T>::type>(E))\ 555 #undef RETURN_IF_EXTENSION 563 for (
auto block : proccesing_blocks->get_recommended_processing_blocks())
571 catch (std::exception&
e)
573 LOG_WARNING(
"Failed to write proccesing block " <<
" for sensor " << sensor_id.
sensor_index <<
". Exception: " << e.what());
579 catch (std::exception&
e)
581 LOG_WARNING(
"Failed to get or write recommended proccesing blocks " <<
" for sensor " << sensor_id.
sensor_index <<
". Exception: " << e.what());
589 return (*reinterpret_cast<char*>(&num) == 1) ? 0 : 1;
virtual rs2_metadata_type get_frame_metadata(const rs2_frame_metadata_value &frame_metadata) const =0
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
constexpr uint32_t get_file_version()
static std::string frame_data_topic(const device_serializer::stream_identifier &stream_id)
void write_extension_snapshot(uint32_t device_id, const nanoseconds ×tamp, rs2_extension type, std::shared_ptr< librealsense::extension_snapshot > snapshot)
void write_pose_frame(const stream_identifier &stream_id, const nanoseconds ×tamp, frame_holder &&frame)
virtual rs2_timestamp_domain get_frame_timestamp_domain() const =0
static std::string post_processing_blocks_topic(const device_serializer::sensor_identifier &sensor_id)
void write_sensor_options(device_serializer::sensor_identifier sensor_id, const nanoseconds ×tamp, std::shared_ptr< options_interface > options)
constexpr const char * FRAME_NUMBER_MD_STR
static std::string l500_data_blocks_topic(const device_serializer::sensor_identifier &sensor_id)
const char * get_string(rs2_rs400_visual_preset value)
virtual const char * get_description() const =0
static std::string sensor_info_topic(const device_serializer::sensor_identifier &sensor_id)
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
_linear_acceleration_type linear_acceleration
#define RETURN_IF_EXTENSION(E, T)
rs2_notification_category category
void write_streaming_info(nanoseconds timestamp, const sensor_identifier &sensor_id, std::shared_ptr< video_stream_profile_interface > profile)
void open(std::string const &filename, uint32_t mode=bagmode::Read)
Open a bag file.
constexpr const char * FRAME_TIMESTAMP_MD_STR
static std::string stream_extrinsic_topic(const device_serializer::stream_identifier &stream_id, uint32_t ref_id)
const char * rs2_distortion_to_string(rs2_distortion distortion)
std::map< uint32_t, std::set< rs2_option > > m_written_options_descriptions
realsense_msgs::Notification to_notification_msg(const notification &n)
static std::string video_stream_info_topic(const device_serializer::stream_identifier &stream_id)
void write_file_version()
_description_type description
void convert(rs2_format source, std::string &target)
void write_frame(const stream_identifier &stream_id, const nanoseconds ×tamp, frame_holder &&frame) override
static std::string device_info_topic(uint32_t device_id)
GLsizei const GLchar *const * string
constexpr const char * TRACKER_CONFIDENCE_MD_STR
void write_stream_info(nanoseconds timestamp, const sensor_identifier &sensor_id, std::shared_ptr< stream_profile_interface > profile)
virtual float query() const =0
rs2_extension get_processing_block_extension(const std::shared_ptr< processing_block_interface > block)
std::map< rs2_extension, std::shared_ptr< extension_snapshot > > get_snapshots() const
_serialized_data_type serialized_data
GLenum GLenum GLsizei void * image
static uint8_t is_big_endian()
void write_motion_frame(const stream_identifier &stream_id, const nanoseconds ×tamp, frame_holder &&frame)
def info(name, value, persistent=False)
std::map< stream_identifier, geometry_msgs::Transform > m_extrinsics_msgs
ros_writer(const std::string &file, bool compress_while_record)
void write_extrinsics(const stream_identifier &stream_id, frame_interface *frame)
const std::string & get_file_name() const override
static std::string pose_accel_topic(const device_serializer::stream_identifier &stream_id)
const char * rs2_extension_type_to_string(rs2_extension type)
static std::string notification_topic(const device_serializer::sensor_identifier &sensor_id, rs2_notification_category nc)
void setCompression(CompressionType compression)
Set the compression method to use for writing chunks.
void write_sensor_processing_blocks(device_serializer::sensor_identifier sensor_id, const nanoseconds ×tamp, std::shared_ptr< recommended_proccesing_blocks_interface > proccesing_blocks)
void write_additional_frame_messages(const stream_identifier &stream_id, const nanoseconds ×tamp, frame_interface *frame)
geometry_msgs::Vector3 to_vector3(const float3 &f)
static std::string file_version_topic()
void write_notification(const sensor_identifier &sensor_id, const nanoseconds ×tamp, const notification &n) override
constexpr const char * SYSTEM_TIME_MD_STR
static std::string imu_intrinsic_topic(const device_serializer::stream_identifier &stream_id)
_bias_variances_type bias_variances
constexpr const char * MAPPER_CONFIDENCE_MD_STR
virtual std::shared_ptr< sensor_interface > get_sensor() const =0
constexpr const char * TIMESTAMP_DOMAIN_MD_STR
std::chrono::duration< uint64_t, std::nano > nanoseconds
static std::string pose_twist_topic(const device_serializer::stream_identifier &stream_id)
static std::string frame_metadata_topic(const device_serializer::stream_identifier &stream_id)
float3 transform(const rs2_extrinsics *extrin, const float3 &point)
_distortion_model_type distortion_model
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
void write_snapshot(uint32_t device_index, const nanoseconds ×tamp, rs2_extension type, const std::shared_ptr< extension_snapshot > &snapshot) override
LOG_INFO("Log message using LOG_INFO()")
virtual std::shared_ptr< stream_profile_interface > get_stream() const =0
void write_device_description(const librealsense::device_snapshot &device_description) override
const char * rs2_camera_info_to_string(rs2_camera_info info)
_angular_velocity_type angular_velocity
GLdouble GLdouble GLdouble q
constexpr device_serializer::nanoseconds get_static_file_info_timestamp()
static std::string option_value_topic(const device_serializer::sensor_identifier &sensor_id, rs2_option option_type)
virtual rs2_time_t get_frame_system_time() const =0
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
void write_frame_metadata(const stream_identifier &stream_id, const nanoseconds ×tamp, frame_interface *frame)
_noise_variances_type noise_variances
std::string serialized_data
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
static std::string option_description_topic(const device_serializer::sensor_identifier &sensor_id, rs2_option option_type)
void write_video_frame(const stream_identifier &stream_id, const nanoseconds ×tamp, frame_holder &&frame)
_is_bigendian_type is_bigendian
_is_recommended_type is_recommended
Motion device intrinsics: scale, bias, and variances.
std::ios_base & hexfloat(std::ios_base &str)
geometry_msgs::Quaternion to_quaternion(const float4 &f)
static std::string pose_transform_topic(const device_serializer::stream_identifier &stream_id)
_timestamp_type timestamp
::std_msgs::Time_< std::allocator< void > > Time
snapshot_collection get_device_extensions_snapshots() const
rs2_log_severity severity
std::vector< sensor_snapshot > get_sensors_snapshots() const
void write_message(std::string const &topic, nanoseconds const &time, T const &msg)
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
void write_l500_data(device_serializer::sensor_identifier sensor_id, const nanoseconds ×tamp, std::shared_ptr< l500_depth_sensor_interface > l500_depth_sensor)
void write_sensor_option(device_serializer::sensor_identifier sensor_id, const nanoseconds ×tamp, rs2_option type, const librealsense::option &option)
void copy(void *dst, void const *src, size_t size)
void write_vendor_info(const std::string &topic, nanoseconds timestamp, std::shared_ptr< info_interface > info_snapshot)
virtual bool supports_frame_metadata(const rs2_frame_metadata_value &frame_metadata) const =0
constexpr uint32_t get_device_index()
static std::string stream_info_topic(const device_serializer::stream_identifier &stream_id)
std::string to_string(T value)