Skip to content

Commit 15aeb14

Browse files
Vikrant Shahvik748
andauthored
Print camera model and version for connected cameras (#96)
* Print camera model and version for connected cameras * Fixing the stack trace on exit by clearing camera vector Co-authored-by: Vikrant Shah <[email protected]>
1 parent 28dc9d5 commit 15aeb14

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ data/
1717
devel
1818
~devel/lib/datacollection_neu/*.xml
1919
.catkin_workspace
20+
include/spinnaker_sdk_camera_driver/spinnaker_configure.h
2021

2122
# ignore doc/notes.txt, but not doc/server/arch.txt
2223
#doc/*.txt

include/spinnaker_sdk_camera_driver/camera.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ namespace acquisition {
5959
// void setTrigMode();
6060
// void setTriggerOverlapOff();
6161

62+
string get_node_value(string node_string);
6263
string get_id();
6364
void make_master() { MASTER_ = true; ROS_DEBUG_STREAM( "camera " << get_id() << " set as master"); }
6465
bool is_master() { return MASTER_; }

src/camera.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
acquisition::Camera::~Camera() {
44

5-
pCam_ = NULL;
5+
pCam_ = nullptr;
66
timestamp_ = 0;
77

88
}
@@ -292,15 +292,19 @@ void acquisition::Camera::trigger() {
292292

293293
}
294294

295-
string acquisition::Camera::get_id() {
295+
string acquisition::Camera::get_node_value(string node_string) {
296296
INodeMap& nodeMap = pCam_->GetTLDeviceNodeMap();
297-
CStringPtr ptrDeviceSerialNumber = nodeMap.GetNode("DeviceSerialNumber");
298-
if (IsReadable(ptrDeviceSerialNumber)){
299-
return string(ptrDeviceSerialNumber->GetValue());
297+
CStringPtr ptrNodeValue = nodeMap.GetNode(node_string.c_str());
298+
if (IsReadable(ptrNodeValue)){
299+
return string(ptrNodeValue->GetValue());
300300
}
301301
return "";
302302
}
303303

304+
string acquisition::Camera::get_id() {
305+
return get_node_value("DeviceSerialNumber");
306+
}
307+
304308
void acquisition::Camera::targetGreyValueTest() {
305309
CFloatPtr ptrExpTest =pCam_->GetNodeMap().GetNode("AutoExposureTargetGreyValue");
306310
//CFloatPtr ptrExpTest=pCam_->GetNodeMap().GetNode("ExposureTime");

src/capture.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ acquisition::Capture::~Capture(){
2222
camList_.Clear();
2323

2424
ROS_INFO_STREAM("Releasing camera pointers...");
25-
for (int i=0; i<cams.size(); i++)
26-
cams[i].~Camera();
25+
cams.clear();
2726

2827
ROS_INFO_STREAM("Releasing system instance...");
2928
system_->ReleaseInstance();
@@ -130,6 +129,7 @@ void acquisition::Capture::init_variables_register_to_ros() {
130129
read_parameters();
131130

132131
// Retrieve singleton reference to system object
132+
ROS_INFO_STREAM("*** SYSTEM INFORMATION ***");
133133
ROS_INFO_STREAM("Creating system instance...");
134134
system_ = System::GetInstance();
135135

@@ -166,8 +166,10 @@ void acquisition::Capture::load_cameras() {
166166

167167
for (int i=0; i<numCameras_; i++) {
168168
acquisition::Camera cam(camList_.GetByIndex(i));
169-
ROS_INFO_STREAM(" -"<<cam.get_id());
170-
}
169+
ROS_INFO_STREAM(" -"<< cam.get_id()
170+
<<" "<< cam.get_node_value("DeviceModelName")
171+
<<" "<< cam.get_node_value("DeviceVersion") );
172+
}
171173

172174
bool master_set = false;
173175
int cam_counter = 0;

0 commit comments

Comments
 (0)