I ran my obstacle_avoider.bash file on simulation and it worked fine, however, when I tried to run it on the real FastBot3, it wasn’t working (I had connected to it and tested it with the joystick and it does work). I rebooked the robot 2 hours later and found the robot with one of it’s wheels off.
Hello @janimahmood22 ,
The robot has been fixed and is working properly now. Please try again to run your code and let us know how it goes.
Best,
Thank you for that. I have another issue where the cameras are not streaming, they are just buffering, so I cannot see footage of the robot.
@albertoezquerro
Please check again. The cameras are up now.
Hello, the buffering is still present on the cameras. I also tried running the obstacle_avoider.bash script on the robot and the robot seems to be responding to the forward moving commands (based in what I can see on the robot visualiser) but not the left and right turn commands. I tested my code on simulation and it was working (i.e., the robot was going forward, left and right on simulation).
Hello @janimahmood22 ,
There was an issue with this lab cameras that should now be fixed. Please let us know if it’s working correctly for you the next time you access the lab.
Best,
Hello, the camera does work now thank you very much. I am having another issue if you wouldn’t mind helping me with it. The robot can go forward but cannot go left or right even though the command is being issued based on the debug messages I receive from the code. I have also attached the obstacle_avoider bash file that I have been using below. I would really appreciate it if you could help me with this.
#! /usr/bin/bash
# include the functions library
source ./robot_functions.bash
# naive obstacle avoider
# this is an infinite while loop - use ctrl+c to break
echo "Running Naive Obstacle Avoider with Bash Script..."
echo "Press Ctrl+C to Terminate..."
# make sure that the robot is stopped initially
# set linear velocity to zero here
set_cmd_vel_linear 0.00
# ...
# set angular velocity to zero here
set_cmd_vel_angular 0.00
# ...
# set obstacle avoidance distance threshold
threshold=0.300
# ...
# your own function definitions, if you have any
# ...
# ...
# ...
# main while loop for naive obstacle avoider
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
while :
do
# get all the five scan ranges
# get the left scan range
scan_left_ray_range=$(get_scan_left_ray_range)
# ...
# get the front left scan range
scan_front_left_ray_range=$(get_scan_front_left_ray_range)
# ...
# get the front scan range
scan_front_ray_range=$(get_scan_front_ray_range)
# ...
# get the front right scan range
scan_front_right_ray_range=$(get_scan_front_right_ray_range)
# ...
# get the right scan range
scan_right_ray_range=$(get_scan_right_ray_range)
# ...
# check if the three frontal scan ranges are less than threshold
# check if front left scan is less than threshold
front_left_free=$(echo "$scan_front_left_ray_range > $threshold" | bc -l)
# ...
# check if front scan is less than threshold
front_free=$(echo "$scan_front_ray_range > $threshold" | bc -l)
# ...
# check if front right scan is less than threshold
front_right_free=$(echo "$scan_front_right_ray_range > $threshold" | bc -l)
# ...
# provide conditions for 8 different cases of frontal scan ranges
# if front left is not free and front is not free and front right is not free
if [[ "$front_left_free" == "0" && "$front_free" == "0" && "$front_right_free" == "0" ]]; then
# ...
# decide direction to turn based on left and right scan ranges
# if left scan range is more than right scan range
if (( $(echo "$scan_left_ray_range > $scan_right_ray_range" | bc -l ) )); then
# turn left
# ...
echo "turning left..."
set_cmd_vel_angular 0.31416
# if left scan range is less than right scan range
else
# turn right
# ...
echo "turning right..."
set_cmd_vel_angular -0.31416
fi
# wait for the robot to turn - tune delay accordingly
sleep 1
# set angular velocity back to zero
set_cmd_vel_angular 0.000
# elif front left is not free and front is not free and front right is free
elif [[ "$front_left_free" == "0" && "$front_free" == "0" && "$front_right_free" == "1" ]]; then
# turn right
# ...
echo "turning right..."
set_cmd_vel_angular -0.31416
# wait for the robot to turn - tune delay accordingly
sleep 1
# set angular velocity back to zero
set_cmd_vel_angular 0.000
# elif front left is not free and front is free and front right is not free
elif [[ "$front_left_free" == "0" && "$front_free" == "1" && "$front_right_free" == "0" ]]; then
# move forward for roughly (front range - threshold) meters
# ...
dist_to_move=$(echo "$scan_front_ray_range - $threshold" | bc -l)
# calculate time with fixed speed of 0.1 m/s
# ...
time_to_move=$(echo "$dist_to_move / 0.100" | bc -l)
# subtract 1 second for parameter setting delay
# ...
# ...
# ...
time_to_move=$(echo "$time_to_move - 1.000" | bc -l)
# time_to_move=$(echo "$time_to_move / 1" | bc) # truncate to integer
echo "dist_to_move: $dist_to_move meters"
echo "time_to_move: $time_to_move seconds"
echo "moving forward..."
set_cmd_vel_linear 0.100
sleep $time_to_move
# set linear velocity back to zero
# ...
set_cmd_vel_linear 0.000
# elif front left is not free and front is free and front right is free
elif [[ "$front_left_free" == "0" && "$front_free" == "1" && "$front_right_free" == "1" ]]; then
# turn right
# ...
echo "turning right..."
set_cmd_vel_angular -0.31416
sleep 1
# set angular velocity back to zero
set_cmd_vel_angular 0.000
# elif front left is free and front is not free and front right is not free
elif [[ "$front_left_free" == "1" && "$front_free" == "0" && "$front_right_free" == "0" ]]; then
# turn left
# ...
echo "turning left..."
set_cmd_vel_angular 0.31416
sleep 1
# set angular velocity back to zero
set_cmd_vel_angular 0.000
# elif front left is free and front is not free and front right is free
elif [[ "$front_left_free" == "1" && "$front_free" == "0" && "$front_right_free" == "1" ]]; then
# decide direction to turn based on left and right scan ranges
# if left scan range is more than right scan range
if (( $(echo "$scan_left_ray_range > $scan_right_ray_range" | bc -l ) )); then
# turn left
# ...
echo "turning left..."
set_cmd_vel_angular 0.31416
# if left scan range is less than right scan range
else
# turn right
# ...
echo "turning right..."
set_cmd_vel_angular -0.31416
fi
sleep 1
# set angular velocity back to zero
set_cmd_vel_angular 0.000
# elif front left is free and front is free and front right is not free
elif [[ "$front_left_free" == "1" && "$front_free" == "1" && "$front_right_free" == "0" ]]; then
# turn left
# ...
echo "turning left..."
set_cmd_vel_angular 0.31416
sleep 1
# set angular velocity back to zero
set_cmd_vel_angular 0.000
# else
else
# if front left is free and front is free and front right is free
# move forward for roughly (front range - threshold) meters
# ...
dist_to_move=$(echo "$scan_front_ray_range - $threshold" | bc -l)
# calculate time with fixed speed of 0.1 m/s
# ...
time_to_move=$(echo "$dist_to_move / 0.100" | bc -l)
# subtract 1 second for parameter setting delay
time_to_move=$(echo "$time_to_move - 1.000" | bc -l)
# time_to_move=$(echo "$time_to_move / 1" | bc) # truncate to integer
echo "dist_to_move: $dist_to_move meters"
echo "time_to_move: $time_to_move seconds"
echo "moving forward..."
set_cmd_vel_linear 0.100
sleep $time_to_move
# ...
# ...
# ...
# set linear velocity back to zero
set_cmd_vel_linear 0.000
# ...
fi
# print a divider line to show iteration is complete
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
done
# End of Code
Hello @janimahmood22 ,
Could you please share your rosject link with me so that I can test it directly? You can send it to my-email address: aezquerro@theconstruct.ai
This will help to debug the issue much faster.
Best,

