[ros-users] need help: set_parameters service callback very sluggish with nodelet-based camera1394 driver

Jack O'Quin jack.oquin at gmail.com
Mon Jan 24 23:24:21 UTC 2011


I am testing the latest camera1394 trunk version on unstable. This
package implements both a camera1394_node driver and a
camera1394/driver nodelet. Most of the code is common to the node and
nodelet implementations.

I noticed that the dynamic reconfigure GUI, which is quite responsive
with the node driver, responds very sluggishly with the nodelet
implementation (sometimes 10 or more seconds).

There are threading differences in these two implementations. The
nodelet version spawns a boost thread to poll the device, while the
node version runs the poll() and ros::spinOnce() in the same main
loop. Due to the separate nodelet poll thread, there is a lock to
serialize access to the device between poll() and reconfig() calls:

{{{
  /** device poll */
  void Camera1394Driver::poll(void)
  {
    bool do_sleep = false;
    {
      // do not run concurrently with reconfig()
      boost::mutex::scoped_lock lock(mutex_);
      do_sleep = (state_ == Driver::CLOSED);
      if (!do_sleep)
        {
          // driver is open, read the next image still holding lock
          sensor_msgs::ImagePtr image(new sensor_msgs::Image);
          if (read(image))
            {
              publish(image);
            }
        }
    }

    if (do_sleep)
      {
        // device was closed, sleeping avoids busy wait
        // (DO NOT hold the lock while sleeping)
        cycle_.sleep();
      }
  }
}}}

The reconfig() method holds the same lock until the callback returns.

I recently changed this to fix a race condition when reconfig() tries
to open the device but fails. But, sluggish performance persists. I
experimented with using the MT nodelet interfaces, but that made no
observable improvement.

I don't understand the nodelet implementation well enough to know what
to try. I would appreciate some hints or suggestions for how to fix
this. It's a serious usability problem right now.

Is there any way to call something like ros::spinOnce() in the poll thread?
-- 
 joq



More information about the ros-users mailing list