63 if (!try_parse(source, target))
65 LOG_INFO(
"Failed to convert source: " << source <<
" to matching " <<
typeid(
T).
name());
77 bool mapped_format =
false;
111 std::transform(source_alias.begin(), source_alias.end(), source_alias.begin(), ::toupper);
114 if (!(ret = try_parse(source_alias, target)))
116 LOG_INFO(
"Failed to convert source: " << source <<
" to matching rs2_format");
125 return std::isfinite(target);
148 r[0] = 1 - 2 * q.
y*q.
y - 2 * q.
z*q.
z;
149 r[3] = 2 * q.
x*q.
y - 2 * q.
z*q.
w;
150 r[6] = 2 * q.
x*q.
z + 2 * q.
y*q.
w;
151 r[1] = 2 * q.
x*q.
y + 2 * q.
z*q.
w;
152 r[4] = 1 - 2 * q.
x*q.
x - 2 * q.
z*q.
z;
153 r[7] = 2 * q.
y*q.
z - 2 * q.
x*q.
w;
154 r[2] = 2 * q.
x*q.
z - 2 * q.
y*q.
w;
155 r[5] = 2 * q.
y*q.
z + 2 * q.
x*q.
w;
156 r[8] = 1 - 2 * q.
x*q.
x - 2 * q.
y*q.
y;
161 auto m = (float(&)[3][3])
r;
163 tr[0] = (
m[0][0] +
m[1][1] +
m[2][2]);
164 tr[1] = (
m[0][0] -
m[1][1] -
m[2][2]);
165 tr[2] = (-
m[0][0] +
m[1][1] -
m[2][2]);
166 tr[3] = (-
m[0][0] -
m[1][1] +
m[2][2]);
167 if (tr[0] >= tr[1] && tr[0]>= tr[2] && tr[0] >= tr[3]) {
168 float s = 2 * std::sqrt(tr[0] + 1);
170 q.
x = (
m[2][1] -
m[1][2]) / s;
171 q.
y = (
m[0][2] -
m[2][0]) / s;
172 q.
z = (
m[1][0] -
m[0][1]) / s;
173 }
else if (tr[1] >= tr[2] && tr[1] >= tr[3]) {
174 float s = 2 * std::sqrt(tr[1] + 1);
175 q.
w = (
m[2][1] -
m[1][2]) / s;
177 q.
y = (
m[1][0] +
m[0][1]) / s;
178 q.
z = (
m[2][0] +
m[0][2]) / s;
179 }
else if (tr[2] >= tr[3]) {
180 float s = 2 * std::sqrt(tr[2] + 1);
181 q.
w = (
m[0][2] -
m[2][0]) / s;
182 q.
x = (
m[1][0] +
m[0][1]) / s;
184 q.
z = (
m[1][2] +
m[2][1]) / s;
186 float s = 2 * std::sqrt(tr[3] + 1);
187 q.
w = (
m[1][0] -
m[0][1]) / s;
188 q.
x = (
m[0][2] +
m[2][0]) / s;
189 q.
y = (
m[1][2] +
m[2][1]) / s;
230 return get_id(
"device_", get<1>(topic));
235 return get_id(
"sensor_", get<2>(topic));
240 auto stream_with_id = get<3>(topic);
242 convert(stream_with_id.substr(0, stream_with_id.find_first_of(
"_")), type);
248 auto stream_with_id = get<3>(topic);
249 return get_id(stream_with_id.substr(0, stream_with_id.find_first_of(
"_") + 1), get<3>(topic));
269 return get<4>(topic);
306 std::replace(topic_name.begin(), topic_name.end(),
' ',
'_');
324 std::replace(topic_name.begin(), topic_name.end(),
' ',
'_');
375 template<u
int32_t index>
378 size_t current_pos = 0;
384 auto token = value_copy.substr(0, current_pos);
385 if (elements_iterator ==
index)
389 value_copy.erase(0, current_pos + seperator_length);
393 if (elements_iterator ==
index)
396 throw std::out_of_range(
to_string() <<
"Requeted index \"" <<
index <<
"\" is out of bound of topic: \"" <<
value <<
"\"");
421 std::ostringstream oss;
423 if (parts.empty() ==
false)
434 if (str.compare(0, prefix.size(), prefix) != 0)
436 throw std::runtime_error(
"Failed to get id after prefix \"" + prefix +
"\"from string \"" + str +
"\"");
467 for (
auto&& regexp : regexps)
469 LOG_DEBUG(
"RegexTopicQuery with expression: " << regexp);
470 _exps.emplace_back(regexp);
524 <<
"/(" << data_msg_types() <<
")/data")
588 auto secs = std::chrono::duration_cast<std::chrono::duration<double>>(
t);
592 namespace legacy_file_format
594 constexpr
const char*
USB_DESCRIPTOR =
"{ 0x94b5fb99, 0x79f2, 0x4d66,{ 0x85, 0x06, 0xb1, 0x5e, 0x8b, 0x8c, 0x9d, 0xa1 } }";
595 constexpr
const char*
DEVICE_INTERFACE_VERSION =
"{ 0xafcd9c11, 0x52e3, 0x4258,{ 0x8d, 0x23, 0xbe, 0x86, 0xfa, 0x97, 0xa0, 0xab } }";
596 constexpr
const char*
FW_VERSION =
"{ 0x7b79605b, 0x5e36, 0x4abe,{ 0xb1, 0x01, 0x94, 0x86, 0xb8, 0x9a, 0xfe, 0xbe } }";
597 constexpr
const char*
CENTRAL_VERSION =
"{ 0x5652ffdb, 0xacac, 0x47ea,{ 0xbf, 0x65, 0x73, 0x3e, 0xf3, 0xd9, 0xe2, 0x70 } }";
598 constexpr
const char*
CENTRAL_PROTOCOL_VERSION =
"{ 0x50376dea, 0x89f4, 0x4d70,{ 0xb1, 0xb0, 0x05, 0xf6, 0x07, 0xb6, 0xae, 0x8a } }";
599 constexpr
const char*
EEPROM_VERSION =
"{ 0x4617d177, 0xb546, 0x4747,{ 0x9d, 0xbf, 0x4f, 0xf8, 0x99, 0x0c, 0x45, 0x6b } }";
600 constexpr
const char*
ROM_VERSION =
"{ 0x16a64010, 0xfee4, 0x4c67,{ 0xae, 0xc5, 0xa0, 0x4d, 0xff, 0x06, 0xeb, 0x0b } }";
601 constexpr
const char*
TM_DEVICE_TYPE =
"{ 0x1212e1d5, 0xfa3e, 0x4273,{ 0x9e, 0xbf, 0xe4, 0x43, 0x87, 0xbe, 0xe5, 0xe8 } }";
602 constexpr
const char*
HW_VERSION =
"{ 0x4439fcca, 0x8673, 0x4851,{ 0x9b, 0xb6, 0x1a, 0xab, 0xbd, 0x74, 0xbd, 0xdc } }";
603 constexpr
const char*
STATUS =
"{ 0x5d6c6637, 0x28c7, 0x4a90,{ 0xab, 0x35, 0x90, 0xb2, 0x1f, 0x1a, 0xe6, 0xb8 } }";
604 constexpr
const char*
STATUS_CODE =
"{ 0xe22a94a6, 0xed64, 0x46ea,{ 0x81, 0x52, 0x6a, 0xb3, 0x0b, 0x0e, 0x2a, 0x18 } }";
605 constexpr
const char*
EXTENDED_STATUS =
"{ 0xff6e50db, 0x3c5f, 0x43e7,{ 0xb4, 0x82, 0xb8, 0xc3, 0xa6, 0x8e, 0x78, 0xcd } }";
606 constexpr
const char*
SERIAL_NUMBER =
"{ 0x7d3e44e7, 0x8970, 0x4a32,{ 0x8e, 0xee, 0xe8, 0xd1, 0xd1, 0x32, 0xa3, 0x22 } }";
607 constexpr
const char*
TIMESTAMP_SORT_TYPE =
"{ 0xb409b217, 0xe5cd, 0x4a04,{ 0x9e, 0x85, 0x1a, 0x7d, 0x59, 0xd7, 0xe5, 0x61 } }";
609 constexpr
const char*
DEPTH =
"DEPTH";
610 constexpr
const char*
COLOR =
"COLOR";
613 constexpr
const char*
ACCEL =
"ACCLEROMETER";
614 constexpr
const char*
GYRO =
"GYROMETER";
615 constexpr
const char*
POSE =
"rs_6DoF";
666 throw std::runtime_error(
to_string() <<
"Unknown timestamp domain: " << source);
671 const size_t number_of_hexadecimal_values_in_a_guid = 11;
672 const std::string left_group = R
"RE(\s*(0x[0-9a-fA-F]{1,8})\s*,\s*(0x[0-9a-fA-F]{1,4})\s*,\s*(0x[0-9a-fA-F]{1,4})\s*,\s*)RE"; 673 const std::string right_group = R
"RE(\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*,\s*(0x[0-9a-fA-F]{1,2})\s*)RE"; 674 const std::string guid_regex_pattern = R
"RE(\{)RE" + left_group + R"RE(\{)RE" + right_group + R"RE(\}\s*\})RE"; 677 std::regex reg(guid_regex_pattern, std::regex_constants::icase);
678 const std::map<rs2_camera_info, const char*> legacy_infos{
683 for (
auto&&
s : legacy_infos)
685 if (std::regex_match(
s.second, reg))
727 if (source.
index == 1)
780 auto index_str = source.substr(type_str.length());
781 if (index_str.empty())
790 retval.index =
index;
804 to_string() << R
"RRR(/(camera|imu)/.*/(image|imu)_raw/\d+)RRR" , 805 to_string() << R"RRR(/camera/rs_6DoF\d+/\d+)RRR" }) {} 823 << (
is_camera(stream_id.stream_type) ?
"/camera/" :
"/imu/")
836 << (
is_camera(stream_id.stream_type) ?
"/camera/" :
"/imu/")
838 <<
"/rs_frame_info_ext/" <<
stream_id.sensor_index)
856 return "/FILE_VERSION";
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)
const char * rs2_format_to_string(rs2_format format)
SensorInfoQuery(uint32_t device_index)
void rot2quat(const float(&r)[9], geometry_msgs::Transform::_rotation_type &q)
static std::string post_processing_blocks_topic(const device_serializer::sensor_identifier &sensor_id)
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)
GLuint const GLchar * name
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...
static std::string get_option_name(const std::string &topic)
std::vector< std::regex > _exps
device_serializer::nanoseconds to_nanoseconds(const rs2rosinternal::Time &t)
static std::string stream_to_ros_type(rs2_stream type)
rs2rosinternal::Time to_rostime(const device_serializer::nanoseconds &t)
const char * rs2_option_to_string(rs2_option option)
constexpr const char * FRAME_TIMESTAMP_MD_STR
static std::string stream_extrinsic_topic(const device_serializer::stream_identifier &stream_id, uint32_t ref_id)
static uint32_t get_device_index(const std::string &topic)
static uint32_t get_sensor_index(const std::string &topic)
static std::string video_stream_info_topic(const device_serializer::stream_identifier &stream_id)
void convert(rs2_format source, std::string &target)
static std::string additional_info_topic()
static uint32_t get_id(const std::string &prefix, const std::string &str)
static std::string device_info_topic(uint32_t device_id)
const std::string TYPE_8UC1
GLsizei const GLchar *const * string
constexpr const char * TRACKER_CONFIDENCE_MD_STR
Exposes librealsense functionality for C compilers.
static std::string device_prefix(uint32_t device_id)
static device_serializer::stream_identifier get_stream_identifier(const std::string &topic)
def info(name, value, persistent=False)
RegexTopicQuery(std::string const ®exp)
static device_serializer::sensor_identifier get_sensor_identifier(const std::string &topic)
static std::string stream_prefix(const device_serializer::stream_identifier &stream_id)
static constexpr const char * ros_pose_type_str()
static std::string pose_accel_topic(const device_serializer::stream_identifier &stream_id)
bool operator()(rosbag::ConnectionInfo const *info) const
Time representation. May either represent wall clock time or ROS clock time.
static std::string notification_topic(const device_serializer::sensor_identifier &sensor_id, rs2_notification_category nc)
unsigned __int64 uint64_t
const std::string TYPE_16UC1
rs2_format
A stream's format identifies how binary data is encoded within a frame.
static std::string file_version_topic()
void quat2rot(const geometry_msgs::Transform::_rotation_type &q, float(&r)[9])
static constexpr const char * ros_imu_type_str()
static std::string property_topic(const device_serializer::sensor_identifier &sensor_id)
constexpr const char * SYSTEM_TIME_MD_STR
ExtrinsicsQuery(const device_serializer::stream_identifier &stream_id)
static std::string stream_prefix(rs2_stream type, uint32_t stream_id)
static std::string imu_intrinsic_topic(const device_serializer::stream_identifier &stream_id)
constexpr const char * MAPPER_CONFIDENCE_MD_STR
rs2_stream
Streams are different types of data provided by RealSense devices.
StreamQuery(const device_serializer::stream_identifier &stream_id)
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)
bool operator()(rosbag::ConnectionInfo const *info) const
static std::string frame_metadata_topic(const device_serializer::stream_identifier &stream_id)
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
LOG_INFO("Log message using LOG_INFO()")
static constexpr const char * ros_image_type_str()
MultipleRegexTopicQuery(const std::vector< std::string > ®exps)
GLdouble GLdouble GLdouble q
constexpr device_serializer::nanoseconds get_static_file_info_timestamp()
static uint32_t get_stream_index(const std::string &topic)
static std::string option_value_topic(const device_serializer::sensor_identifier &sensor_id, rs2_option option_type)
const char * rs2_stream_to_string(rs2_stream stream)
ROSTIME_DECL const Time TIME_MIN
rs2_notification_category
Category of the librealsense notification.
long long stoll(const std::string &value)
constexpr uint32_t get_minimum_supported_file_version()
static uint32_t get_extrinsic_group_index(const std::string &topic)
static rs2_stream get_stream_type(const std::string &topic)
static std::string option_description_topic(const device_serializer::sensor_identifier &sensor_id, rs2_option option_type)
GLsizei GLsizei GLchar * source
bool starts_with(const std::string &s, const std::string &prefix)
double stod(const std::string &value)
int stoi(const std::string &value)
static std::string sensor_prefix(uint32_t sensor_id)
GLenum GLuint GLenum GLsizei length
static std::string data_msg_types()
static constexpr const char * elements_separator()
static std::string pose_transform_topic(const device_serializer::stream_identifier &stream_id)
const char * rs2_notification_category_to_string(rs2_notification_category category)
GLuint GLenum GLenum transform
::std_msgs::Time_< std::allocator< void > > Time
static std::string create_from(const std::vector< std::string > &parts)
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
void copy(void *dst, void const *src, size_t size)
static std::string stream_info_topic(const device_serializer::stream_identifier &stream_id)
unsigned long stoul(const std::string &value)
static std::string stream_full_prefix(const device_serializer::stream_identifier &stream_id)
std::string to_string(T value)
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.