Skip to content

Instantly share code, notes, and snippets.

@PierrickKoch
Created May 7, 2012 06:19
Show Gist options
  • Select an option

  • Save PierrickKoch/2626230 to your computer and use it in GitHub Desktop.

Select an option

Save PierrickKoch/2626230 to your computer and use it in GitHub Desktop.
Test ROS topic
#!/bin/sh
testresult=$(mktemp)
roscore &
rospid=$!
sleep 5 # TODO find better way to wait roscore init (no flush stdout...)
echo "
###############################################################################
Start Testing
###############################################################################"
rostopic echo -n1 /test > $testresult &
rostopic pub -1 /test std_msgs/String "ProteusTestSucceed"
kill $rospid
wait $rospid
if grep "ProteusTestSucceed" $testresult; then
echo "
###############################################################################
Test Passed OK
###############################################################################"
else
echo "
###############################################################################
Test Failed
###############################################################################"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment