From e84557340a65a157ddbb5fb5c6b985118997ca1c Mon Sep 17 00:00:00 2001 From: Ramon Wijnands Date: Fri, 20 Nov 2015 17:13:14 +0100 Subject: [PATCH] make the travis setup_examples.sh script more robust - use roslaunch to deduplicate launching effort - use rostopic info to check for the last node's topic existance - return a status code based on if it succeeded --- test/examples/setup_examples.launch | 1 + test/examples/setup_examples.sh | 30 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/examples/setup_examples.launch b/test/examples/setup_examples.launch index eb240cdd7..7b36ff1db 100644 --- a/test/examples/setup_examples.launch +++ b/test/examples/setup_examples.launch @@ -2,6 +2,7 @@ + diff --git a/test/examples/setup_examples.sh b/test/examples/setup_examples.sh index 5d7943cd1..b38e4e4e9 100644 --- a/test/examples/setup_examples.sh +++ b/test/examples/setup_examples.sh @@ -1,23 +1,27 @@ if command -v rosrun 2>/dev/null; then echo "Shutting everything down" - ps aux | grep ros | awk '{print $2}' | xargs kill -9 + ps aux | grep [r]os | awk '{print $2}' | xargs kill -9 sleep 1 echo "Starting roscore and various examples in background processes" + roslaunch test/examples/setup_examples.launch > roslaunch.log & - nohup roscore > /dev/null 2>&1& - sleep 2 - nohup rosrun tf static_transform_publisher 0 0 0 0 0 0 world turtle1 100 > /dev/null 2>&1& - nohup rosrun tf2_web_republisher tf2_web_republisher > /dev/null 2>&1& - nohup rosrun actionlib_tutorials fibonacci_server > /dev/null 2>&1& - nohup rosrun rospy_tutorials add_two_ints_server > /dev/null 2>&1& - nohup rostopic pub /listener std_msgs/String "Hello, World" > /dev/null 2>&1& - # wait a moment then start up bridge - sleep 3 - nohup roslaunch rosbridge_server rosbridge_websocket.launch > /dev/null 2>&1& - sleep 3 - echo "Ready for lift off" + LAUNCHED=false + for i in 1 2 3 4 5 6 7 8 9 10 + do + echo "Waiting for /hello_world_publisher...$i" + sleep 1 + rostopic info /listener > /dev/null && LAUNCHED=true && break + done + if [ "$LAUNCHED" = true ] ; then + echo "Ready for lift off" + exit 0 + else + echo "/hello_world_publisher not launched" + exit 1 + fi else echo "Couldn't find ROS on path (try to source it)" echo "source /opt/ros/indigo/setup.bash" + exit 1 fi \ No newline at end of file