@@ -35,7 +35,7 @@ void handler(int i) {
3535
3636}
3737
38- acquisition::Capture::Capture ():nh_(), nh_pvt_ (" ~" ) {
38+ acquisition::Capture::Capture (): it_(nh_), nh_pvt_ (" ~" ) {
3939
4040 // struct sigaction sigIntHandler;
4141
@@ -91,7 +91,7 @@ acquisition::Capture::Capture():nh_(),nh_pvt_ ("~") {
9191 achieved_time_ = 0 ;
9292
9393 // decimation_ = 1;
94-
94+
9595 CAM_ = 0 ;
9696
9797 // default flag values
@@ -113,6 +113,12 @@ acquisition::Capture::Capture():nh_(),nh_pvt_ ("~") {
113113
114114 // initializing the ros publisher
115115 acquisition_pub = nh_.advertise <spinnaker_sdk_camera_driver::SpinnakerImageNames>(" camera" , 1000 );
116+ // dynamic reconfigure
117+ // dynamic_reconfigure::Server<spinnaker_sdk_camera_driver::spinnaker_camConfig> server;
118+ dynamic_reconfigure::Server<spinnaker_sdk_camera_driver::spinnaker_camConfig>::CallbackType f;
119+
120+ f = boost::bind (&acquisition::Capture::dynamicReconfigureCallback,this , _1, _2);
121+ server.setCallback (f);
116122}
117123
118124void acquisition::Capture::load_cameras () {
@@ -133,6 +139,8 @@ void acquisition::Capture::load_cameras() {
133139
134140 bool master_set = false ;
135141 int cam_counter = 0 ;
142+
143+
136144 for (int j=0 ; j<cam_ids_.size (); j++) {
137145 bool current_cam_found=false ;
138146 for (int i=0 ; i<numCameras_; i++) {
@@ -156,26 +164,24 @@ void acquisition::Capture::load_cameras() {
156164
157165 cams.push_back (cam);
158166
159- camera_image_pubs.push_back (nh_.advertise <sensor_msgs::Image>(" camera_array/" +cam_names_[j]+" /image_raw" , 1 ));
160- camera_info_pubs.push_back (nh_.advertise <sensor_msgs::CameraInfo>(" camera_array/" +cam_names_[j]+" /camera_info" , 1 ));
167+ camera_image_pubs.push_back (it_.advertiseCamera (" camera_array/" +cam_names_[j]+" /image_raw" , 1 ));
168+ // camera_info_pubs.push_back(nh_.advertise<sensor_msgs::CameraInfo>("camera_array/"+cam_names_[j]+"/camera_info", 1));
169+
161170 img_msgs.push_back (sensor_msgs::ImagePtr ());
162-
163171 if (PUBLISH_CAM_INFO_){
164- sensor_msgs::CameraInfo ci_msg;
165-
166- ci_msg.height = 1024 ;
167- ci_msg.width = 1280 ;
168- ci_msg.distortion_model = " plumb_bob" ;
169- ci_msg.D = distortion_coeff_vec_[j];
170- ci_msg.binning_x = binning_;
171- ci_msg.binning_y = binning_;
172+ sensor_msgs::CameraInfoPtr ci_msg (new sensor_msgs::CameraInfo ());
173+ ci_msg->height = 1024 ;
174+ ci_msg->width = 1280 ;
175+ ci_msg->distortion_model = " plumb_bob" ;
176+ ci_msg->D = distortion_coeff_vec_[j];
177+ ci_msg->binning_x = binning_;
178+ ci_msg->binning_y = binning_;
172179 for (int count = 0 ; count<intrinsic_coeff_vec_[j].size ();count++)
173- ci_msg.K [count] = intrinsic_coeff_vec_[j][count];
174- ci_msg.header .frame_id = " cam_" +to_string (j)+" _optical_frame" ;
175- ci_msg.P = {intrinsic_coeff_vec_[j][0 ], intrinsic_coeff_vec_[j][1 ],intrinsic_coeff_vec_[j][2 ], 0 ,
176- intrinsic_coeff_vec_[j][3 ],intrinsic_coeff_vec_[j][4 ],intrinsic_coeff_vec_[j][5 ],0 ,
177- intrinsic_coeff_vec_[j][6 ],intrinsic_coeff_vec_[j][7 ],intrinsic_coeff_vec_[j][8 ],0 };
178-
180+ ci_msg->K [count] = intrinsic_coeff_vec_[j][count];
181+ ci_msg->header .frame_id = " cam_" +to_string (j)+" _optical_frame" ;
182+ ci_msg->P = {intrinsic_coeff_vec_[j][0 ], intrinsic_coeff_vec_[j][1 ], intrinsic_coeff_vec_[j][2 ], 0 ,
183+ intrinsic_coeff_vec_[j][3 ], intrinsic_coeff_vec_[j][4 ], intrinsic_coeff_vec_[j][5 ], 0 ,
184+ intrinsic_coeff_vec_[j][6 ], intrinsic_coeff_vec_[j][7 ], intrinsic_coeff_vec_[j][8 ], 0 };
179185 cam_info_msgs.push_back (ci_msg);
180186 }
181187 cam_counter++;
@@ -390,8 +396,8 @@ void acquisition::Capture::read_parameters() {
390396 PUBLISH_CAM_INFO_ = intrinsics_list_provided && distort_list_provided;
391397 if (PUBLISH_CAM_INFO_)
392398 ROS_INFO (" Camera coeffs provided, camera info messges will be published." );
393- else
394- ROS_INFO (" Camera coeffs not provided correctly, camera info messges will not be published." );
399+ else
400+ ROS_INFO (" Camera coeffs not provided correctly, camera info messges will not be published." );
395401
396402// ROS_ASSERT_MSG(my_list.getType()
397403// int num_ids = cam_id_vec.size();
@@ -599,15 +605,19 @@ void acquisition::Capture::export_to_ROS() {
599605
600606 if (color_)
601607 img_msgs[i]=cv_bridge::CvImage (img_msg_header, " bgr8" , frames_[i]).toImageMsg ();
602- else
603- img_msgs[i]=cv_bridge::CvImage (img_msg_header, " mono8" , frames_[i]).toImageMsg ();
604-
605- camera_image_pubs[i].publish (img_msgs[i]);
608+ else
609+ img_msgs[i]=cv_bridge::CvImage (img_msg_header, " mono8" , frames_[i]).toImageMsg ();
606610
611+ if (PUBLISH_CAM_INFO_){
612+ cam_info_msgs[i]->header .stamp = mesg.header .stamp ;
613+ }
614+ camera_image_pubs[i].publish (img_msgs[i],cam_info_msgs[i]);
615+ /*
607616 if (PUBLISH_CAM_INFO_){
608617 cam_info_msgs[i].header.stamp = mesg.header.stamp;
609618 camera_info_pubs[i].publish(cam_info_msgs[i]);
610619 }
620+ */
611621 }
612622 export_to_ROS_time_ = ros::Time::now ().toSec ()-t;;
613623}
@@ -767,7 +777,7 @@ void acquisition::Capture::run_soft_trig() {
767777 }
768778
769779 double disp_time_ = ros::Time::now ().toSec () - t;
770-
780+
771781 // Call update functions
772782 if (!MANUAL_TRIGGER_) {
773783 cams[MASTER_CAM_].trigger ();
@@ -792,7 +802,7 @@ void acquisition::Capture::run_soft_trig() {
792802 }
793803
794804 if (EXPORT_TO_ROS_) export_to_ROS ();
795-
805+ // cams[MASTER_CAM_].targetGreyValueTest();
796806 // ros publishing messages
797807 acquisition_pub.publish (mesg);
798808
@@ -1008,3 +1018,20 @@ std::string acquisition::Capture::todays_date()
10081018 std::string td (out);
10091019 return td;
10101020}
1021+
1022+ void acquisition::Capture::dynamicReconfigureCallback (spinnaker_sdk_camera_driver::spinnaker_camConfig &config, uint32_t level){
1023+ ROS_INFO_STREAM (" Dynamic Reconfigure: Target grey value : " << config.target_grey_val <<" Exposure " <<config.exposure_time );
1024+ ROS_INFO_STREAM (" Dynamic Reconfigure: Level : " << level);
1025+
1026+ if (level == 1 ){
1027+ cams[MASTER_CAM_].setEnumValue (" AutoExposureTargetGreyValueAuto" , " Off" );
1028+ cams[MASTER_CAM_].setFloatValue (" AutoExposureTargetGreyValue" , config.target_grey_val );
1029+ }
1030+ else if (level == 3 && config.exposure_time > 0 ){
1031+ cams[MASTER_CAM_].setEnumValue (" ExposureAuto" , " Off" );
1032+ cams[MASTER_CAM_].setEnumValue (" ExposureMode" , " Timed" );
1033+ cams[MASTER_CAM_].setFloatValue (" ExposureTime" , config.exposure_time );
1034+ }
1035+
1036+
1037+ }
0 commit comments