Hi
For Exercise 3.4 of Advanced Utilities | Linux for Robotics, I’d like to suggest the following improvement to the code provided in the Ex3.4 Solution.
Currently this script will give an “./ex3_4_script.sh: line 5: [: ==: unary operator expected” error due to the lack of double quotes inside the IF statements for $ARG1. Issue logged here "bash: [: =: unary operator expected" on Linux for Robotics course?
Other recommended changes provide in the code block below may also be helpful to beginners;
- use of ECHO as a useful debugging technique to see where a line succeeds/fails
- use of ELSE statement to;
demonstrate/prompt that an argument needs to be passed with the script
demonstrate how a student can create a simple user prompt
#!/bin/bash
ARG1=$1
if [ "$ARG1" == "circle" ]; then
echo "circling";
rosrun move_bb8_pkg move_bb8_circle.py
elif [ "$ARG1" == 'forward_backward' ]; then
echo "back and forth";
rosrun move_bb8_pkg move_bb8_forward_backward.py
elif [ "$ARG1" == "square" ]; then
echo "square dancing";
rosrun move_bb8_pkg move_bb8_square.py
else
echo "Please enter one of the following;
circle
forward_backward
square"
fi