Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to turn off packet resend #163

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t> getAttachedCameras();

Expand Down Expand Up @@ -193,6 +193,9 @@ class PointGreyCamera
unsigned int packet_size_;
/// GigE packet delay:
unsigned int packet_delay_;
/// If true, GigE packet resend is enabled:
bool packet_resend_;


/*!
* \brief Changes the video mode of the connected camera.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pointgrey_camera_driver/launch/camera.launch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<arg name="camera_name" default="camera" />
<arg name="camera_serial" default="0" />
<arg name="calibrated" default="0" />
<arg name="packet_resend" default="true" />

<group ns="$(arg camera_name)">
<node pkg="nodelet" type="nodelet" name="camera_nodelet_manager" args="manager" />
Expand All @@ -12,6 +13,7 @@
args="load pointgrey_camera_driver/PointGreyCameraNodelet camera_nodelet_manager" >
<param name="frame_id" value="camera" />
<param name="serial" value="$(arg camera_serial)" />
<param name="packet_resend" value="$(arg packet_resend)" />

<!-- When unspecified, the driver will use the default framerate as given by the
camera itself. Use this parameter to override that value for cameras capable of
Expand Down
28 changes: 17 additions & 11 deletions pointgrey_camera_driver/src/PointGreyCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion pointgrey_camera_driver/src/nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ class PointGreyCameraNodelet: public nodelet::Nodelet
pnh.param<int>("packet_size", packet_size_, 1400);
pnh.param<bool>("auto_packet_size", auto_packet_size_, true);
pnh.param<int>("packet_delay", packet_delay_, 4000);
pnh.param<bool>("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;
Expand Down Expand Up @@ -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_;
Expand Down