@@ -37,30 +37,38 @@ void acquisition::Camera::deinit() {
37
37
}
38
38
39
39
ImagePtr 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
42
44
43
- if (pResultImage->IsIncomplete ()) {
44
-
45
- ROS_WARN_STREAM (" Image incomplete with image status " << pResultImage->GetImageStatus () << " !" );
45
+ if (pResultImage->IsIncomplete ()) {
46
46
47
- } else {
47
+ ROS_WARN_STREAM ( " Image incomplete with image status " << pResultImage-> GetImageStatus () << " ! " );
48
48
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!" );
55
49
} 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
+
58
62
}
59
63
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 " );
60
69
}
61
70
62
- ROS_DEBUG_STREAM (" Grabbed frame from camera " << get_id () << " with timestamp " << timestamp_*1000 );
63
- return pResultImage;
71
+ return pResultImage;
64
72
}
65
73
66
74
// Returns last timestamp
@@ -80,8 +88,14 @@ int acquisition::Camera::get_frame_id() {
80
88
81
89
Mat acquisition::Camera::grab_mat_frame () {
82
90
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
+
85
99
86
100
}
87
101
0 commit comments