Skip to content

Commit

Permalink
D457 Segfault when calling get_motion_intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az committed Aug 8, 2023
1 parent 1c5c9f3 commit fa5fe4f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 14 deletions.
15 changes: 6 additions & 9 deletions src/ds/d400/d400-motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ namespace librealsense
return _ds_motion_common->create_hid_device(ctx, all_hid_infos, camera_fw_version, _tf_keeper);
}

rs2_motion_device_intrinsic d400_motion::get_motion_intrinsics(rs2_stream stream) const
{
return d400_motion_base::get_motion_intrinsics(stream);
}

d400_motion_base::d400_motion_base(std::shared_ptr<context> ctx,
const platform::backend_device_group& group)
: device(ctx, group),
Expand All @@ -119,7 +114,7 @@ namespace librealsense

std::vector<platform::hid_device_info> hid_infos = group.hid_devices;

_ds_motion_common->init_hid(hid_infos, *_depth_stream);
_ds_motion_common->init_motion(hid_infos.empty(), *_depth_stream);

initialize_fisheye_sensor(ctx,group);

Expand All @@ -136,14 +131,16 @@ namespace librealsense

d400_motion_uvc::d400_motion_uvc(std::shared_ptr<context> ctx,
const platform::backend_device_group& group)
: d400_motion_base(ctx, group),
device(ctx, group),
d400_device(ctx, group)
: device(ctx, group),
d400_device(ctx, group),
d400_motion_base(ctx, group)
{
using namespace ds;

std::vector<platform::uvc_device_info> uvc_infos = group.uvc_devices;

_ds_motion_common->init_motion(uvc_infos.empty(), *_depth_stream);

if (!uvc_infos.empty())
{
// product id - D457 dev - check - must not be the front of uvc_infos vector
Expand Down
2 changes: 0 additions & 2 deletions src/ds/d400/d400-motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ namespace librealsense
const std::vector<platform::hid_device_info>& all_hid_infos,
const firmware_version& camera_fw_version);

rs2_motion_device_intrinsic get_motion_intrinsics(rs2_stream) const;

protected:
friend class ds_motion_common;
friend class ds_fisheye_sensor;
Expand Down
4 changes: 2 additions & 2 deletions src/ds/ds-motion-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ namespace librealsense
return hid_ep;
}

void ds_motion_common::init_hid(const std::vector<platform::hid_device_info>& hid_infos, const stream_interface& depth_stream)
void ds_motion_common::init_motion(bool is_infos_empty, const stream_interface& depth_stream)
{
if (!hid_infos.empty())
if (!is_infos_empty)
{
// motion correction
_mm_calib = std::make_shared<mm_calib_handler>(_hw_monitor, _owner->_pid);
Expand Down
2 changes: 1 addition & 1 deletion src/ds/ds-motion-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace librealsense
const firmware_version& camera_fw_version,
std::shared_ptr<time_diff_keeper> tf_keeper);

void init_hid(const std::vector<platform::hid_device_info>& hid_infos, const stream_interface& depth_stream);
void init_motion(bool is_infos_empty, const stream_interface& depth_stream);

const std::vector<uint8_t>& get_fisheye_calibration_table() const;

Expand Down
40 changes: 40 additions & 0 deletions unit-tests/live/intrinsics/test-motion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2023 Intel Corporation. All Rights Reserved.

# test:device:jetson D457
# test:device:!jetson D455
# This test check existence motion intrinsic data in accel and gyro profiles.

import pyrealsense2 as rs
from rspy import test, log

device = test.find_first_device_or_exit()
motion_sensor = device.first_motion_sensor()

test.start('Check intrinsics in motion sensor:')

test.check(motion_sensor)

if motion_sensor:

motion_profile_accel = next(p for p in motion_sensor.profiles if p.stream_type() == rs.stream.accel)
motion_profile_gyro = next(p for p in motion_sensor.profiles if p.stream_type() == rs.stream.gyro)

test.check(motion_profile_accel and motion_profile_gyro)

if motion_profile_accel:
motion_profile_accel = motion_profile_accel.as_motion_stream_profile()
intrinsics_accel = motion_profile_accel.get_motion_intrinsics()

log.d(str(intrinsics_accel))
test.check(len(str(intrinsics_accel)) > 0) # Checking if intrinsics has data

if motion_profile_gyro:
motion_profile_gyro = motion_profile_gyro.as_motion_stream_profile()
intrinsics_gyro = motion_profile_gyro.get_motion_intrinsics()

log.d(intrinsics_gyro)
test.check(len(str(intrinsics_gyro)) > 0) # Checking if intrinsics has data

test.finish()
test.print_results_and_exit()

0 comments on commit fa5fe4f

Please sign in to comment.