How to run ROS command from a python script?
Hello! I need some help as I was trying to write a python script which could run some ROS commands, such as $rostopic list and $rostopic echo(while some nodes are running). I tried something like the following, but none of them works. when I tried this:
os.system("rostopic list")
I got this error when I ran the above: sh: 1: rostopic: not found
Or this:
subprocess.call(["rostopic", "list"])
It was not working and a error message was given like this "FileNotFoundError: [Errno 2] No such file or directory: 'rostopic'"
I was thinking about execute a shell script from my python script, but I don't know how to write one for running ROS commands.
I appreciate any help!