Skip to content

Commit

Permalink
Merge pull request #5780 from maloel/freefall
Browse files Browse the repository at this point in the history
Add RS2_OPTION_FREEFALL_DETECTION_ENABLED
  • Loading branch information
ev-mp authored Feb 6, 2020
2 parents d363eb9 + 0d1bab8 commit a2f4808
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ extern "C" {
RS2_OPTION_LED_POWER, /**< Power of the LED (light emitting diode), with 0 meaning LED off*/
RS2_OPTION_ZERO_ORDER_ENABLED, /**< Toggle Zero-Order mode */
RS2_OPTION_ENABLE_MAP_PRESERVATION, /**< Preserve previous map when starting */
RS2_OPTION_FREEFALL_DETECTION_ENABLED, /**< Enable/disable sensor shutdown when a free-fall is detected (on by default) */
RS2_OPTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_option;

Expand Down
8 changes: 8 additions & 0 deletions src/l500/l500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ namespace librealsense
register_info(RS2_CAMERA_INFO_PRODUCT_ID, pid_hex_str);
register_info(RS2_CAMERA_INFO_PRODUCT_LINE, "L500");
register_info(RS2_CAMERA_INFO_CAMERA_LOCKED, _is_locked ? "YES" : "NO");

if( _fw_version >= firmware_version( "1.3.5.0" ) )
{
depth_sensor.register_option(
RS2_OPTION_FREEFALL_DETECTION_ENABLED,
std::make_shared< freefall_option >( *_hw_monitor )
);
}
}

std::shared_ptr<synthetic_sensor> l500_device::create_depth_device(std::shared_ptr<context> ctx,
Expand Down
16 changes: 16 additions & 0 deletions src/l500/l500-private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,21 @@ namespace librealsense

return rv;
}

freefall_option::freefall_option( hw_monitor & hwm )
: _hwm( hwm )
{
// bool_option initializes with def=true, which is what we want
assert( is_true() );
}

void freefall_option::set( float value )
{
bool_option::set( value );

command cmd{ FALL_DETECT_ENABLE, is_true() };
auto res = _hwm.send( cmd );
_record_action( *this );
}
} // librealsense::ivcam2
} // namespace librealsense
22 changes: 21 additions & 1 deletion src/l500/l500-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ namespace librealsense
TEMPERATURES_GET = 0x6A,
DPT_INTRINSICS_FULL_GET = 0x7F,
RGB_INTRINSIC_GET = 0x81,
RGB_EXTRINSIC_GET = 0x82
RGB_EXTRINSIC_GET = 0x82,
FALL_DETECT_ENABLE = 0x9D // Enable (by default) free-fall sensor shutoff (0=disable; 1=enable)
};

enum gvd_fields
Expand Down Expand Up @@ -318,5 +319,24 @@ namespace librealsense
rs2_timestamp_domain get_frame_timestamp_domain(const std::shared_ptr<frame_interface>& frame) const override;
};

/* For RS2_OPTION_FREEFALL_DETECTION_ENABLED */
class freefall_option : public bool_option
{
public:
freefall_option( hw_monitor & hwm );

virtual void set( float value ) override;
virtual const char * get_description() const override
{
return "When enabled (default), the sensor will turn off if a free-fall is detected";
}
virtual void enable_recording( std::function<void( const option& )> record_action ) override { _record_action = record_action; }

private:
std::function<void( const option& )> _record_action = []( const option& ) {};
hw_monitor & _hwm;
};


} // librealsense::ivcam2
} // namespace librealsense
1 change: 1 addition & 0 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ namespace librealsense
CASE(LED_POWER)
CASE(ZERO_ORDER_ENABLED)
CASE(ENABLE_MAP_PRESERVATION)
CASE(FREEFALL_DETECTION_ENABLED)
default: assert(!is_valid(value)); return UNKNOWN_VALUE;
}
#undef CASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public enum Option {
ENABLE_POSE_JUMPING(57),
ENABLE_DYNAMIC_CALIBRATION(58),
DEPTH_OFFSET(59),
LED_POWER(60);
LED_POWER(60),
ZERO_ORDER_ENABLED(61),
ENABLE_MAP_PRESERVATION(62),
FREEFALL_DETECTION_ENABLED(63);

private final int mValue;

Expand Down
1 change: 1 addition & 0 deletions wrappers/nodejs/src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4689,6 +4689,7 @@ void InitModule(v8::Local<v8::Object> exports) {
_FORCE_SET_ENUM(RS2_OPTION_LED_POWER);
_FORCE_SET_ENUM(RS2_OPTION_ZERO_ORDER_ENABLED);
_FORCE_SET_ENUM(RS2_OPTION_ENABLE_MAP_PRESERVATION);
_FORCE_SET_ENUM(RS2_OPTION_FREEFALL_DETECTION_ENABLED);
_FORCE_SET_ENUM(RS2_OPTION_COUNT);

// rs2_camera_info
Expand Down
1 change: 1 addition & 0 deletions wrappers/python/pybackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ PYBIND11_MODULE(NAME, m) {
.value("enable_led_power", RS2_OPTION_LED_POWER)
.value("zero_order_enabled", RS2_OPTION_ZERO_ORDER_ENABLED)
.value("enable_map_preservation", RS2_OPTION_ENABLE_MAP_PRESERVATION)
.value("enable_freefall_detection", RS2_OPTION_FREEFALL_DETECTION_ENABLED)
.value("count", RS2_OPTION_COUNT);

py::enum_<platform::power_state> power_state(m, "power_state");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ enum class ERealSenseOptionType : uint8
LED_POWER , /**< Power of the LED (light emitting diode), with 0 meaning LED off */
ZERO_ORDER_ENABLED , /**< Zero-order mode */
ENABLE_MAP_PRESERVATION , /**< Preserve map from the previous run */
FREEFALL_DETECTION_ENABLED , /**< Enable/disable sensor shutdown when a free-fall is detected (on by default) */
};

UENUM(Blueprintable)
Expand Down

0 comments on commit a2f4808

Please sign in to comment.