From ab62b50e1a504be9dea3eac42ce63d4969661034 Mon Sep 17 00:00:00 2001 From: Alec Tutin Date: Mon, 8 Mar 2021 09:57:45 +1000 Subject: [PATCH 1/2] Added setting the Auto Shutter Range of the camera to the configuration. --- pointgrey_camera_driver/cfg/PointGrey.cfg | 4 +++ .../pointgrey_camera_driver/PointGreyCamera.h | 12 +++++++ .../src/PointGreyCamera.cpp | 32 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/pointgrey_camera_driver/cfg/PointGrey.cfg b/pointgrey_camera_driver/cfg/PointGrey.cfg index 4ec1385..1adc3a5 100755 --- a/pointgrey_camera_driver/cfg/PointGrey.cfg +++ b/pointgrey_camera_driver/cfg/PointGrey.cfg @@ -123,6 +123,10 @@ gen.add("white_balance_blue", int_t, SensorLevels.RECONFIGURE_RUNNING, "W gen.add("white_balance_red", int_t, SensorLevels.RECONFIGURE_RUNNING, "White balance red component.", 550, 0, 1023) +gen.add("auto_shutter_range_min", int_t, SensorLevels.RECONFIGURE_RUNNING, "Auto Shutter Range Minimum", 1, 1, 4095) + +gen.add("auto_shutter_range_max", int_t, SensorLevels.RECONFIGURE_RUNNING, "Auto Shutter Range Maximum", 4095, 1, 4095) + # Format7-specific parameters gen.add("format7_roi_width", int_t, SensorLevels.RECONFIGURE_STOP, "Width of Format7 Region of Interest in unbinned pixels, full width if zero.", 0, 0, 65535) diff --git a/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h b/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h index b8d91d6..aa5c047 100644 --- a/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h +++ b/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h @@ -270,6 +270,18 @@ class PointGreyCamera */ bool setWhiteBalance(bool& auto_white_balance, uint16_t &blue, uint16_t &red); + /*! + * \brief Sets the auto shutter range property + * + * This function will set the auto shutter range for the camera.. If value is outside the range of min and max, + * it will return false. + * \param min_value Minimum value for the auto shutter range setting. + * \param max_value Maximum value for the auto shutter range setting. + * + * \return Returns true when the configuration could be applied without modification. + */ + bool setAutoShutterRange(uint32_t min_value, uint32_t max_value); + /*! * \brief Gets the current frame rate. * diff --git a/pointgrey_camera_driver/src/PointGreyCamera.cpp b/pointgrey_camera_driver/src/PointGreyCamera.cpp index 33f3171..8e9336c 100644 --- a/pointgrey_camera_driver/src/PointGreyCamera.cpp +++ b/pointgrey_camera_driver/src/PointGreyCamera.cpp @@ -142,6 +142,9 @@ bool PointGreyCamera::setNewConfiguration(pointgrey_camera_driver::PointGreyConf config.white_balance_blue = blue; config.white_balance_red = red; + // Set auto shutter range + retVal &= PointGreyCamera::setAutoShutterRange(config.auto_shutter_range_min, config.auto_shutter_range_max); + // Set trigger switch (config.trigger_polarity) { @@ -624,6 +627,35 @@ bool PointGreyCamera::setWhiteBalance(bool &auto_white_balance, uint16_t &blue, return true; } +bool PointGreyCamera::setAutoShutterRange(uint32_t min_value, uint32_t max_value) +{ + if (min_value > max_value || min_value > 4095 || max_value > 4095 || min_value == 0) { + return false; + } + + // Get camera info to check if color or black and white chameleon + CameraInfo cInfo; + Error error = cam_.GetCameraInfo(&cInfo); + handleError("PointGreyCamera::setAutoShutterRange Failed to get camera info.", error); + + unsigned auto_shutter_range_addr = 0x1098; + unsigned enable = 1 << 31; + + const uint16_t mask = 0b111111111111; + + min_value &= mask; + max_value &= mask; + + uint32_t register_value = enable | (min_value << 12) | max_value; + + error = cam_.WriteRegister(auto_shutter_range_addr, enable); + handleError("PointGreyCamera::setAutoShutterRange Failed to write to register.", error); + + error = cam_.WriteRegister(auto_shutter_range_addr, register_value); + handleError("PointGreyCamera::setAutoShutterRange Failed to write to register.", error); + return true; +} + void PointGreyCamera::setTimeout(const double &timeout) { FC2Config pConfig; From 3372112b4b5b3caa54ae53d1cb347f861e7a0333 Mon Sep 17 00:00:00 2001 From: Alec Tutin Date: Mon, 8 Mar 2021 10:08:22 +1000 Subject: [PATCH 2/2] Adding a simple gitignore for cmake build and IDE files. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aaf3f83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/pointgrey_camera_driver/cmake-build-debug/ + +# JetBrains IDE +/pointgrey_camera_driver/.idea/