ros-drivers / flir_camera_driver

168 stars 158 forks source link

U3VMessageChannelID doesn't exist on GigE #27

Open zlacelle opened 5 years ago

zlacelle commented 5 years ago

On a Blackfly S GigE camera, the spinnaker_camera_driver adds a parameter to the DiagnosticsManager of name "U3VMessageChannelID", which does not exist on the GigE cameras. This causes an exception:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Unable to get parmeter U3VMessageChannelID

Fixed this with a change to the driver to have a parameter for USB3 vs GigE. Patch is below.

diff --git a/spinnaker_camera_driver/launch/camera.launch b/spinnaker_camera_driver/launch/camera.launch
index 68576f3..b8227ad 100644
--- a/spinnaker_camera_driver/launch/camera.launch
+++ b/spinnaker_camera_driver/launch/camera.launch
@@ -29,6 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI
   <arg name="camera_name" default="camera" />
   <arg name="camera_serial" default="0" />
   <arg name="calibrated" default="0" />
+  <arg name="device_type" default="USB3" /> <!-- USB3 or GigE -->

   <group ns="$(arg camera_name)">
     <node pkg="nodelet" type="nodelet" name="camera_nodelet_manager" args="manager" cwd="node" output="screen"/>
@@ -38,7 +39,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI

       <param name="frame_id" value="camera" />
       <param name="serial" value="$(arg camera_serial)" />
-
+      <param name="device_type" value="$(arg device_type)" />
+      
       <!-- When unspecified, the driver will use the default framerate as given by the
            camera itself. Use this parameter to override that value for cameras capable of
            other framerates. -->
diff --git a/spinnaker_camera_driver/src/nodelet.cpp b/spinnaker_camera_driver/src/nodelet.cpp
index b5263a0..c835b08 100644
--- a/spinnaker_camera_driver/src/nodelet.cpp
+++ b/spinnaker_camera_driver/src/nodelet.cpp
@@ -334,6 +334,8 @@ private:

     // Set up a diagnosed publisher
     double desired_freq;
+    std::string device_type;
+    pnh.param<std::string>("device_type", device_type, "USB3");
     pnh.param<double>("desired_freq", desired_freq, 30.0);
     pnh.param<double>("min_freq", min_freq_, desired_freq);
     pnh.param<double>("max_freq", max_freq_, desired_freq);
@@ -370,7 +372,10 @@ private:
     diag_man->addDiagnostic("PowerSupplyVoltage", true, std::make_pair(4.5f, 5.2f), 4.4f, 5.3f);
     diag_man->addDiagnostic("PowerSupplyCurrent", true, std::make_pair(0.4f, 0.6f), 0.3f, 1.0f);
     diag_man->addDiagnostic<int>("DeviceUptime");
-    diag_man->addDiagnostic<int>("U3VMessageChannelID");
+    if( device_type.compare("USB3") == 0 )
+    {
+      diag_man->addDiagnostic<int>("U3VMessageChannelID");
+    }
   }

   /**
zeeshanhabibvirani commented 4 years ago

Thanks Alot!