Obstacle avoider is working for me but Robot statistics is not working. Please see my code below,
#! /usr/bin/bash
# include the functions library
source ./robot_functions.bash
# robot statistics
# this is an infinite while loop - use ctrl+c to break
echo "Running Robot Statistics with Bash Script..."
echo "Press Ctrl+C to Terminate..."
# main while loop for naive obstacle avoider
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
while :
do
# print distance covered since start
distance_covered=$(odom_distance)
echo "Distance covered: $distance_covered"
# print current direction of robot
direction_robot=$(odom_direction)
echo "Current Direction: $direction_robot"
# print odom position x, y, z
position_x=$(odom_position_x)
position_y=$(odom_position_y)
position_z=$(odom_position_z)
echo "Odom position x,y,z $position_x, $position_y, $position_z"
# print odom orientation r, p, y
orientation_r=$(odom_orientation_r)
orientation_p=$(odom_orientation_p)
orientation_y=$(odom_orientation_y)
echo "Orientation r,p,y $odom_orientation_r, $odom_orientation_p, $odom_orientation_y"
# print imu angular velocity x, y, z
# ...
# print imu linear acceleration x, y, z
# ...
# print a divider line to show iteration is complete
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
done
# End of Code
There is high chance that the /odom topic is not providing the data, which could be the main reason why the robot_statistics program is not working.
If you have the simulation running, then try to run the following command:
ros2 topic list
The above command should enlist /odom as one of the topics.
Then execute the following command on the same terminal:
ros2 topic echo /odom --once --full-length
If you get a bunch of data containing x, y and z positions of the robot along with x, y, z and w quaternion for robot orientation, then the /odom topic is working, and probably the robot_statistics program is not working as intended.
If either the /odom topic is not listed or if there is no data published on /odom topic, then the robot odometry is not working.
Please try the above commands and inform the results.
I forgot to ask you one major question: Was the robot_statistics program not working on the simulation or on the real robot or on both?
I recently tested the provided robot_statistics program on the simulation and it worked quite well, without any issues. Although I did not get a chance to test it on the real robot as of writing this post.
Please let me know in which environment, was the robot_statistics program not working for you.