@@ -37,30 +37,38 @@ void acquisition::Camera::deinit() {
3737}
3838
3939ImagePtr acquisition::Camera::grab_frame () {
40- ImagePtr pResultImage = pCam_->GetNextImage (GET_NEXT_IMAGE_TIMEOUT_);
41- // Check if the Image is complete
40+ ImagePtr pResultImage;
41+ try {
42+ pResultImage = pCam_->GetNextImage (GET_NEXT_IMAGE_TIMEOUT_);
43+ // Check if the Image is complete
4244
43- if (pResultImage->IsIncomplete ()) {
44-
45- ROS_WARN_STREAM (" Image incomplete with image status " << pResultImage->GetImageStatus () << " !" );
45+ if (pResultImage->IsIncomplete ()) {
4646
47- } else {
47+ ROS_WARN_STREAM ( " Image incomplete with image status " << pResultImage-> GetImageStatus () << " ! " );
4848
49- timestamp_ = pResultImage->GetTimeStamp ();
50-
51- if (frameID_ >= 0 ) {
52- lastFrameID_ = frameID_;
53- frameID_ = pResultImage->GetFrameID ();
54- ROS_WARN_STREAM_COND (frameID_ > lastFrameID_ + 1 ," Frames are being skipped!" );
5549 } else {
56- frameID_ = pResultImage->GetFrameID ();
57- ROS_ASSERT_MSG (frameID_ == 0 ," First frame ID was not zero! Might cause sync issues later..." );
50+
51+ timestamp_ = pResultImage->GetTimeStamp ();
52+
53+ if (frameID_ >= 0 ) {
54+ lastFrameID_ = frameID_;
55+ frameID_ = pResultImage->GetFrameID ();
56+ ROS_WARN_STREAM_COND (frameID_ > lastFrameID_ + 1 ," Frames are being skipped!" );
57+ } else {
58+ frameID_ = pResultImage->GetFrameID ();
59+ ROS_ASSERT_MSG (frameID_ == 0 ," First frame ID was not zero! Might cause sync issues later..." );
60+ }
61+
5862 }
5963
64+ ROS_DEBUG_STREAM (" Grabbed frame from camera " << get_id () << " with timestamp " << timestamp_*1000 );
65+ return pResultImage;
66+ }
67+ catch (Spinnaker::Exception &e){
68+ ROS_FATAL_STREAM (e.what ()<<" \n Likely reason is that slaves are not triggered. Check GPIO cables\n " );
6069 }
6170
62- ROS_DEBUG_STREAM (" Grabbed frame from camera " << get_id () << " with timestamp " << timestamp_*1000 );
63- return pResultImage;
71+ return pResultImage;
6472}
6573
6674// Returns last timestamp
@@ -80,8 +88,14 @@ int acquisition::Camera::get_frame_id() {
8088
8189Mat acquisition::Camera::grab_mat_frame () {
8290
83- ImagePtr pResultImage = grab_frame ();
84- return convert_to_mat (pResultImage);
91+ try {
92+ ImagePtr pResultImage = grab_frame ();
93+ return convert_to_mat (pResultImage);
94+ }
95+ catch (Spinnaker::Exception &e){
96+ ros::shutdown ();
97+ }
98+
8599
86100}
87101
0 commit comments