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

Detect the new products in the SDK and Viewer: D435f, D435if, D455f, D456 #11399

Merged
merged 5 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
45 changes: 44 additions & 1 deletion src/ds/d400/d400-device.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2016 Intel Corporation. All Rights Reserved.

#include <regex>
#include <iterator>

#include "device.h"
#include "context.h"
#include "image.h"
Expand Down Expand Up @@ -446,7 +449,10 @@ namespace librealsense
// Option INTER_CAM_SYNC_MODE is not enabled in D405
if (_pid != ds::RS405_PID)
val |= d400_caps::CAP_INTERCAM_HW_SYNC;

if (gvd_buf[ip65_sealed_offset] == 0x1)
val |= d400_caps::CAP_IP65;
if (gvd_buf[ir_filter_offset] == 0x1)
val |= d400_caps::CAP_IR_FILTER;
return val;
}

Expand Down Expand Up @@ -692,6 +698,22 @@ namespace librealsense
std::make_shared<thermal_compensation>(_thermal_monitor,thermal_compensation_toggle));
}

auto ir_filter_mask = d400_caps::CAP_IR_FILTER;
if (val_in_range(_pid, { RS435_RGB_PID, RS435I_PID, RS455_PID }) &&
(_device_capabilities & ir_filter_mask) == ir_filter_mask &&
is_capability_supports(d400_caps::CAP_IR_FILTER, gvd_buff[gvd_version_offset]))
{
update_device_name(device_name, d400_caps::CAP_IR_FILTER);
}

auto ip65_mask = d400_caps::CAP_IP65;
if (val_in_range(_pid, { RS455_PID })&&
(_device_capabilities & ip65_mask) == ip65_mask &&
is_capability_supports(d400_caps::CAP_IP65, gvd_buff[gvd_version_offset]))
{
update_device_name(device_name, d400_caps::CAP_IP65);
}

std::shared_ptr<option> exposure_option = nullptr;
std::shared_ptr<option> gain_option = nullptr;
std::shared_ptr<hdr_option> hdr_enabled_option = nullptr;
Expand Down Expand Up @@ -1081,6 +1103,27 @@ namespace librealsense
//TODO: Implement
}

// Check if need change camera name due to number modifications on one device PID.
void update_device_name(std::string& device_name, const ds::d400_caps cap)
{
std::regex old_name_reg("D455");

switch (cap)
{
case ds::d400_caps::CAP_IR_FILTER:
device_name += "F"; // Adding "F" to end of device name if it has IR filter.
break;

case ds::d400_caps::CAP_IP65:
device_name = std::regex_replace(device_name, old_name_reg, "D456"); // Change device name from D455 to D456.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove line 1109 and place here:

device_name = std::regex_replace(device_name, std::regex("D455"), "D456"); // Change device name from D455 to D456.

?
The parameter at line 1109 is only relevant on this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are absolutely right. I tried your solution and VS marked it like an error, so full of pain I moved it out of "switch".
But now it worked. It happens the second time. Maybe delay in IDE.
Changed according to your suggestion.

break;

default:
throw invalid_value_exception("capability '" + ds::d400_capabilities_names.at(cap) + "' is not supported for device name update");
break;
}
}

platform::usb_spec d400_device::get_usb_spec() const
{
if(!supports_info(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR))
Expand Down
3 changes: 2 additions & 1 deletion src/ds/d400/d400-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ namespace librealsense
friend class ds5u_depth_sensor;
};


// Update device name according capability in it.
void update_device_name(std::string& device_name, const ds::d400_caps cap);
}
13 changes: 13 additions & 0 deletions src/ds/d400/d400-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,18 @@ namespace librealsense
bool d400_try_fetch_usb_device(std::vector<platform::usb_device_info>& devices,
const platform::uvc_device_info& info, platform::usb_device_info& result);

// Checks if given capability supporting by current gvd (firmware data) version.
static bool is_capability_supports(const ds::d400_caps capability, const uint8_t cur_gvd_version)
{
auto cap = ds::d400_cap_to_min_gvd_version.find(capability);
if (cap == ds::d400_cap_to_min_gvd_version.end())
{
throw invalid_value_exception("Not found capabilty in map of cabability--gvd version.");
}

uint8_t min_gvd_version = cap->second;
return min_gvd_version <= cur_gvd_version;
}

} // namespace ds
} // namespace librealsense
17 changes: 15 additions & 2 deletions src/ds/ds-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ namespace librealsense
CAP_BMI_055 = (1u << 6),
CAP_BMI_085 = (1u << 7),
CAP_INTERCAM_HW_SYNC = (1u << 8),
CAP_IP65 = (1u << 9),
CAP_IR_FILTER = (1u << 10),
CAP_MAX
};

Expand All @@ -186,7 +188,14 @@ namespace librealsense
{ d400_caps::CAP_GLOBAL_SHUTTER, "Global Shutter" },
{ d400_caps::CAP_ROLLING_SHUTTER, "Rolling Shutter" },
{ d400_caps::CAP_BMI_055, "IMU BMI_055" },
{ d400_caps::CAP_BMI_085, "IMU BMI_085" }
{ d400_caps::CAP_BMI_085, "IMU BMI_085" },
{ d400_caps::CAP_IP65, "IP65 Sealed device"},
{ d400_caps::CAP_IR_FILTER, "IR filter" }
};

static const std::map<d400_caps, std::int8_t> d400_cap_to_min_gvd_version = {
{d400_caps::CAP_IP65, 0x4},
{d400_caps::CAP_IR_FILTER, 0x4}
};

inline d400_caps operator &(const d400_caps lhs, const d400_caps rhs)
Expand Down Expand Up @@ -214,7 +223,8 @@ namespace librealsense
for (auto i : { d400_caps::CAP_ACTIVE_PROJECTOR,d400_caps::CAP_RGB_SENSOR,
d400_caps::CAP_FISHEYE_SENSOR, d400_caps::CAP_IMU_SENSOR,
d400_caps::CAP_GLOBAL_SHUTTER, d400_caps::CAP_ROLLING_SHUTTER,
d400_caps::CAP_BMI_055, d400_caps::CAP_BMI_085 })
d400_caps::CAP_BMI_055, d400_caps::CAP_BMI_085,
d400_caps::CAP_IP65, d400_caps::CAP_IR_FILTER })
{
if (i == (i & cap))
stream << d400_capabilities_names.at(i) << "/";
Expand Down Expand Up @@ -519,13 +529,16 @@ namespace librealsense
enum gvd_fields
{
// Keep sorted
gvd_version_offset = 2,
camera_fw_version_offset = 12,
is_camera_locked_offset = 25,
module_serial_offset = 48,
module_asic_serial_offset = 64,
fisheye_sensor_lb = 112,
fisheye_sensor_hb = 113,
imu_acc_chip_id = 124,
ip65_sealed_offset = 161,
ir_filter_offset = 164,
depth_sensor_type = 166,
active_projector = 170,
rgb_sensor = 174,
Expand Down