Skip to content

Commit 0d4d7bc

Browse files
committed
fix imu data
1 parent a6f90c9 commit 0d4d7bc

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/ds/d400/d400-motion.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ namespace librealsense
4141
return _ds_motion_common->get_motion_intrinsics(stream);
4242
}
4343

44+
bool d400_motion_base::is_imu_high_accuracy() const
45+
{
46+
// D400 FW 5.16 and above use 32 bits in the struct, instead of 16.
47+
return _fw_version >= firmware_version( 5, 16, 0, 0 );
48+
}
49+
50+
double d400_motion_base::get_gyro_default_scale() const
51+
{
52+
// FW scale in the HID feature report was 10 up to 5.16, changed to 1000 to support gyro sensitivity option.
53+
// D400 FW performs conversion from raw to physical, we get [deg/sec] values.
54+
return _fw_version >= firmware_version( 5, 16, 0, 0 ) ? 0.0001 : 0.1;
55+
}
56+
4457
std::shared_ptr<synthetic_sensor> d400_motion_uvc::create_uvc_device(std::shared_ptr<context> ctx,
4558
const std::vector<platform::uvc_device_info>& all_uvc_infos,
4659
const firmware_version& camera_fw_version)
@@ -88,7 +101,7 @@ namespace librealsense
88101
motion_ep->register_processing_block(
89102
{ {RS2_FORMAT_MOTION_XYZ32F} },
90103
{ {RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_ACCEL}, {RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_GYRO} },
91-
[&, mm_correct_opt, gyro_scale_factor]()
104+
[&, high_accuracy, mm_correct_opt, gyro_scale_factor]()
92105
{ return std::make_shared< motion_to_accel_gyro >( _mm_calib, mm_correct_opt, gyro_scale_factor, high_accuracy );
93106
});
94107

src/ds/d400/d400-motion.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace librealsense
1313
{
1414
public:
1515
rs2_motion_device_intrinsic get_motion_intrinsics(rs2_stream) const;
16+
bool is_imu_high_accuracy() const override;
17+
double get_gyro_default_scale() const override;
1618

1719
std::shared_ptr<auto_exposure_mechanism> register_auto_exposure_options(synthetic_sensor* ep,
1820
const platform::extension_unit* fisheye_xu);

src/proc/motion-transform.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,19 @@ namespace librealsense
166166
bool high_accuracy )
167167
: motion_transform(name, RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_ANY, mm_calib, mm_correct_opt)
168168
{
169+
static constexpr float gravity = 9.80665f; // Standard Gravitation Acceleration
170+
static constexpr double accelerator_scale_factor = 0.001 * gravity;
171+
169172
if( high_accuracy )
173+
{
170174
_converter = std::make_unique< converter_32_bit_mipi >( deg2rad( gyro_scale_factor ) );
175+
_accel_converter = std::make_unique< converter_32_bit_mipi >( accelerator_scale_factor );
176+
}
171177
else
178+
{
172179
_converter = std::make_unique< converter_16_bit_mipi >( deg2rad( gyro_scale_factor ) );
180+
_accel_converter = std::make_unique< converter_32_bit_mipi >( accelerator_scale_factor );
181+
}
173182
configure_processing_callback();
174183
}
175184

@@ -230,17 +239,18 @@ namespace librealsense
230239
if (source[0] == 1)
231240
{
232241
_target_stream = RS2_STREAM_ACCEL;
242+
_accel_converter->convert( dest, source );
233243
}
234244
else if (source[0] == 2)
235245
{
236246
_target_stream = RS2_STREAM_GYRO;
247+
_converter->convert( dest, source );
237248
}
238249
else
239250
{
240251
throw("motion_to_accel_gyro::process_function - stream type not discovered");
241252
}
242253

243-
_converter->convert( dest, source );
244254
}
245255

246256
acceleration_transform::acceleration_transform( std::shared_ptr< mm_calib_handler > mm_calib,

src/proc/motion-transform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ namespace librealsense
6767

6868
std::shared_ptr<stream_profile_interface> _source_stream_profile;
6969
std::shared_ptr<stream_profile_interface> _accel_gyro_target_profile;
70+
std::unique_ptr< imu_to_librs_converter > _accel_converter;
7071
};
7172

7273
class acceleration_transform : public motion_transform

0 commit comments

Comments
 (0)