Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding SR300 derivative into SDK core #8713

Merged
merged 9 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,7 @@ namespace rs2
auto s = std::make_shared<sensor>(sub);
auto objects = std::make_shared< atomic_objects_in_frame >();
// checking if the sensor is color_sensor or is D405 (with integrated RGB in depth sensor)
if (s->is<color_sensor>() || (dev.supports(RS2_CAMERA_INFO_PRODUCT_ID) && !strcmp(dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID), "0B5B")))
if (s->is<color_sensor>() || !strcmp(dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID), "0B5B"))
objects = _detected_objects;
auto model = std::make_shared<subdevice_model>(dev, std::make_shared<sensor>(sub), objects, error_message, viewer, new_device_connected);
subdevices.push_back(model);
Expand Down
1 change: 1 addition & 0 deletions config/99-realsense-libusb.rules
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b0d", MODE:="066
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b3a", MODE:="0666", GROUP:="plugdev"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b3d", MODE:="0666", GROUP:="plugdev"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b48", MODE:="0666", GROUP:="plugdev"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0aa3", MODE:="0666", GROUP:="plugdev"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b49", MODE:="0666", GROUP:="plugdev"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b4b", MODE:="0666", GROUP:="plugdev"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0b4d", MODE:="0666", GROUP:="plugdev"
Expand Down
2 changes: 1 addition & 1 deletion src/ivcam/ivcam-private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace librealsense
{

result = *it;
if(result.mi == 4)
if(result.mi == 4 || result.mi == 2)
{
devices.erase(it);
return true;
Expand Down
141 changes: 97 additions & 44 deletions src/ivcam/sr300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ namespace librealsense
return std::make_shared<sr305_camera>(ctx, _color, _depth, _hwm,
this->get_device_data(),
register_device_notifications);
case SR306_PID:
return std::make_shared<sr306_camera>(ctx, _depth, _hwm,
this->get_device_data(),
register_device_notifications);
default:
throw std::runtime_error(to_string() << "Unsupported SR300 model! 0x"
<< std::hex << std::setw(4) << std::setfill('0') << (int)pid);
Expand All @@ -69,34 +73,36 @@ namespace librealsense
std::vector<platform::uvc_device_info> chosen;
std::vector<std::shared_ptr<device_info>> results;

auto correct_pid = filter_by_product(uvc, { SR300_PID, SR300v2_PID });
auto correct_pid = filter_by_product(uvc, { SR300_PID, SR300v2_PID, SR306_PID });
auto group_devices = group_devices_by_unique_id(correct_pid);
for (auto& group : group_devices)
{
if (group.size() == 2 &&
mi_present(group, 0) &&
mi_present(group, 2))
{
auto color = get_mi(group, 0);
auto depth = get_mi(group, 2);
platform::usb_device_info hwm;
platform::usb_device_info hwm;
platform::uvc_device_info dev0;
platform::uvc_device_info dev2;

if (ivcam::try_fetch_usb_device(usb, color, hwm))
{
auto info = std::make_shared<sr300_info>(ctx, color, depth, hwm);
chosen.push_back(color);
chosen.push_back(depth);
results.push_back(info);
}
else
if (mi_present(group, 0))
nohayassin marked this conversation as resolved.
Show resolved Hide resolved
{
dev0 = get_mi(group, 0);
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
chosen.push_back(dev0);
if (!ivcam::try_fetch_usb_device(usb, dev0, hwm))
{
LOG_WARNING("try_fetch_usb_device(...) failed.");
return results;
}
}
else
if (mi_present(group, 2))
{
LOG_WARNING("SR300 group_devices is empty.");
dev2 = get_mi(group, 2);
chosen.push_back(dev2);
}
if (!dev2.pid)
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
std::swap(dev0, dev2);
auto info = std::make_shared<sr300_info>(ctx, dev0, dev2, hwm);
results.push_back(info);

if (!dev0.pid && !dev2.pid)
LOG_WARNING("SR300 group_devices is empty.");
}

trim_device_list(uvc, chosen);
Expand Down Expand Up @@ -164,7 +170,7 @@ namespace librealsense
return color_ep;
}

std::shared_ptr<synthetic_sensor> sr300_camera::create_depth_device(std::shared_ptr<context> ctx,
std::shared_ptr<synthetic_sensor> sr3xx_camera::create_depth_device(std::shared_ptr<context> ctx,
const platform::uvc_device_info& depth)
{
using namespace ivcam;
Expand Down Expand Up @@ -229,7 +235,7 @@ namespace librealsense
return depth_ep;
}

rs2_intrinsics sr300_camera::make_depth_intrinsics(const ivcam::camera_calib_params & c, const int2 & dims)
rs2_intrinsics sr3xx_camera::make_depth_intrinsics(const ivcam::camera_calib_params & c, const int2 & dims)
{
return{ dims.x, dims.y, (c.Kc[0][2] * 0.5f + 0.5f) * dims.x,
(c.Kc[1][2] * 0.5f + 0.5f) * dims.y,
Expand Down Expand Up @@ -261,37 +267,37 @@ namespace librealsense
return intrin;
}

float sr300_camera::read_mems_temp() const
float sr3xx_camera::read_mems_temp() const
{
command command(ivcam::fw_cmd::GetMEMSTemp);
auto data = _hw_monitor->send(command);
auto t = *reinterpret_cast<int32_t *>(data.data());
return static_cast<float>(t) / 100;
}

int sr300_camera::read_ir_temp() const
int sr3xx_camera::read_ir_temp() const
{
command command(ivcam::fw_cmd::GetIRTemp);
auto data = _hw_monitor->send(command);
return static_cast<int8_t>(data[0]);
}

void sr300_camera::force_hardware_reset() const
void sr3xx_camera::force_hardware_reset() const
{
command cmd(ivcam::fw_cmd::HWReset);
cmd.require_response = false;
_hw_monitor->send(cmd);
}

void sr300_camera::enable_timestamp(bool colorEnable, bool depthEnable) const
void sr3xx_camera::enable_timestamp(bool colorEnable, bool depthEnable) const
{
command cmd(ivcam::fw_cmd::TimeStampEnable);
cmd.param1 = depthEnable ? 1 : 0;
cmd.param2 = colorEnable ? 1 : 0;
_hw_monitor->send(cmd);
}

void sr300_camera::set_auto_range(const ivcam::cam_auto_range_request& c) const
void sr3xx_camera::set_auto_range(const ivcam::cam_auto_range_request& c) const
{
command cmd(ivcam::fw_cmd::SetAutoRange);
cmd.param1 = c.enableMvR;
Expand Down Expand Up @@ -322,7 +328,7 @@ namespace librealsense
_hw_monitor->send(cmd);
}

void sr300_camera::enter_update_state() const
void sr3xx_camera::enter_update_state() const
{
// Stop all data streaming/exchange pipes with HW
stop_activity();
Expand Down Expand Up @@ -350,7 +356,7 @@ namespace librealsense
}
}

std::vector<uint8_t> sr300_camera::backup_flash(update_progress_callback_ptr callback)
std::vector<uint8_t> sr3xx_camera::backup_flash(update_progress_callback_ptr callback)
{
// TODO: Refactor, unify with DS version
int flash_size = 1024 * 2048;
Expand Down Expand Up @@ -397,7 +403,7 @@ namespace librealsense
return flash;
}

void sr300_camera::update_flash(const std::vector<uint8_t>&, update_progress_callback_ptr, int)
void sr3xx_camera::update_flash(const std::vector<uint8_t>&, update_progress_callback_ptr, int)
{
throw std::runtime_error("update_flash is not supported by SR300");
}
Expand All @@ -421,7 +427,7 @@ namespace librealsense
TakeFromRAM = 2
};

ivcam::camera_calib_params sr300_camera::get_calibration() const
ivcam::camera_calib_params sr3xx_camera::get_calibration() const
{
command command(ivcam::fw_cmd::GetCalibrationTable);
command.param1 = static_cast<uint32_t>(cam_data_source::TakeFromRAM);
Expand All @@ -432,7 +438,7 @@ namespace librealsense
return rawCalib.CalibrationParameters;
}

sr300_camera::sr300_camera(std::shared_ptr<context> ctx, const platform::uvc_device_info &color,
sr3xx_camera::sr3xx_camera(std::shared_ptr<context> ctx,
const platform::uvc_device_info &depth,
const platform::usb_device_info &hwm_device,
const platform::backend_device_group& group,
Expand All @@ -442,12 +448,10 @@ namespace librealsense
_depth_device_idx(add_sensor(create_depth_device(ctx, depth))),
_depth_stream(new stream(RS2_STREAM_DEPTH)),
_ir_stream(new stream(RS2_STREAM_INFRARED)),
_color_stream(new stream(RS2_STREAM_COLOR)),
_color_device_idx(add_sensor(create_color_device(ctx, color))),
_hw_monitor(std::make_shared<hw_monitor>(std::make_shared<locked_transfer>(ctx->get_backend().create_usb_device(hwm_device), get_raw_depth_sensor())))
{
using namespace ivcam;
static auto device_name = "Intel RealSense SR300";
static auto device_name = "Intel RealSense SR3xx";

// Temporal solution for HW Monitor injection - to be refactored
this->assign_hw_monitor(_hw_monitor);
Expand All @@ -458,13 +462,11 @@ namespace librealsense

auto fw_version = _hw_monitor->get_firmware_version_string(gvd_buff, fw_version_offset);
auto serial = _hw_monitor->get_module_serial_string(gvd_buff, module_serial_offset);
auto pid_hex_str = hexify(depth.pid);

_camer_calib_params = [this]() { return get_calibration(); };
enable_timestamp(true, true);

auto pid_hex_str = hexify(color.pid);
//auto recommended_fw_version = firmware_version(SR3XX_RECOMMENDED_FIRMWARE_VERSION);

register_info(RS2_CAMERA_INFO_NAME, device_name);
register_info(RS2_CAMERA_INFO_SERIAL_NUMBER, serial);
register_info(RS2_CAMERA_INFO_ASIC_SERIAL_NUMBER, serial);
Expand All @@ -475,7 +477,6 @@ namespace librealsense
register_info(RS2_CAMERA_INFO_PRODUCT_ID, pid_hex_str);
register_info(RS2_CAMERA_INFO_PRODUCT_LINE, "SR300");
register_info(RS2_CAMERA_INFO_CAMERA_LOCKED, _is_locked ? "YES" : "NO");
//register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version);

register_autorange_options();

Expand All @@ -491,11 +492,9 @@ namespace librealsense
});

environment::get_instance().get_extrinsics_graph().register_same_extrinsics(*_depth_stream, *_ir_stream);
environment::get_instance().get_extrinsics_graph().register_extrinsics(*_depth_stream, *_color_stream, _depth_to_color_extrinsics);

register_stream_to_extrinsic_group(*_depth_stream, 0);
register_stream_to_extrinsic_group(*_ir_stream, 0);
register_stream_to_extrinsic_group(*_color_stream, 0);

get_depth_sensor().register_option(RS2_OPTION_DEPTH_UNITS,
std::make_shared<const_value_option>("Number of meters represented by a single depth unit",
Expand All @@ -506,6 +505,22 @@ namespace librealsense

}

sr300_camera::sr300_camera(std::shared_ptr<context> ctx, const platform::uvc_device_info& color,
const platform::uvc_device_info& depth,
const platform::usb_device_info& hwm_device,
const platform::backend_device_group& group,
bool register_device_notifications)
: sr3xx_camera(ctx, depth, hwm_device, group, register_device_notifications),
device(ctx, group, register_device_notifications),
_color_stream(new stream(RS2_STREAM_COLOR)),
_color_device_idx(add_sensor(create_color_device(ctx, color)))
{
static auto device_name = "Intel RealSense SR300";
update_info(RS2_CAMERA_INFO_NAME, device_name);
environment::get_instance().get_extrinsics_graph().register_extrinsics(*_depth_stream, *_color_stream, _depth_to_color_extrinsics);
register_stream_to_extrinsic_group(*_color_stream, 0);
}

sr305_camera::sr305_camera(std::shared_ptr<context> ctx, const platform::uvc_device_info &color,
const platform::uvc_device_info &depth,
const platform::usb_device_info &hwm_device,
Expand All @@ -515,7 +530,9 @@ namespace librealsense
device(ctx, group, register_device_notifications) {

static auto device_name = "Intel RealSense SR305";
auto recommended_fw_version = firmware_version(SR3XX_RECOMMENDED_FIRMWARE_VERSION);
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
update_info(RS2_CAMERA_INFO_NAME, device_name);
register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version);

roi_sensor_interface* roi_sensor;
if ((roi_sensor = dynamic_cast<roi_sensor_interface*>(&get_sensor(_color_device_idx))))
Expand All @@ -524,22 +541,35 @@ namespace librealsense

}

sr306_camera::sr306_camera(std::shared_ptr<context> ctx,
const platform::uvc_device_info& depth,
const platform::usb_device_info& hwm_device,
const platform::backend_device_group& group,
bool register_device_notifications)
: sr3xx_camera(ctx, depth, hwm_device, group, register_device_notifications),
device(ctx, group, register_device_notifications) {

static auto device_name = "Intel RealSense SR306";
auto recommended_fw_version = firmware_version(SR3XX_RECOMMENDED_FIRMWARE_VERSION);
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
update_info(RS2_CAMERA_INFO_NAME, device_name);
register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version);
}

command sr300_camera::get_firmware_logs_command() const
command sr3xx_camera::get_firmware_logs_command() const
{
return command{ ivcam::GLD, 0x1f4 };
}

command sr300_camera::get_flash_logs_command() const
command sr3xx_camera::get_flash_logs_command() const
{
return command{ ivcam::FlashRead, 0x000B6000, 0x3f8 };
}

void sr300_camera::create_snapshot(std::shared_ptr<debug_interface>& snapshot) const
void sr3xx_camera::create_snapshot(std::shared_ptr<debug_interface>& snapshot) const
{
//TODO: implement
}
void sr300_camera::enable_recording(std::function<void(const debug_interface&)> record_action)
void sr3xx_camera::enable_recording(std::function<void(const debug_interface&)> record_action)
{
//TODO: implement
}
Expand Down Expand Up @@ -613,6 +643,29 @@ namespace librealsense
return (has_metadata_ts(frame)) ? RS2_TIMESTAMP_DOMAIN_HARDWARE_CLOCK : _backup_timestamp_reader->get_frame_timestamp_domain(frame);
}

std::shared_ptr<matcher> sr3xx_camera::create_matcher(const frame_holder& frame) const
{
std::vector<std::shared_ptr<matcher>> depth_matchers;

std::vector<stream_interface*> streams = { _depth_stream.get(), _ir_stream.get() };

for (auto& s : streams)
{
depth_matchers.push_back(std::make_shared<identity_matcher>(s->get_unique_id(), s->get_stream_type()));
}
std::vector<std::shared_ptr<matcher>> matchers;
if (!frame.frame->supports_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER))
{
matchers.push_back(std::make_shared<timestamp_composite_matcher>(depth_matchers));
}
else
{
matchers.push_back(std::make_shared<frame_number_composite_matcher>(depth_matchers));
}

return std::make_shared<timestamp_composite_matcher>(matchers);
}

std::shared_ptr<matcher> sr300_camera::create_matcher(const frame_holder& frame) const
{
std::vector<std::shared_ptr<matcher>> depth_matchers;
Expand All @@ -637,8 +690,8 @@ namespace librealsense
matchers.push_back(color_matcher);

return std::make_shared<timestamp_composite_matcher>(matchers);

}

processing_blocks sr300_camera::sr300_depth_sensor::get_sr300_depth_recommended_proccesing_blocks()
{
auto res = get_depth_recommended_proccesing_blocks();
Expand Down
Loading