Skip to content

Instantly share code, notes, and snippets.

@xaxxontech
Last active June 16, 2021 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xaxxontech/b70e8f18e4570a07724eca9f9f6f0307 to your computer and use it in GitHub Desktop.
Save xaxxontech/b70e8f18e4570a07724eca9f9f6f0307 to your computer and use it in GitHub Desktop.
Launching ROS1 commands from Java
#!/bin/bash
#setup ROS1 environment and execute params as single quoted string
# loads ROS environment
source $HOME/stuff/cartographer_catkin_ws/install_isolated/setup.bash
source $HOME/catkin_ws/devel/setup.bash --extend
rosclean purge -y
if ! rostopic list
then
roscore &
sleep 5
fi
date >> logs/ros.log
if [ -z "$@" ]; then
exit 1
fi
echo $@ >> logs/ros.log
stdbuf -o0 $@ >> logs/ros.log 2>&1 &
#print PID of last command
echo PID: $!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment