0
$\begingroup$

I am trying to consolidate a few nodes into a single process using nodelets. I have a ObjectDetectionNodelet that has a subscriber that subscribes to the raw image data. Every time I run the subscriber node, it crashes the driver.

[camera_1_nodelet_manager-1] process has died [pid 15157, exit code -11, cmd /opt/ros/noetic/lib/nodelet/nodelet manager __name:=camera_1_nodelet_manager __log:=/home/user/.ros/log/7d8a6240-bfde-11d3-9583-48b02d75c59c/camera_1_nodelet_manager-1.log].
log file: /home/user/.ros/log/7d8a6240-bfde-11d3-9583-48b02d75c59c/camera_1_nodelet_manager-1*.log
[camera_1/spinnaker_camera_nodelet_camera_1-2] process has finished cleanly
log file: /home/user/.ros/log/7d8a6240-bfde-11d3-9583-48b02d75c59c/camera_1-spinnaker_camera_nodelet_camera_1-2*.log
[ObjectDetectionNodelet-3] process has finished cleanly
log file: /home/user/.ros/log/7d8a6240-bfde-11d3-9583-48b02d75c59c/ObjectDetectionNodelet-3*.log

Can someone please evaluate by current setup and check launch files if I am doing any mistake in starting multiple nodelets? Any help is appreciated.

Following is my current setup:

  • I am using Blackfly S cameras for my application and using the spinnaker_camera_driver to stream data and this publishes image data to a topic /camera_1/image_raw . Here is a link to spinnaker nodelet that publishes raw data

  • I have a separate package which contains code for object detection. My current launch file looks like the following where I setup a nodelet manager camera_1_nodelet_manager and start the SpinnakerCameraNodelet and ObjectDetectionNodelet in the same nodelet manager:

Main launch file -

<?xml version="1.0"?>
<launch>
  <arg name="camera_name"               default="camera_1" />
  <arg name="nodelet_manager_name"      default="$(arg camera_name)_nodelet_manager" />
>       
>       <!-- Nodelet manager-->
>       <node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager_name)"  args="manager" output="screen"/>

  <!-- Load spinnaker nodelet-->
  <include file="$(find spinnaker_camera_driver)/launch/gige_camera.launch">
>         <arg name="nodelet_manager_name"    value="$(arg nodelet_manager_name)" />
    <arg name="camera_name"             value="$(arg camera_name)" />
>       </include>
>     
>       <!-- Load object detection nodelet-->
>       <node pkg="nodelet" type="nodelet" name="ObjectDetectionNodelet" 
>             args="load object_detection_nodelet/ObjectDetectionNodelet /$(arg nodelet_manager_name)">
    <param name="camera_name"           value="$(arg camera_name)" />
  </node>
</launch>

And the included launch file from spinnaker camera driver is the following -

<?xml version="1.0"?>
<launch>
  <arg name="camera_name"                     default="camera_1" />
  <arg name="calibrated"                      default="0" />
  <arg name="nodelet_manager_name"            default="camera_1_nodelet_manager" />

  <group ns="$(arg camera_name)">    
    <!-- Camera nodelet -->
    <node pkg="nodelet" type="nodelet" name="spin_cam_nodelet" args="load spinnaker_camera_driver/SpinnakerCameraNodelet /$(arg nodelet_manager_name)" >
      <param name="frame_id"            value="$(arg camera_name)" />
    </node>
  </group>
</launch>

object_detection_nodelet.cpp is as follows:

#include <pluginlib/class_list_macros.h>
#include <object_detection/object_detection_nodelet.h>

namespace object_detection_nodelet {

ObjectDetectionNodelet::ObjectDetectionNodelet() {}

void ObjectDetectionNodelet::onInit(void) {
  std::string cameraName;
  ros::NodeHandle& privateNh = getPrivateNodeHandle();

  privateNh.getParam("camera_name", cameraName);

  m_ObjectDetectionPtr_.reset(new ObjectDetection(cameraName, getNodeHandle()));
}
};  // namespace object_detection_nodelet

PLUGINLIB_EXPORT_CLASS(object_detection_nodelet::ObjectDetectionNodelet, nodelet::Nodelet);

And the object_detection.cpp node which has the subscriber is as follows:

#include <object_detection/object_detection.h>

ObjectDetection::ObjectDetection(const std::string& cameraName, ros::NodeHandle& nh)
    : m_CameraName_(cameraName),
      tracker_(120) {

  image_sub = nh.subscribe(cameraName + "/image_raw", 10, &ObjectDetection::inputImageCallback_, this);
  image_pub = nh.advertise<sensor_msgs::Image>(cameraName + "/roi_image", 10);
}

void ObjectDetection::inputImageCallback_(const sensor_msgs::Image::ConstPtr& msg) {
  cv::Mat inputImage = ImageConverter::convertToCvMat(msg);
  cv::Mat filteredImage;

  sensor_msgs::Image outputImageMsg = ImageConverter::convertToRosImage(filteredImage);
  image_pub.publish(outputImageMsg);
}
$\endgroup$
3
  • $\begingroup$ What actual error are you getting? You've provided a lot of information here, but not the actual error that you're trying to solve. $\endgroup$
    – cst0
    Sep 15, 2023 at 0:18
  • $\begingroup$ I have updated the post with the error message. It doesn't give any relevant info except that the process died $\endgroup$
    – nebula
    Sep 15, 2023 at 14:24
  • $\begingroup$ convertToRosImage() may not like a default-constructed cv::Mat. As Mike F suggests, the most efficient way to find the problem is to connect gdb to your running nodelet manager process. $\endgroup$
    – Mike973
    Sep 16, 2023 at 12:58

1 Answer 1

1
$\begingroup$

I would suspect that the problem is not with your posted code - but rather the driver itself.

The driver is likely implemented as a lazy publisher - this means that it does not interact with the hardware until a ROS subscriber connects and needs messages to be generated. I would suggest that you look at the logs from the driver itself to further debug this issue.

$\endgroup$
2
  • $\begingroup$ But if I launch the driver ros code by itself, then it publishes data to the topic. I can view it on rqt_image_view. In case of a lazy publisher that shouldn't work right?I am adding a link to the actual spinnaker nodelet that publishes the raw image $\endgroup$
    – nebula
    Sep 15, 2023 at 14:27
  • $\begingroup$ Ok - that changes things quite a bit. Since everything is running inside the same nodelet manager your nodelet could actually be the thing crashing. I notice a bunch of pointers involved as well as an "ImageConverter" which we have no information about. Your error message has 3 log files - look in those for any output (is the format of the image incorrect, etc). If that doesn't give you any information, you likely have a segfault or similar issue which will involve connecting gdb to find out where your code is going wrong. $\endgroup$ Sep 16, 2023 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.