Skip to content

Instantly share code, notes, and snippets.

@gokhansolak
Last active November 17, 2020 12:06
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 gokhansolak/a0e423822dc8e55f149a7581b82dc4d6 to your computer and use it in GitHub Desktop.
Save gokhansolak/a0e423822dc8e55f149a7581b82dc4d6 to your computer and use it in GitHub Desktop.
Repeats ROS experiments, keeps a notes file in Markdown format
#!/usr/bin/env bash
# This script calls a certain ROS launch file with incremental experiment numbers,
# and records user notes in order to a markdown (md) file.
# exp_type: name of the launch file
# exp_no: last index to start from
#
#
# usage (arguments are optional):
# ./iterate_exp.sh exp_type exp_no ros_package[optional]
# ros package containing the experiment programs
ros_package="lfd_experiments"
# get user input if arguments are not given
if [ "$#" -lt "1" ]; then
echo "exp type:"
read typ
else
typ=$1
fi
if [ "$#" -lt "2" ]; then
echo "initial exp_no:"
read exp
else
exp=$2
fi
# optional argument
if [ "$#" -eq "3" ]; then
ros_package=$3
fi
# obj and task info changes rarely, just restart the script if needed
echo "Obj no:"
read obj
echo "Task no:"
read task
# do while user enter "n"
yn="y"
while [ "$yn" == "y" ]
do
echo "$typ experiment no: $exp"
# record user's notes before the experiment
echo "Enter notes:"
read notes
# optionally, ignore the experiment, don't write notes etc.
if [ "$notes" != "ignore" ]; then
timestamp=`date +"%d/%m/%Y %H:%M"`
echo -e "\n#### Experiment $exp: [obj $obj, task $task] \n*$timestamp*" >> ${typ}_notes.md
echo -e "* **before:**\t$notes" >> ${typ}_notes.md
fi
# launch the ROS experiment programs
roslaunch ${ros_package} ${typ}.launch record:=true exp_no:=$exp obj_type:=$obj task_type:=$task
roslaunch ${ros_package} dump_params.launch exp_no:=$exp prefix:=$typ
# after experiment, write notes if not ignored
if [ "$notes" != "ignore" ]; then
# record user's notes after the experiment
echo "Enter results:"
read results
echo -e "* **after:** \t$results" >> ${typ}_notes.md
let "exp++"
fi
# terminate optionally
read -p "Repeat experiment? (y/n)" yn
done;
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment