mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
d/rs: Generalize laser emitter option setup to any rs option
This commit is contained in:
parent
fa431fc010
commit
1c7323f1c2
|
@ -430,6 +430,8 @@ rs_ddev_destroy(struct xrt_device *xdev)
|
||||||
|
|
||||||
close_ddev(rs);
|
close_ddev(rs);
|
||||||
|
|
||||||
|
m_relation_history_destroy(&rs->relation_hist);
|
||||||
|
|
||||||
free(rs);
|
free(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,23 +444,38 @@ rs_source_load_stream_options_from_json(struct rs_source *rs)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! Disable any laser emitters because they confuse SLAM feature detection
|
//! Set an option for all sensors. Return whether it was set for any.
|
||||||
static void
|
static bool
|
||||||
disable_all_laser_emitters(struct rs_source *rs)
|
set_option_in_all_sensors(struct rs_source *rs, enum rs2_option option, float value)
|
||||||
{
|
{
|
||||||
struct rs_container *rsc = &rs->rsc;
|
struct rs_container *rsc = &rs->rsc;
|
||||||
rs2_sensor_list *sensors = DO(rs2_query_sensors, rsc->device);
|
rs2_sensor_list *sensors = DO(rs2_query_sensors, rsc->device);
|
||||||
int sensors_count = DO(rs2_get_sensors_count, sensors);
|
int sensors_count = DO(rs2_get_sensors_count, sensors);
|
||||||
|
bool any_set = false;
|
||||||
for (int i = 0; i < sensors_count; i++) {
|
for (int i = 0; i < sensors_count; i++) {
|
||||||
rs2_sensor *sensor = DO(rs2_create_sensor, sensors, i);
|
rs2_sensor *sensor = DO(rs2_create_sensor, sensors, i);
|
||||||
rs2_options *sensor_options = (rs2_options *)sensor;
|
rs2_options *sensor_options = (rs2_options *)sensor;
|
||||||
bool has_emitter = DO(rs2_supports_option, sensor_options, RS2_OPTION_EMITTER_ENABLED);
|
bool has_option = DO(rs2_supports_option, sensor_options, option);
|
||||||
if (has_emitter) {
|
if (has_option) {
|
||||||
DO(rs2_set_option, sensor_options, RS2_OPTION_EMITTER_ENABLED, 0);
|
float min, max, step, def;
|
||||||
|
DO(rs2_get_option_range, sensor_options, option, &min, &max, &step, &def);
|
||||||
|
bool valid_value = value >= min && value <= max;
|
||||||
|
if (valid_value) {
|
||||||
|
DO(rs2_set_option, sensor_options, option, value);
|
||||||
|
any_set = true;
|
||||||
|
} else {
|
||||||
|
float cur = rs2_get_option(sensor_options, option, NULL);
|
||||||
|
const char *option_desc = DO(rs2_get_option_description, sensor_options, option);
|
||||||
|
const char *option_name = DO(rs2_get_option_name, sensor_options, option);
|
||||||
|
RS_ERROR(rs, "Invalid value=%f for option %s ('%s')", value, option_name, option_desc);
|
||||||
|
RS_ERROR(rs, "Min=%f Max=%f Step=%f Current=%f", min, max, step, cur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs2_delete_sensor(sensor);
|
rs2_delete_sensor(sensor);
|
||||||
}
|
}
|
||||||
rs2_delete_sensor_list(sensors);
|
rs2_delete_sensor_list(sensors);
|
||||||
|
|
||||||
|
return any_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -824,7 +839,7 @@ rs_source_stream_start(struct xrt_fs *xfs,
|
||||||
struct rs_container *rsc = &rs->rsc;
|
struct rs_container *rsc = &rs->rsc;
|
||||||
rsc->profile = DO(rs2_pipeline_start_with_config_and_callback, rsc->pipeline, rsc->config, on_frame, rs);
|
rsc->profile = DO(rs2_pipeline_start_with_config_and_callback, rsc->pipeline, rsc->config, on_frame, rs);
|
||||||
|
|
||||||
disable_all_laser_emitters(rs);
|
set_option_in_all_sensors(rs, RS2_OPTION_EMITTER_ENABLED, 0); // Lasers are bad for SLAM
|
||||||
|
|
||||||
rs->is_running = true;
|
rs->is_running = true;
|
||||||
return rs->is_running;
|
return rs->is_running;
|
||||||
|
|
Loading…
Reference in a new issue