wait_for_service fails when python node is launched using a launch file
I am training a deep reinforcement learning model using the Gazebo simulator. I have a python file that controls the robot in the Gazebo sim. Basically, the python file executes a step in the simulation, computes the reward value and resets the robot when it collides with something. For resetting the robots, I am using /gazebo/set_model_state
service. The python script needs some ROS parameters and I am launching it along with a YAML file using a launch file. The set up works fine when I am training a single turtlebot robot. However, when I try to train multiple turtlebots in the same simulation environment, the launch file fails with the following error message,
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 166, in wait_for_service
raise ROSInterruptException("rospy shutdown")
rospy.exceptions.ROSInterruptException: rospy shutdown
Now if I try to run the python file directly, it works fine without any error messages even while training multiple robots. I am not able to understand how launching the same python file with a launch file is causing this error. I initially thought this error might be because of simultaneous calls to the wait_for_service
. I even tried to provide random timeout
values when calling the wait_for_service
but that did not work either. Has anyone faced similar issue? Thanks in advance for any help!
Asked by utsavpatel on 2022-11-29 11:34:38 UTC
Comments