Add imu parameter README

This commit is contained in:
Joe Dong
2023-08-23 17:14:08 +08:00
parent 8a81d30428
commit a623d4a4ca
5 changed files with 115 additions and 7 deletions
@@ -57,10 +57,16 @@ OBSyncMode OBSyncModeFromString(const std::string& mode);
OB_SAMPLE_RATE sampleRateFromString(std::string& sample_rate);
std::string sampleRateToString(const OB_SAMPLE_RATE &sample_rate);
OB_GYRO_FULL_SCALE_RANGE fullGyroScaleRangeFromString(std::string& full_scale_range);
std::string fullGyroScaleRangeToString(const OB_GYRO_FULL_SCALE_RANGE &full_scale_range);
OBAccelFullScaleRange fullAccelScaleRangeFromString(std::string& full_scale_range);
std::string fullAccelScaleRangeToString(const OBAccelFullScaleRange &full_scale_range);
std::string parseUsbPort(const std::string& line);
} // namespace orbbec_camera
+6 -7
View File
@@ -3,8 +3,9 @@
#include <orbbec_camera/ob_camera_node_driver.h>
#include <memory>
#include <magic_enum/magic_enum.hpp>
#include <orbbec_camera/utils.h>
int main() {
using namespace orbbec_camera;
auto context = std::make_unique<ob::Context>();
context->setLoggerSeverity(OBLogSeverity::OB_LOG_SEVERITY_NONE);
auto device_list = context->queryDeviceList();
@@ -37,16 +38,14 @@ int main() {
auto profile = origin_profile->as<ob::AccelStreamProfile>();
RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"),
"accel profile: sampleRate "
<< magic_enum::enum_name(profile->sampleRate())
<< " full scale_range "
<< magic_enum::enum_name(profile->fullScaleRange()));
<< sampleRateToString(profile->sampleRate()) << " full scale_range "
<< fullAccelScaleRangeToString(profile->fullScaleRange()));
} else if (sensor->type() == OB_SENSOR_GYRO) {
auto profile = origin_profile->as<ob::GyroStreamProfile>();
RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"),
"gyro profile: sampleRate "
<< magic_enum::enum_name(profile->sampleRate())
<< " full scale_range "
<< magic_enum::enum_name(profile->fullScaleRange()));
<< sampleRateToString(profile->sampleRate()) << " full scale_range "
<< fullGyroScaleRangeToString(profile->fullScaleRange()));
} else {
RCLCPP_INFO_STREAM(rclcpp::get_logger("list_device_node"),
"unknown profile: " << magic_enum::enum_name(sensor->type()));
+75
View File
@@ -342,6 +342,43 @@ OB_SAMPLE_RATE sampleRateFromString(std::string &sample_rate) {
}
}
std::string sampleRateToString(const OB_SAMPLE_RATE &sample_rate) {
switch (sample_rate) {
case OB_SAMPLE_RATE_1_5625_HZ:
return "1.5625hz";
case OB_SAMPLE_RATE_3_125_HZ:
return "3.125hz";
case OB_SAMPLE_RATE_6_25_HZ:
return "6.25hz";
case OB_SAMPLE_RATE_12_5_HZ:
return "12.5hz";
case OB_SAMPLE_RATE_25_HZ:
return "25hz";
case OB_SAMPLE_RATE_50_HZ:
return "50hz";
case OB_SAMPLE_RATE_100_HZ:
return "100hz";
case OB_SAMPLE_RATE_200_HZ:
return "200hz";
case OB_SAMPLE_RATE_500_HZ:
return "500hz";
case OB_SAMPLE_RATE_1_KHZ:
return "1khz";
case OB_SAMPLE_RATE_2_KHZ:
return "2khz";
case OB_SAMPLE_RATE_4_KHZ:
return "4khz";
case OB_SAMPLE_RATE_8_KHZ:
return "8khz";
case OB_SAMPLE_RATE_16_KHZ:
return "16khz";
case OB_SAMPLE_RATE_32_KHZ:
return "32khz";
default:
return "100hz";
}
}
OB_GYRO_FULL_SCALE_RANGE fullGyroScaleRangeFromString(std::string &full_scale_range) {
std::transform(full_scale_range.begin(), full_scale_range.end(), full_scale_range.begin(),
::tolower);
@@ -368,6 +405,29 @@ OB_GYRO_FULL_SCALE_RANGE fullGyroScaleRangeFromString(std::string &full_scale_ra
}
}
std::string fullGyroScaleRangeToString(const OB_GYRO_FULL_SCALE_RANGE &full_scale_range) {
switch (full_scale_range) {
case OB_GYRO_FS_16dps:
return "16dps";
case OB_GYRO_FS_31dps:
return "31dps";
case OB_GYRO_FS_62dps:
return "62dps";
case OB_GYRO_FS_125dps:
return "125dps";
case OB_GYRO_FS_250dps:
return "250dps";
case OB_GYRO_FS_500dps:
return "500dps";
case OB_GYRO_FS_1000dps:
return "1000dps";
case OB_GYRO_FS_2000dps:
return "2000dps";
default:
return "16dps";
}
}
OBAccelFullScaleRange fullAccelScaleRangeFromString(std::string &full_scale_range) {
std::transform(full_scale_range.begin(), full_scale_range.end(), full_scale_range.begin(),
::tolower);
@@ -386,6 +446,21 @@ OBAccelFullScaleRange fullAccelScaleRangeFromString(std::string &full_scale_rang
}
}
std::string fullAccelScaleRangeToString(const OBAccelFullScaleRange &full_scale_range) {
switch (full_scale_range) {
case OB_ACCEL_FS_2g:
return "2g";
case OB_ACCEL_FS_4g:
return "4g";
case OB_ACCEL_FS_8g:
return "8g";
case OB_ACCEL_FS_16g:
return "16g";
default:
return "2g";
}
}
std::string parseUsbPort(const std::string &line) {
std::string port_id;
std::regex self_regex("(?:[^ ]+/usb[0-9]+[0-9./-]*/){0,1}([0-9.-]+)(:){0,1}[^ ]*",