ROS Troubleshooting

From robotics


"My robot doesn't work! Help!"

Before calling over someone to help, try to debug the problem yourself. Follow the steps below to resolve the most common issues you might encounter, and pay close attention to any error or warning messages.

Did you build and source?

  1. If you're running your own code, run catkin_make in your catkin directory and make sure there are no errors. This is not always necessary when you are just editing python code or launch scripts, but is critical if you are defining messages, services, or using C++.
  2. Run source /opt/ros/indigo/setup.bash to source the main components of ROS.
  3. Run source <catkin_ws>/devel/setup.bash to source your packages.

Important: the source command only affects the terminal it is called in. If calling it solved your problem, make sure to add it to the bottom of your ~/.bashrc file and close/reopen all of your terminals. As a reminder, your ~/.bashrc file is run every time you open a terminal.

If your problems persist, go the the next section.

Does teleop work?

Steps:

  1. On the Turtlebot and your computer, kill all ROS nodes and processes: rosnode kill -a; killall -9 rosmaster; killall -9 roscore
  2. On the Turtlebot, launch bringup: roslaunch turtlebot_bringup minimal.launch
  3. On your computer, launch teleop: roslaunch turtlebot_teleop keyboard_teleop.launch --screen
  4. Try to teleoperate the turtlebot with your keyboard.

Results:

  • I can teleop successfully. Looks like your ROS configuration is fine, and the problem is in your code. Use rostopic echo, and add print or rospy.logdebug() commands to help debug the issue. Another useful command to try is roswtf <your-launch-file>, which can identify issues with how your code connects to ROS.
  • I can teleop, but the commands seem delayed or sluggish. It's possible the network is congested. See the section on ping below.
  • The robot doesn't respond to teleop. Go to the next step.

Does ping work?

A ping command is a call-and-response between two machines. To identify a computer's IP address, run ifconfig and look for something like inet addr: 192.168.0.5. The turtlebot IPs are also printed on their laptops. Below, we'll call the two important IPs 192.168.your.ip and 192.168.bot.ip.

Steps:

  1. On your computer, run ping 192.168.bot.ip
  2. On the Turtlebot, run ping 192.168.your.ip

Results:

  • One or both pings received no response. The two computers cannot see each other. Make sure that both computers are connected to the same WiFi network; you can try disconnecting each computer from wifi and reconnecting it to make sure. They should be connected to the local router, not to WPI-Wireless or eduroam. If you are running in a Virtual Machine, your VM may be causing the issue; the solution depends on which VM software you are running, but you should make sure that the VM's network mode is set to "bridged" or the equivalent. Googling "bridge network <your-VM-software>" will likely give you an answer.
  • Both pings succeeded, but the times were 200ms or more. This can be caused by excess ROS traffic clogging the network. After making sure you're not the one causing it (kill all ROS processes as described above), you can try turning the router off for 15 seconds, then turning it on. Keep in mind that this will kick the other two turtlebots off the router as well, so make sure you're not interrupting someone else's tests before doing this.
  • Both pings succeeded with low ping times. Looks like the network is fine. Go to the next step.

Are ROS variables set properly?

There are two critical environment variables that tell ROS where the different machines are.

Steps:

  1. Run echo $ROS_MASTER_URI on both your computer and the Turtlebot. The output should be http://192.168.bot.ip:11311/ on BOTH machines.
  2. Run echo $ROS_HOSTNAME on both your computer and the Turtlebot. The output should be the IP address of the machine you are running the command on.

Note: ROS_HOSTNAME and ROS_IP serve a similar purpose. Only one needs to be set; if both are set, ROS_HOSTNAME takes precedence.

Results:

  • One of the outputs doesn't match the correct value. Set the values correctly. The syntax for setting environment variables is export ROS_HOSTNAME=192.168.0.1. Make sure to set both variables correctly on both computers. To avoid lots of typing, put the commands at the bottom of your ~/.bashrc file, which is run every time a terminal is opened. Important: environment variables persist only in the terminal they were set in. Whenever you want to change them, either export them in every terminal you are using, or add them to your ~/.bashrc and close/reopen your terminals.
  • Both variables are set correctly on both machines and teleop still fails. Start the nodes needed for teleop, and then run roswtf. Did any of the info it gave help? If not, ask someone for help.