ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Hi,

Here is the functions we use in our init.d file to start / stop ros. It prints the output of the node in tty8 and tty9. It could be combined with screen for easier use as well.

start_ros () {
    source /opt/ros/setup.sh

    roscore <>/dev/tty8 2>/dev/tty8 & disown
    until rostopic list ; do sleep 1; done
    roslaunch YOUR_PACKAGE YOUR_LAUNCH_FILE.launch <> /dev/tty9 2>/dev/tty9 & disown
}

stop_ros () {
    source /opt/ros/setup.sh

    #killall nodes
    for i in $( rosnode list ); do
    rosnode kill $i;
    done

    #stop roscore
    killall roscore
}