ros commands launched using subprocess keep repeating
I am trying to execute a bunch of ROS commands using a shell script in a python node. However, everytime I launch a process using subprocess.call(['./config/reset.sh'])
, the script keeps looping and does not stop executing. The contents of the reset.sh
script are as follows:
#!/usr/bin/env bash
rosservice call /controller_manager/switch_controller [] ["arm_position_controller"] 2
rosservice call /gazebo/pause_physics
rosservice call /gazebo/set_model_configuration '{model_name: robot, joint_names: [joint_a1, joint_a2, joint_a3, joint_a4, joint_a5, joint_a6], joint_positions: [0, -1.5, 1.5, 0, 1, 0]}'
sleep 2
rosservice call /controller_manager/switch_controller ["arm_position_controller"] [] 2 &
sleep 2
rosservice call /gazebo/unpause_physics
I should add that executing the script from the terminal runs it once successfully.
This is most likely not a ROS problem, but something with how you use
subprocess
or how your script is setup.It would perhaps be better to post this question on a forum that is focused on solving these kinds of problems.