Skip to content

Commit

Permalink
My current changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bafonso committed Apr 1, 2016
1 parent 282464a commit baaca54
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 13 deletions.
4 changes: 4 additions & 0 deletions pointgrey_camera_driver/cfg/PointGrey.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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("high_speed_mode", bool_t, SensorLevels.RECONFIGURE_STOP, "High Speed mode", True)

gen.add("number_of_buffers", int_t, SensorLevels.RECONFIGURE_STOP, "Number of buffers, default is 10", 10, 0, 1000)

# 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ class PointGreyCamera
*/
void setTimeout(const double &timeout);

/*!
* \brief Will switch camera to high speed mode.
*
* This function will switch camera to high speed mode. Must be called after connect().
* \param high_speed Bool to turn on or off the function
*
*/
void setHighPerformance(bool high_speed);

/*!
* \brief Will set defined buffers to store in RAM.
*
* This function will set the set defined buffers. Must be called after connect().
* \param buffers The desired buffers to put in the computer's RAM
*
*/
void setBuffers(const int &buffers);

/*!
* \brief Used to set the serial number for the camera you wish to connect to.
*
Expand Down Expand Up @@ -165,6 +183,8 @@ class PointGreyCamera

uint getShutter();

uint getFrameCounter();

uint getBrightness();

uint getExposure();
Expand Down
71 changes: 59 additions & 12 deletions pointgrey_camera_driver/src/PointGreyCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ bool PointGreyCamera::setNewConfiguration(pointgrey_camera_driver::PointGreyConf
retVal &= false;
}

// set High Speed
PointGreyCamera::setHighPerformance(config.high_speed_mode);
PointGreyCamera::setBuffers(config.number_of_buffers);

return retVal;
}

Expand Down Expand Up @@ -580,6 +584,28 @@ bool PointGreyCamera::setWhiteBalance(bool &auto_white_balance, uint16_t &blue,
return true;
}

void PointGreyCamera::setHighPerformance(bool high_performance)
{
FC2Config pConfig;
Error error = cam_.GetConfiguration(&pConfig);
PointGreyCamera::handleError("PointGreyCamera::enableHighPerformance Could not get camera configuration", error);
pConfig.highPerformanceRetrieveBuffer = high_performance;
error = cam_.SetConfiguration(&pConfig);
PointGreyCamera::handleError("PointGreyCamera::enableHighPerformance Could not set camera configuration", error);


}

void PointGreyCamera::setBuffers(const int &buffers)
{
FC2Config pConfig;
Error error = cam_.GetConfiguration(&pConfig);
PointGreyCamera::handleError("PointGreyCamera::enableHighPerformance Could not get camera configuration", error);
pConfig.numBuffers = buffers;
error = cam_.SetConfiguration(&pConfig);
PointGreyCamera::handleError("PointGreyCamera::enableHighPerformance Could not set camera configuration", error);
}

void PointGreyCamera::setTimeout(const double &timeout)
{
FC2Config pConfig;
Expand Down Expand Up @@ -860,7 +886,6 @@ void PointGreyCamera::connect()
// Set packet delay:
setupGigEPacketDelay(guid, packet_delay_);
}

error = cam_.Connect(&guid);
PointGreyCamera::handleError("PointGreyCamera::connect Failed to connect to camera", error);

Expand All @@ -870,18 +895,27 @@ void PointGreyCamera::connect()
PointGreyCamera::handleError("PointGreyCamera::connect Failed to get camera info.", error);
isColor_ = cInfo.isColorCamera;

// Enable metadata
error = cam_.ResetStats();
PointGreyCamera::handleError("PointGreyCamera::connect Failed to reset stats", error);

EmbeddedImageInfo EmbeddedInfo;
cam_.GetEmbeddedImageInfo(&EmbeddedInfo);
// We enable the features that are available to retrieve
EmbeddedImageInfo info;
info.timestamp.onOff = true;
info.gain.onOff = true;
info.shutter.onOff = true;
info.brightness.onOff = true;
info.exposure.onOff = true;
info.whiteBalance.onOff = true;
info.frameCounter.onOff = true;
info.ROIPosition.onOff = true;
info.timestamp.onOff = (EmbeddedInfo.timestamp.available) ? true : false;
info.gain.onOff = (EmbeddedInfo.gain.available) ? true : false;
info.shutter.onOff = (EmbeddedInfo.shutter.available) ? true : false;
info.brightness.onOff = (EmbeddedInfo.brightness.available) ? true : false;
info.exposure.onOff = (EmbeddedInfo.exposure.available) ? true : false;
info.whiteBalance.onOff = (EmbeddedInfo.whiteBalance.available) ? true : false;
info.frameCounter.onOff = (EmbeddedInfo.frameCounter.available) ? true : false;
info.strobePattern.onOff = (EmbeddedInfo.strobePattern.available) ? true : false;
info.GPIOPinState.onOff = (EmbeddedInfo.GPIOPinState.available) ? true : false;
info.ROIPosition.onOff = (EmbeddedInfo.ROIPosition.available) ? true : false;
error = cam_.SetEmbeddedImageInfo(&info);
PointGreyCamera::handleError("PointGreyCamera::connect Could not enable metadata", error);
PointGreyCamera::handleError("PointGreyCamera:: Could not enable metadata", error);


}
}

Expand Down Expand Up @@ -931,6 +965,9 @@ void PointGreyCamera::grabImage(sensor_msgs::Image &image, const std::string &fr
Error error = cam_.RetrieveBuffer(&rawImage);
PointGreyCamera::handleError("PointGreyCamera::grabImage Failed to retrieve buffer", error);
metadata_ = rawImage.GetMetadata();
// std::ostringstream metadataInfo ;
// metadataInfo << "Frame out of the metadata is: " << metadata_.embeddedFrameCounter ;
// ROS_INFO(metadataInfo.str().c_str());

// Set header timestamp as embedded for now
TimeStamp embeddedTime = rawImage.GetTimeStamp();
Expand Down Expand Up @@ -1095,9 +1132,19 @@ uint PointGreyCamera::getShutter()
return metadata_.embeddedShutter >> 20;
}

uint PointGreyCamera::getFrameCounter()
{
// std::ostringstream y ;
// y << "from getFrameCounter() we get: " << metadata_.embeddedFrameCounter ;
// ROS_INFO(y.str().c_str());
// return metadata_.embeddedFrameCounter >> 20 ; // why was >> 20?
return metadata_.embeddedFrameCounter ;

}

uint PointGreyCamera::getBrightness()
{
return metadata_.embeddedTimeStamp >> 20;
return metadata_.embeddedTimeStamp >> 20;
}

uint PointGreyCamera::getExposure()
Expand Down
6 changes: 6 additions & 0 deletions pointgrey_camera_driver/src/nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ class PointGreyCameraNodelet: public nodelet::Nodelet

wfov_image->temperature = pg_.getCameraTemperature();

wfov_image->frame_counter = (uint16_t)pg_.getFrameCounter();
// uint ohyeah = pg_.getFrameCounter() ;
// std::ostringstream fc ;
// fc << "frame counter from the pg_.getFrameCounter() is: " << wfov_image->frame_counter << " ohyeah is " << ohyeah;
// ROS_INFO(fc.str().c_str());

ros::Time time = ros::Time::now();
wfov_image->header.stamp = time;
wfov_image->image.header.stamp = time;
Expand Down
4 changes: 3 additions & 1 deletion wfov_camera_msgs/msg/WFOVImage.msg
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ uint16 white_balance_blue # White balance in blue.

uint16 white_balance_red # White balance in red.

float32 temperature # Temperature reported by the camera (Celsius).
float32 temperature # Temperature reported by the camera (Celsius).

uint16 frame_counter # Frame counter reported by the camera

0 comments on commit baaca54

Please sign in to comment.