From bbade3865807fe2538636ca818e2fb231d79973e Mon Sep 17 00:00:00 2001 From: Finn Linzer Date: Fri, 16 Feb 2018 14:46:27 +0100 Subject: [PATCH 1/3] option to enable or disable packet resend added --- .../pointgrey_camera_driver/PointGreyCamera.h | 16 ++++++++++- .../src/PointGreyCamera.cpp | 28 +++++++++++-------- pointgrey_camera_driver/src/nodelet.cpp | 6 +++- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h b/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h index b8d91d6..96e8fdb 100644 --- a/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h +++ b/pointgrey_camera_driver/include/pointgrey_camera_driver/PointGreyCamera.h @@ -144,7 +144,7 @@ class PointGreyCamera * \param auto_packet_size Flag stating if packet size should be automatically determined or not. * \param packet_size The packet size value to use if auto_packet_size is false. */ - void setGigEParameters(bool auto_packet_size, unsigned int packet_size, unsigned int packet_delay); + void setGigEParameters(bool auto_packet_size, unsigned int packet_size, unsigned int packet_delay, bool packet_resend); std::vector getAttachedCameras(); @@ -193,6 +193,9 @@ class PointGreyCamera unsigned int packet_size_; /// GigE packet delay: unsigned int packet_delay_; + /// If true, GigE packet resend is enabled: + unsigned int packet_resend_; + /*! * \brief Changes the video mode of the connected camera. @@ -343,6 +346,17 @@ class PointGreyCamera */ void setupGigEPacketDelay(FlyCapture2::PGRGuid & guid, unsigned int packet_delay); + /*! + * \brief Will configure the packet resend option of the GigECamera with the given GUID to the given value. + * + * Note that this is expected only to work for GigE cameras, and only if the camera + * is not connected. + * + * \param guid the camera to autoconfigure + * \param packet_resend Use packet resend option. + */ + void setupGigEPacketResend(FlyCapture2::PGRGuid & guid, bool packet_resend); + public: /*! * \brief Handles errors returned by FlyCapture2. diff --git a/pointgrey_camera_driver/src/PointGreyCamera.cpp b/pointgrey_camera_driver/src/PointGreyCamera.cpp index 33f3171..ed60820 100644 --- a/pointgrey_camera_driver/src/PointGreyCamera.cpp +++ b/pointgrey_camera_driver/src/PointGreyCamera.cpp @@ -819,11 +819,12 @@ bool PointGreyCamera::setExternalTrigger(bool &enable, std::string &mode, std::s return retVal; } -void PointGreyCamera::setGigEParameters(bool auto_packet_size, unsigned int packet_size, unsigned int packet_delay) +void PointGreyCamera::setGigEParameters(bool auto_packet_size, unsigned int packet_size, unsigned int packet_delay, bool packet_resend) { auto_packet_size_ = auto_packet_size; packet_size_ = packet_size; packet_delay_ = packet_delay; + packet_resend_ = packet_resend; } void PointGreyCamera::setupGigEPacketSize(PGRGuid & guid) @@ -870,6 +871,20 @@ void PointGreyCamera::setupGigEPacketDelay(PGRGuid & guid, unsigned int packet_d PointGreyCamera::handleError("PointGreyCamera::connect could not set GigE packet_delay", error); } +void PointGreyCamera::setupGigEPacketResend(PGRGuid & guid, bool packet_resend) +{ + GigECamera cam; + Error error; + error = cam.Connect(&guid); + PointGreyCamera::handleError("PointGreyCamera::connect could not connect as GigE camera", error); + GigEConfig gigeconfig; + error = cam.GetGigEConfig(&gigeconfig); + PointGreyCamera::handleError("PointGreyCamera::GetGigEConfig could not get GigE setting", error); + gigeconfig.enablePacketResend = packet_resend; + error = cam.SetGigEConfig(&gigeconfig); + PointGreyCamera::handleError("PointGreyCamera::SetGigEConfig could not set GigE settings (packet resend)", error); +} + void PointGreyCamera::connect() { if(!cam_.IsConnected()) @@ -905,16 +920,7 @@ void PointGreyCamera::connect() setupGigEPacketDelay(guid, packet_delay_); // Enable packet resend - GigECamera cam; - Error error; - error = cam.Connect(&guid); - PointGreyCamera::handleError("PointGreyCamera::connect could not connect as GigE camera", error); - GigEConfig gigeconfig; - error = cam.GetGigEConfig(&gigeconfig); - PointGreyCamera::handleError("PointGreyCamera::GetGigEConfig could not get GigE setting", error); - gigeconfig.enablePacketResend = true; - error = cam.SetGigEConfig(&gigeconfig); - PointGreyCamera::handleError("PointGreyCamera::SetGigEConfig could not set GigE settings (packet resend)", error); + setupGigEPacketResend(guid, packet_resend_); } error = cam_.Connect(&guid); diff --git a/pointgrey_camera_driver/src/nodelet.cpp b/pointgrey_camera_driver/src/nodelet.cpp index a74db2d..90e5baf 100644 --- a/pointgrey_camera_driver/src/nodelet.cpp +++ b/pointgrey_camera_driver/src/nodelet.cpp @@ -259,9 +259,10 @@ class PointGreyCameraNodelet: public nodelet::Nodelet pnh.param("packet_size", packet_size_, 1400); pnh.param("auto_packet_size", auto_packet_size_, true); pnh.param("packet_delay", packet_delay_, 4000); + pnh.param("packet_resend", packet_resend_, true); // Set GigE parameters: - pg_.setGigEParameters(auto_packet_size_, packet_size_, packet_delay_); + pg_.setGigEParameters(auto_packet_size_, packet_size_, packet_delay_, packet_resend_); // Get the location of our camera config yaml std::string camera_info_url; @@ -600,6 +601,9 @@ class PointGreyCameraNodelet: public nodelet::Nodelet int packet_size_; /// GigE packet delay: int packet_delay_; + /// If true, GigE packet resend is enabled: + bool packet_resend_; + /// Configuration: pointgrey_camera_driver::PointGreyConfig config_; From a4ba101b148b7dc7b722cbffb570f57281ef05d0 Mon Sep 17 00:00:00 2001 From: Finn Linzer Date: Mon, 26 Feb 2018 11:30:29 +0100 Subject: [PATCH 2/3] add packet_resend option in camera.launch file --- pointgrey_camera_driver/launch/camera.launch | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pointgrey_camera_driver/launch/camera.launch b/pointgrey_camera_driver/launch/camera.launch index 4699643..30ffe08 100644 --- a/pointgrey_camera_driver/launch/camera.launch +++ b/pointgrey_camera_driver/launch/camera.launch @@ -4,6 +4,7 @@ + @@ -12,6 +13,7 @@ args="load pointgrey_camera_driver/PointGreyCameraNodelet camera_nodelet_manager" > +