correcting the long pending errors

We need an alternative of ros::Asyncspinner in ROS2.

Links for discussion of this issue in github repository:

  1. Alternative for asyncspinner in ROS2 #6

  2. Segmentation fault with using Jderobot Image library with ROS2 #7

Progress::

Till last week I was stuck into segmentation fault and unable to debug it. I was able to find it and solve it. This was due to typecasting a class.

But, my tool was still not working.

Going ahead into the code, I was able to discover the actual problem.

I have been using a protected member function ‘run’ rclcpp::executors::MultiThreadedExecutor for this purpose as suggested by community is github isses 2 years back.

But it didn’t help too solve the problem completely.

What is the actual issue ?

My subscriber is being created, in the node BUT since the node is not spinning correctly so the subcriber isn’t subscribing to ROS2 image topics. In ros2 we have topic+ callback binded to subscriber, if node is not running as expected subscriber won’t run. My program is not going into the callback function.

Why is this error not coming in earlier codes?

  1. In other codes we are using rclcpp::spin() which does’t allow program to move ahead sequentially. It blocks callbacks working in background.

  2. With the use of spin I was able to go into callback function. But in this tool we have other threads running too. After spinning we got to return something into client (from CameraClient and getcameraclient class). Data returned into client will be passed to main Camviz.cpp where in a loop(for GUI), image data will be extracted and passed to GUI block for showing image.

In short, with this kinda architecture where we need to return something after spinning into client we can’t do directly as we were doing in other codes. We need something like start function where we can call our multithreaded asynchronous spinner to run the node.

Most probably, my implementation of this spinner, especially the line to add a new node to spin is wrong. If that is solved, we can solve the whole issue.

Why not dump the rclcpp::multithreaded spinner and build a threading function ourselves?

I tried this too. The issue we have here is again the ros2 architecture in which callbacks are binded to subscriber. Our callback function needs some argument parameters. But we have no idea how does subscriber passes those into callback function!

In this approach we can put callbacks in thread, but since we don’t know how subscriber gets the arg parameters from topic into callback. Without going into the source code of subscription it is difficult to do this thing according to me.

I was not able to solve this issue and get the tool working in ROS2, but I after working and debugging into this code in detail I have pointed out the problems and possible solutions. With a discussion in ros2 community with developers I can surely can answers to all shortcomings in my approaches.

Getting a response from them might take time.