From 7a658132a154493555537318707521187b313e91 Mon Sep 17 00:00:00 2001 From: Jonathan Bohren Date: Tue, 2 Sep 2014 23:38:17 -0400 Subject: [PATCH] features: switch to only using integer parameters --- cfg/Camera1394.cfg | 60 ++++++++++++++++++++--------------------- src/nodes/features.cpp | 61 +++++------------------------------------- src/nodes/features.h | 10 +++---- 3 files changed, 42 insertions(+), 89 deletions(-) diff --git a/cfg/Camera1394.cfg b/cfg/Camera1394.cfg index 0d3ab5f..9f5fdcf 100755 --- a/cfg/Camera1394.cfg +++ b/cfg/Camera1394.cfg @@ -191,69 +191,69 @@ controls = gen.enum([gen.const("Off", int_t, 0, "Use fixed value"), gen.add("auto_brightness", int_t, SensorLevels.RECONFIGURE_RUNNING, "Brightness control state.", 1, 0, 4, edit_method = controls) -gen.add("brightness", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Black level offset.", 0., 0., 4095.) +gen.add("brightness", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Black level offset.", 0, 0, 4095) gen.add("auto_exposure", int_t, SensorLevels.RECONFIGURE_RUNNING, "Combined Gain, Iris & Shutter control.", 1, 0, 4, edit_method = controls) -gen.add("exposure", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Auto exposure value (like contrast).", 0., -10., 4095.) +gen.add("exposure", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Auto exposure value (like contrast).", 0, 0, 4095) gen.add("auto_focus", int_t, SensorLevels.RECONFIGURE_RUNNING, "Focus control state.", 1, 0, 4, edit_method= controls) -gen.add("focus", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Focus control.", 0., 0., 4095.) +gen.add("focus", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Focus control.", 0, 0, 4095) gen.add("auto_gain", int_t, SensorLevels.RECONFIGURE_RUNNING, "Gain control state.", 1, 0, 4, edit_method = controls) -gen.add("gain", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Relative circuit gain.", 0., -10., 4095) +gen.add("gain", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Relative circuit gain.", 0, 0, 4095) gen.add("auto_gamma", int_t, SensorLevels.RECONFIGURE_RUNNING, "Gamma control state.", 1, 0, 4, edit_method = controls) -gen.add("gamma", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Gamma expansion exponent.", 2.2, 0., 10.) +gen.add("gamma", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Gamma expansion exponent.", 0, 0, 4095) gen.add("auto_hue", int_t, SensorLevels.RECONFIGURE_RUNNING, "Hue control state.", 1, 0, 4, edit_method = controls) -gen.add("hue", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Color phase.", 0., 0., 4095.) +gen.add("hue", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Color phase.", 0, 0, 4095) gen.add("auto_iris", int_t, SensorLevels.RECONFIGURE_RUNNING, "Iris control state.", 1, 0, 4, edit_method = controls) -gen.add("iris", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Iris control.", 8., 0., 4095.) +gen.add("iris", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Iris control.", 0, 0, 4095) gen.add("auto_pan", int_t, SensorLevels.RECONFIGURE_RUNNING, "Pan control state.", 1, 0, 4, edit_method = controls) -gen.add("pan", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Pan control.", 0., 0., 4095.) +gen.add("pan", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Pan control.", 0, 0, 4095) gen.add("auto_saturation", int_t, SensorLevels.RECONFIGURE_RUNNING, "Saturation control state.", 1, 0, 4, edit_method = controls) -gen.add("saturation", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Color saturation.", 1., 0., 4095.) +gen.add("saturation", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Color saturation.", 0, 0, 4095) gen.add("auto_sharpness", int_t, SensorLevels.RECONFIGURE_RUNNING, "Sharpness control state.", 1, 0, 4, edit_method = controls) -gen.add("sharpness", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Image sharpness.", 1., 0., 4095.) +gen.add("sharpness", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Image sharpness.", 1, 0, 4095) gen.add("auto_shutter", int_t, SensorLevels.RECONFIGURE_RUNNING, "Shutter control state.", 1, 0, 4, edit_method = controls) -gen.add("shutter", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Shutter speed.", 1., 0., 4095.) +gen.add("shutter", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Shutter speed.", 0, 0, 4095) gen.add("external_trigger", bool_t, SensorLevels.RECONFIGURE_RUNNING, "External trigger power state", False) @@ -299,25 +299,25 @@ gen.add("trigger_polarity", str_t, SensorLevels.RECONFIGURE_RUNNING, gen.add("auto_trigger", int_t, SensorLevels.RECONFIGURE_RUNNING, "Trigger control state.", 1, 0, 4, edit_method = controls) -gen.add("trigger", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Trigger parameter N", 0., 0., 4095.) +gen.add("trigger", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Trigger parameter N", 0, 0, 4095) gen.add("auto_white_balance", int_t, SensorLevels.RECONFIGURE_RUNNING, "White balance control state.", 1, 0, 4, edit_method = controls) -gen.add("white_balance_BU", double_t, SensorLevels.RECONFIGURE_RUNNING, +gen.add("white_balance_BU", int_t, SensorLevels.RECONFIGURE_RUNNING, "Blue or U component of white balance.", - 0., 0., 4095.) + 0, 0, 4095) -gen.add("white_balance_RV", double_t, SensorLevels.RECONFIGURE_RUNNING, +gen.add("white_balance_RV", int_t, SensorLevels.RECONFIGURE_RUNNING, "Red or V component of white balance.", - 0., 0., 4095.) + 0, 0, 4095) gen.add("auto_zoom", int_t, SensorLevels.RECONFIGURE_RUNNING, "Zoom control state.", 1, 0, 4, edit_method = controls) -gen.add("zoom", double_t, SensorLevels.RECONFIGURE_RUNNING, - "Zoom control.", 0., 0., 4095.) +gen.add("zoom", int_t, SensorLevels.RECONFIGURE_RUNNING, + "Zoom control.", 0, 0, 4095) PACKAGE='camera1394' exit(gen.generate(PACKAGE, "Camera1394", "Camera1394")) diff --git a/src/nodes/features.cpp b/src/nodes/features.cpp index 7115cd9..68d35e1 100644 --- a/src/nodes/features.cpp +++ b/src/nodes/features.cpp @@ -278,7 +278,7 @@ void Features::reconfigure(Config *newconfig) * represent all possible option values accurately. */ void Features::configure(dc1394feature_t feature, int *control, - double *value, double *value2) + int *value, int *value2) { // device-relevant information for this feature dc1394feature_info_t *finfo = @@ -314,37 +314,7 @@ void Features::configure(dc1394feature_t feature, int *control, break; } - // TODO: break this into some internal methods - if (finfo->absolute_capable && finfo->abs_control) - { - // supports reading and setting float value - float fmin, fmax; - if (DC1394_SUCCESS == - dc1394_feature_get_absolute_boundaries(camera_, feature, - &fmin, &fmax)) - { - // clamp *value between minimum and maximum - if (*value < fmin) - *value = (double) fmin; - else if (*value > fmax) - *value = (double) fmax; - } - else - { - ROS_WARN_STREAM("failed to get feature " - << featureName(feature) << " boundaries "); - } - - // @todo handle absolute White Balance values - float fval = *value; - if (DC1394_SUCCESS != - dc1394_feature_set_absolute_value(camera_, feature, fval)) - { - ROS_WARN_STREAM("failed to set feature " - << featureName(feature) << " to " << fval); - } - } - else // no float representation + // no float representation { // round requested value to nearest integer *value = rint(*value); @@ -479,7 +449,7 @@ Features::state_t Features::getState(dc1394feature_info_t *finfo) * for white balance. Otherwise NULL. */ void Features::getValues(dc1394feature_info_t *finfo, - double *value, double *value2) + int *value, int *value2) { dc1394feature_t feature = finfo->id; dc1394error_t rc; @@ -494,13 +464,6 @@ void Features::getValues(dc1394feature_info_t *finfo, if (feature == DC1394_FEATURE_WHITE_BALANCE) { // handle White Balance separately, it has two components - if (finfo->absolute_capable && finfo->abs_control) - { - // supports reading and setting float value - // @todo get absolute White Balance values - rc = DC1394_FUNCTION_NOT_SUPPORTED; - } - else { // get integer White Balance values uint32_t bu_val; @@ -528,17 +491,7 @@ void Features::getValues(dc1394feature_info_t *finfo, else { // other features only have one component - if (finfo->absolute_capable && finfo->abs_control) - { - // supports reading and setting float value - float fval; - rc = dc1394_feature_get_absolute_value(camera_, feature, &fval); - if (DC1394_SUCCESS == rc) - { - *value = fval; // convert to double - } - } - else // no float representation + // no float representation { uint32_t ival; rc = dc1394_feature_get_value(camera_, feature, &ival); @@ -641,7 +594,7 @@ void Features::setPower(dc1394feature_info_t *finfo, dc1394switch_t on_off) */ void Features::updateIfChanged(dc1394feature_t feature, int old_control, int *control, - double old_value, double *value) + int old_value, int *value) { if ((old_control != *control) || (old_value != *value)) { @@ -668,8 +621,8 @@ void Features::updateIfChanged(dc1394feature_t feature, */ void Features::updateIfChanged(dc1394feature_t feature, int old_control, int *control, - double old_value, double *value, - double old_value2, double *value2) + int old_value, int *value, + int old_value2, int *value2) { if ((old_control != *control) || (old_value != *value) diff --git a/src/nodes/features.h b/src/nodes/features.h index add4261..90e2cc7 100644 --- a/src/nodes/features.h +++ b/src/nodes/features.h @@ -76,10 +76,10 @@ class Features typedef int state_t; ///< camera1394::Camera1394_* state values void configure(dc1394feature_t feature, int *control, - double *value, double *value2=NULL); + int *value, int *value2=NULL); state_t getState(dc1394feature_info_t *finfo); void getValues(dc1394feature_info_t *finfo, - double *value, double *value2); + int *value, int *value2); /** Does this camera feature support a given mode? * @@ -117,11 +117,11 @@ class Features void setPower(dc1394feature_info_t *finfo, dc1394switch_t on_off); void updateIfChanged(dc1394feature_t feature, int old_control, int *control, - double old_value, double *value); + int old_value, int *value); void updateIfChanged(dc1394feature_t feature, int old_control, int *control, - double old_value, double *value, - double old_value2, double *value2); + int old_value, int *value, + int old_value2, int *value2); dc1394camera_t *camera_; ///< current camera dc1394featureset_t feature_set_; ///< that camera's feature set