rosrun vs roslaunch to run a single node, any difference?
Hi everyone!
Well, in my understanding launch
files are meant to launch a node or so many nodes at a time and allow setting parameters dynamically , remapping and making sure that nodes don't stop if respawn
is set to True
and so many other stuff.
I was wondering what is the difference between:
<?xml version="1.0"?>
<launch>
<node name="my_node" pkg="my_package" type="my_node"/>
</launch>
and
roscore&
rosrun my_package my_node
There shouldn't be any difference ?!
In my case, when using rosrun
, my node was crashing every 30 min and no ros logs where generated but when using roslaunch
instead, it didn't crash for hours and the log files where saved successfully.
Is it just a coincidence!? or does the roslaunch
command run nodes in a more coherent way?
I would be pleased if you could explain this to me...
Thanks!
Edit 1
In response to john.j.oneill 's comment
Basically I'm running the node from a bash script, start_my_node.sh
and I do use the &
after the rosrun
command, my script is as follows:
#!/bin/bash
#ROS exportations
#ROS source
roscore&
sleep 1
rosrun my_package my_node&
So it is not about having a lot of text in the output?
Is using a similar script a good way to start ros nodes?