PickNikRobotics / rviz_visual_tools

C++ API wrapper for displaying shapes and meshes in Rviz
771 stars 243 forks source link

trigger() blocks forever - bug? #146

Closed CodeFinder2 closed 2 years ago

CodeFinder2 commented 4 years ago

Hi,

I am facing the problem that

    ROS_ERROR("FOO");
    visual_tools->trigger();
    ROS_ERROR("BAR");

does not return. Even when Rviz connects, nothing will happen. I don't know if this is related to my issue but note that neither visual_tools->loadMarkerPub(false, true); nor visual_tools->loadMarkerPub(true, true); is working. (I am requiring latched topics.)

Once I comment this block:

  // Check if connected to a subscriber
  if (!pub_rviz_markers_waited_ && !pub_rviz_markers_connected_)
  {
    ROS_DEBUG_STREAM_NAMED(LOGNAME, "Waiting for subscribers before publishing markers...");
    waitForSubscriber(pub_rviz_markers_);

    // Only wait for the publisher once, after that just ignore the lack of connection
    pub_rviz_markers_waited_ = true;
  }

in the implementation of RvizVisualTools::publishMarkers() (invoked by trigger()), it is working fine.

Is this a bug? IMHO, there should be the possibility to skip the waitForSubscriber().

CodeFinder2 commented 4 years ago

Okay, nevermind: it is related to the ros::spinOnce() in RvizVisualTools::waitForSubscriber(). I have previously locked a mutex and if spinOnce() invokes a callback (locking the mutex again), it deadlocks.

So, would it be possible to skip waitForSubscriber()? Probably adding an additonal parameter?

mfocchi commented 4 years ago

Me and all my research group have the exact same issue. Is it going to be fixed? In which version?