Linux for Robotics - robot_statistics is not working

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

Hi @furkanyildiz2557 ,

Welcome to this Community!

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.

Regards,
Girish

Thank you Girish for your comment!

Here are the results,

user:~/ros2_ws/src/linux_basics_project/linux_basics_project$ ros2 topic list
/clicked_point
/clock
/cmd_vel
/goal_pose
/imu
/initialpose
/joint_states
/odom
/parameter_events
/performance_metrics
/robot_description
/rosout
/scan
/tf
/tf_static

Also the second command,

user:~/ros2_ws/src/linux_basics_project/linux_basics_project$ ros2 topic echo /odom --once --full-length
header:
  stamp:
    sec: 378
    nanosec: 591000000
  frame_id: odom
child_frame_id: base_footprint
pose:
  pose:
    position:
      x: 0.8495579728723683
      y: 0.5080588787600072
      z: 0.008504622038884455
    orientation:
      x: 0.001277350481095016
      y: 0.001146300647024526
      z: -0.7513411555651985
      w: 0.6599117534371755
  covariance:
  - 1.0e-05
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1.0e-05
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1000000000000.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1000000000000.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1000000000000.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.001
twist:
  twist:
    linear:
      x: 0.00039511859924740904
      y: 2.9074025718229548e-06
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: -5.7317491025122296e-05
  covariance:
  - 1.0e-05
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1.0e-05
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1000000000000.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1000000000000.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 1000000000000.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.001
---

From this, I assume that my robot_statistics is not working as i intended. How can I resolve this ?

Kindly,
Furkan

Hi @furkanyildiz2557 ,

Thanks for your reply.

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.

Regards,
Girish

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.