40 #include <sensor_msgs/CameraInfo.h> 41 #include <std_msgs/Float64.h> 43 #include <wfov_camera_msgs/WFOVImage.h> 44 #include <image_exposure_msgs/ExposureSequence.h> 49 #include <boost/thread.hpp> 51 #include <dynamic_reconfigure/server.h> 76 void paramCallback(pointgrey_camera_driver::PointGreyConfig &config, uint32_t level)
80 config.video_mode =
"format7_mode3";
84 NODELET_DEBUG(
"Dynamic reconfigure callback with level: %d", level);
89 wb_blue_ = config.white_balance_blue;
90 wb_red_ = config.white_balance_red;
94 if(config.video_mode ==
"640x480_mono8" || config.video_mode ==
"format7_mode1")
99 else if(config.video_mode ==
"format7_mode2")
111 if(config.video_mode ==
"format7_mode0" || config.video_mode ==
"format7_mode1" || config.video_mode ==
"format7_mode2")
129 catch(std::runtime_error& e)
131 NODELET_ERROR(
"Reconfigure Callback failed with error: %s", e.what());
145 std::string firstcam;
146 pnh.
param<std::string>(
"first_namespace", firstcam,
"left");
148 std::string secondcam;
149 pnh.
param<std::string>(
"second_namespace", secondcam,
"right");
154 pnh.
param<
int>(
"serial", serialParam, 0);
155 uint32_t serial = (uint32_t)serialParam;
157 std::string camera_info_url;
158 pnh.
param<std::string>(
"camera_info_url", camera_info_url,
"");
159 std::string second_info_url;
160 pnh.
param<std::string>(
"second_info_url", second_info_url,
"");
166 pnh.
param(
"timeout", timeout, 1.0);
169 volatile bool connected =
false;
174 NODELET_INFO(
"Connecting to camera serial: %u", serial);
182 catch(std::runtime_error& e)
190 srv_ = boost::make_shared <dynamic_reconfigure::Server<pointgrey_camera_driver::PointGreyConfig> > (pnh);
192 srv_->setCallback(f);
195 std::stringstream cinfo_name;
196 cinfo_name << serial;
202 ci_.reset(
new sensor_msgs::CameraInfo(
cinfo_->getCameraInfo()));
204 rci_.reset(
new sensor_msgs::CameraInfo(
rcinfo_->getCameraInfo()));
209 it_pub_ =
it_->advertiseCamera(
"image_raw", 5);
222 volatile bool started =
false;
233 catch(std::runtime_error& e)
255 catch(std::runtime_error& e)
268 while(!boost::this_thread::interruption_requested())
272 sensor_msgs::ImagePtr image(
new sensor_msgs::Image);
273 sensor_msgs::ImagePtr second_image(
new sensor_msgs::Image);
277 image->header.stamp = time;
278 second_image->header.stamp = time;
279 ci_->header.stamp = time;
280 rci_->header.stamp = time;
298 std_msgs::Float64 temp;
306 catch(std::runtime_error& e)
317 catch(std::runtime_error& e2)
331 NODELET_DEBUG(
"Gain callback: Setting gain to %f and white balances to %u, %u", msg.gain, msg.white_balance_blue, msg.white_balance_red);
335 wb_red_ = msg.white_balance_red;
338 catch(std::runtime_error& e)
340 NODELET_ERROR(
"gainWBCallback failed with error: %s", e.what());
356 sensor_msgs::CameraInfoPtr
ci_;
369 sensor_msgs::CameraInfoPtr
rci_;
std::string second_frame_id_
Frame id used for the second camera.
boost::shared_ptr< boost::thread > pubThread_
The thread that reads and publishes the images.
float getCameraTemperature()
Gets the current operating temperature.
void publish(const sensor_msgs::Image &image, const sensor_msgs::CameraInfo &info) const
#define NODELET_ERROR(...)
#define NODELET_WARN(...)
void setDesiredCamera(const uint32_t &id)
Used to set the serial number for the camera you wish to connect to.
void publish(const boost::shared_ptr< M > &message) const
void setBRWhiteBalance(bool auto_white_balance, uint16_t &blue, uint16_t &red)
boost::shared_ptr< camera_info_manager::CameraInfoManager > cinfo_
Needed to initialize and keep the CameraInfoManager in scope.
size_t roi_height_
Camera Info ROI height.
size_t binning_y_
Camera Info pixel binning along the image y axis.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void gainWBCallback(const image_exposure_msgs::ExposureSequence &msg)
ros::Subscriber sub_
Subscriber for gain and white balance changes.
Interface to Point Grey cameras.
void setHardwareID(const std::string &hwid)
void devicePoll()
Function for the boost::thread to grabImages and publish them.
ros::NodeHandle & getMTNodeHandle() const
size_t roi_width_
Camera Info ROI width.
void setGain(double &gain)
sensor_msgs::CameraInfoPtr rci_
Camera Info message.
bool do_rectify_
Whether or not to rectify as if part of an image. Set to false if whole image, and true if in ROI mod...
size_t roi_y_offset_
Camera Info ROI y offset.
bool stop()
Stops the camera loading data into its buffer.
ros::Publisher temp_pub_
Publisher for current camera temperature.
ros::NodeHandle & getMTPrivateNodeHandle() const
void setTimeout(const double &timeout)
Will set grabImage timeout for the camera.
PLUGINLIB_EXPORT_CLASS(image_proc::CropNonZeroNodelet, nodelet::Nodelet)
void connect()
Function that connects to a specified camera.
PointGreyCamera pg_
Instance of the PointGreyCamera library, used to interface with the hardware.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
PointGreyStereoCameraNodelet()
void cleanUp()
Cleans up the memory and disconnects the camera.
~PointGreyStereoCameraNodelet()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
image_transport::CameraPublisher rit_pub_
CameraInfoManager ROS publisher.
size_t roi_x_offset_
Camera Info ROI x offset.
std::string frame_id_
Frame id for the camera messages, defaults to 'camera'.
void start()
Starts the camera loading data into its buffer.
#define NODELET_INFO(...)
void paramCallback(pointgrey_camera_driver::PointGreyConfig &config, uint32_t level)
Function that allows reconfiguration of the camera.
boost::shared_ptr< camera_info_manager::CameraInfoManager > rcinfo_
Needed to initialize and keep the CameraInfoManager in scope.
boost::shared_ptr< image_transport::ImageTransport > it_
Needed to initialize and keep the ImageTransport in scope.
sensor_msgs::CameraInfoPtr ci_
Camera Info message.
image_transport::CameraPublisher it_pub_
CameraInfoManager ROS publisher.
void disconnect()
Disconnects from the camera.
#define NODELET_DEBUG(...)
void onInit()
Serves as a psuedo constructor for nodelets.
boost::shared_ptr< dynamic_reconfigure::Server< pointgrey_camera_driver::PointGreyConfig > > srv_
Needed to initialize and keep the dynamic_reconfigure::Server in scope.
diagnostic_updater::Updater updater_
Handles publishing diagnostics messages.
void grabStereoImage(sensor_msgs::Image &image, const std::string &frame_id, sensor_msgs::Image &second_image, const std::string &second_frame_id)
bool setNewConfiguration(pointgrey_camera_driver::PointGreyConfig &config, const uint32_t &level)
Function that allows reconfiguration of the camera.
boost::shared_ptr< image_transport::ImageTransport > rit_
Needed to initialize and keep the ImageTransport in scope.
size_t binning_x_
Camera Info pixel binning along the image x axis.