Running three scripts at the same time


#1

Hi, I have three scripts that I need to run them at the same time.
One is to take off, set the drone to a position and land it.
One is to subscribe imu data from mavros api and publish it to a topic.

One is to subscribe from the topic and transform it to a tf format.

when I run them at the same time, sometimes one of the process started earlier tells me that “shutdown request: new node registered with same name” . But sometimes it can run smoothly. I also need to do rosbag record -a, and all three scripts crash when I do rosbag.

The scripts can be accessed through the following link

https://drive.google.com/drive/folders/1oRzqUesq9GqZWesNZhCWkUHfNOpg0PxL?usp=sharing

Could you please advise on what I should do!


#2

Hi @kellykhoooo,

Give me some time to go through this. Will try to suggest something ASAP.


#3

ROS api requires every node has unique name. If you unsure about uniqueness pass anonymous=True parameter to init_node function.


#4

When you run these scripts, how are you exiting from the scripts?
Only your Execute_app is designed to exit after doing certain actions, but other two apps will run perpetually.

I think this is what is happening ->
You boot up your CC/Laptop
You execute all 3 apps and they all run and work just fine
Now you try to re-execute them after a while, and the execute_app starts up just fine, but the other two throws this error: “shutdown request: new node registered with same name” . But this is still not a big problem, as this is just cleaning up the previous 2 apps that you were running.

You have a couple of options:

  • Just let it be the way things are. This should not cause any trouble for you.
  • Create a hook, so that if execute_app.py exits, it shd trigger other 2 apps to exit as well. You can use params to do this. You can set/reset a param just before execute_app exits. In other 2 apps, you can keep checking the param’s value in a while loop with sleep.
  • You can manually kill the nodes using rosnode kill <nodename>

The suggestion of @efeevren, is also correct. And if you use ‘anonymous’ tag then our problem would also be solved, but I would strongly suggest against it. If you use ‘anonymous’ and do not take any step to close/exit the previous running apps, then very soon your system would be flooded with such ‘ghost’ apps which have no purpose.