Skip to content

Commit

Permalink
Limit alternating laser to global shutter/emitter SKUs on
Browse files Browse the repository at this point in the history
Fix EOL discrepancy
Enhance unit-test

Change-Id: If12bda3219a62fc1ef45080ceec021ef2f3621a3
  • Loading branch information
ev-mp committed Jan 20, 2019
1 parent 7c0befe commit 20cfc12
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ namespace librealsense
val |= d400_caps::CAP_IMU_SENSOR;
if (0xFF != (gvd_buf[fisheye_sensor_lb] & gvd_buf[fisheye_sensor_hb]))
val |= d400_caps::CAP_FISHEYE_SENSOR;
if (0x1 == gvd_buf[depth_sensor_type])
val |= d400_caps::CAP_ROLLING_SHUTTER; // Standard depth
if (0x2 == gvd_buf[depth_sensor_type])
val |= d400_caps::CAP_GLOBAL_SHUTTER; // Wide depth

return val;
}
Expand Down Expand Up @@ -464,7 +468,9 @@ namespace librealsense
RS2_OPTION_ASIC_TEMPERATURE));
}

if (_fw_version >= firmware_version("5.11.0.44"))
// Alternating laser pattern is applicable for global shutter/active SKUs
auto mask = d400_caps::CAP_GLOBAL_SHUTTER | d400_caps::CAP_ACTIVE_PROJECTOR;
if ((_fw_version >= firmware_version("5.11.0.44")) && ((_device_capabilities & mask) == mask))
{
depth_ep.register_option(RS2_OPTION_EMITTER_ON_OFF, std::make_shared<alternating_emitter_option>(*_hw_monitor, &depth_ep));
}
Expand Down
10 changes: 8 additions & 2 deletions src/ds5/ds5-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ namespace librealsense
CAP_RGB_SENSOR = (1u << 1), // Dedicated RGB sensor
CAP_FISHEYE_SENSOR = (1u << 2), // TM1
CAP_IMU_SENSOR = (1u << 3),
CAP_GLOBAL_SHUTTER = (1u << 4),
CAP_ROLLING_SHUTTER = (1u << 5),
CAP_MAX
};

Expand All @@ -208,7 +210,9 @@ namespace librealsense
{ d400_caps::CAP_ACTIVE_PROJECTOR, "Active Projector" },
{ d400_caps::CAP_RGB_SENSOR, "RGB Sensor" },
{ d400_caps::CAP_FISHEYE_SENSOR, "Fisheye Sensor" },
{ d400_caps::CAP_IMU_SENSOR, "IMU Sensor" }
{ d400_caps::CAP_IMU_SENSOR, "IMU Sensor" },
{ d400_caps::CAP_GLOBAL_SHUTTER, "Global Shutter" },
{ d400_caps::CAP_ROLLING_SHUTTER, "Rolling Shutter" }
};

inline d400_caps operator &(const d400_caps lhs, const d400_caps rhs)
Expand All @@ -229,7 +233,8 @@ namespace librealsense
inline std::ostream& operator <<(std::ostream& stream, const d400_caps& cap)
{
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_FISHEYE_SENSOR, d400_caps::CAP_IMU_SENSOR,
d400_caps::CAP_GLOBAL_SHUTTER, d400_caps::CAP_ROLLING_SHUTTER })
{
if (i==(i&cap))
stream << d400_capabilities_names.at(i) << " ";
Expand Down Expand Up @@ -523,6 +528,7 @@ namespace librealsense
module_serial_offset = 48,
fisheye_sensor_lb = 112,
fisheye_sensor_hb = 113,
depth_sensor_type = 166,
active_projector = 170,
rgb_sensor = 174,
imu_sensor = 178,
Expand Down
2 changes: 1 addition & 1 deletion src/win/win-hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ namespace librealsense
d.fo.metadata = &data.ts_low;
d.fo.metadata_size = HID_METADATA_SIZE;
d.fo.frame_size = sizeof(data);
d.fo.backend_time = 0;
d.fo.backend_time = 0;
if (SystemTimeToFileTime(&sys_time, &file_time))
{
auto ll_now = (LONGLONG)file_time.dwLowDateTime + ((LONGLONG)(file_time.dwHighDateTime) << 32LL) - WIN_FILETIME_2_UNIX_SYSTIME;
Expand Down
35 changes: 33 additions & 2 deletions unit-tests/unit-tests-live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4003,12 +4003,37 @@ TEST_CASE("Alternating Emitter", "[live][options]")
GIVEN("Success scenario"){

REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ON_OFF,0));
// FW Limitation - the control status update is asynchronous
std::this_thread::sleep_for(std::chrono::milliseconds(200));
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED,0));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ENABLED));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ON_OFF));

WHEN("Sequence - idle - flickering on/off")
{
THEN("Stress test succeed")
{
for (int i=0 ;i<30; i++)
{
//std::cout << "iteration " << i << " off";
// Revert to original state
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ON_OFF,0));
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED,0));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ON_OFF));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ENABLED));
//std::cout << " - on\n";
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED,1));
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ON_OFF,1));
REQUIRE(1 == depth_sensor.get_option(RS2_OPTION_EMITTER_ENABLED));
REQUIRE(1 == depth_sensor.get_option(RS2_OPTION_EMITTER_ON_OFF));
}

// Revert
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ON_OFF,0));
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED,0));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ON_OFF));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ENABLED));
}
}

WHEN("Sequence=[idle->:laser_on->: emitter_toggle_on->:streaming]") {

REQUIRE(false==static_cast<bool>(depth_sensor.get_option(RS2_OPTION_EMITTER_ON_OFF)));
Expand Down Expand Up @@ -4150,6 +4175,12 @@ TEST_CASE("Alternating Emitter", "[live][options]")
}
}
}

// Revert to original state
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ON_OFF,0));
REQUIRE_NOTHROW(depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED,0));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ON_OFF));
REQUIRE(0 == depth_sensor.get_option(RS2_OPTION_EMITTER_ENABLED));
}
}
}
Expand Down

0 comments on commit 20cfc12

Please sign in to comment.