Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service::waitForService stuck in ros::Duration::sleep when use_sim_time true without /clock publisher, because using ros::Duration::sleep instead of ros::WallDuration::sleep #1492

Closed
alrros opened this issue Aug 22, 2018 · 3 comments

Comments

@alrros
Copy link

alrros commented Aug 22, 2018

The function service::waitForService in file libros/service.cpp
uses ros::Duration::sleep instead of ros::WallDuration::sleep,
which leads to the side effect of beeing stuck in ros::Duration::sleep
under the following conditions:

  • use_sim_time is set as ros parameter
  • no simulated time publisher is active (no /clock publisher)
  • the service provider is not yet available

This case is significantly critical, when:

  • using a nodelet as /clock publisher
  • starting nodelet manager and nodelet loader in 1 roslaunch
    --> in 99/100 cases everything is fine
    --> in 1/100 cases the nodelet loader gets stuck in service::waitForService -> ros::Duration::sleep

Although nodelet is used as an example, the main problem is the usage of ros::Duration::sleep at service client initialization instead of ros::WallDuration::sleep.

Quick Reproduction:
The problem can be quickly reproduced the following way by using the service "load_nodelet" of the nodelet manager as an example:
case A) everything is fine

  • first: terminal 1: roscore
  • then: terminal 2: rosparam set use_sim_time "true"
  • then: terminal 3: rosrun nodelet nodelet manager __name:=nodelet_manager
  • then: (wait 1s)
  • then: terminal 4: rosrun nodelet nodelet load nodelet_tutorial_math/Plus nodelet_manager __name:=nodelet1 nodelet1/in:=foo _value:=1.1
  • then: terminal 5: rosservice call /nodelet_manager/list
    ==> nodelet is loaded

case B) stuck, no nodelet loaded

  • first: terminal 1: roscore
  • then: terminal 2: rosparam set use_sim_time "true"
  • then: terminal 3: rosrun nodelet nodelet load nodelet_tutorial_math/Plus nodelet_manager __name:=nodelet1 nodelet1/in:=foo _value:=1.1
  • then: (wait 1s)
  • then: terminal 4: rosrun nodelet nodelet manager __name:=nodelet_manager
  • then: terminal 5: rosservice call /nodelet_manager/list
    ==> no nodelet loaded, empty list

(note: no /clock publisher is active, but ros::Duration::sleep is never executed in case A)



function

  • bool service::waitForService(const std::string& service_name, ros::Duration timeout)

in file

  • ros_comm/clients/roscpp/src/libros/service.cpp

uses

  • ros::Duration::sleep

instead of

  • ros::WallDuration::sleep

under the following conditions

  • use_sim_time is set as ros parameter
  • no simulated time publisher is active (no /clock publisher)
  • the service provider is not yet available

causing critical side effect:

  • beeing stuck in service::waitForService -> ros::Duration::sleep
@dirk-thomas
Copy link
Member

Please consider to provide a PR with the proposed change.

@khssnv
Copy link

khssnv commented Jan 7, 2019

Faced the same in ROS Kinetic / rospy.

@cwecht
Copy link
Contributor

cwecht commented Feb 28, 2019

@khssnv your problem seems to have a different cause. rospys wait_for_service function relies not on rostime (as far as I can see).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants