ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

I'm getting the rosgraph not found error

asked 2017-05-17 19:10:42 -0500

diegovargas34 gravatar image

updated 2017-05-19 00:37:23 -0500

gvdhoorn gravatar image

Hello, I'm trying to control a robot that has ROS controllers with a Python program, but everytime I run the program, I get an error regarding the rosgraph library not being found. I've tried everything other people have said in other threads, but nothing has worked so far. This is the program I'm using to try and control the robot:

#! /usr/bin/env python
import rospy, math
import numpy as np
import sys, termios, tty, select, os
from geometry_msgs.msg import Twist

class KeyTeleop(object):
    cmd_bindings = {'q': np.array([1, 1]),
                    'w': np.array([1, 0]),
                    'e': np.array([1, -1]),
                    'a': np.array([0, 1]),
                    'd': np.array([0, -1]),
                    'z': np.array([-1, -1]),
                    'x': np.array([-1, 0]),
                    'c': np.array([-1, 1])
    set_bindings = {'t': np.array([1, 1]),
                    'b': np.array([-1, -1]),
                    'y': np.array([1, 0]),
                    'n': np.array([-1, 0]),
                    'u': np.array([0, 1]),
                    'm': np.array([0, -1])

    def init(self):
        # Save terminal settings
        self.settings = termios.tcgetattr(sys.stdin)
        # Initial values
        self.inc_ratio = 0.1
        self.speed = np.array([0.5, 1.0])
        self.command = np.array([0, 0])
        self.update_rate = 10  # Hz
        self.alive = True
        # Setup publisher
        self.pub_twist = rospy.Publisher('/cmd_vel', Twist)

    def fini(self):
        # Restore terminal settings
        termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.settings)

    def run(self):
            r = rospy.Rate(self.update_rate)  # Hz
            while not rospy.is_shutdown():
                ch = self.get_key()
        except rospy.exceptions.ROSInterruptException:

    def print_usage(self):
        msg = """
    Keyboard Teleop that Publish to /cmd_vel (geometry_msgs/Twist)
    Copyright (C) 2013
    Released under BSD License
    H:       Print this menu
    Moving around:
      Q   W   E
      A   S   D
      Z   X   Z
    T/B :   increase/decrease max speeds 10%
    Y/N :   increase/decrease only linear speed 10%
    U/M :   increase/decrease only angular speed 10%
    anything else : stop

    G :   Quit

    # Used to print items to screen, while terminal is in funky mode
    def loginfo(self, str):
        termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.settings)

    # Used to print teleop status
    def show_status(self):
        msg = 'Status:\tlinear %.2f\tangular %.2f' % (self.speed[0], self.speed[1])

    # For everything that can't be a binding, use if/elif instead
    def process_key(self, ch):
        if ch == 'h':
        elif ch in self.cmd_bindings.keys():
            self.command = self.cmd_bindings[ch]
        elif ch in self.set_bindings.keys():
            self.speed = self.speed * (1 + self.set_bindings[ch] * self.inc_ratio)
        elif ch == 'g':
            # Stop the robot
            twist = Twist()
            self.command = np.array([0, 0])

    def update(self):
        if rospy.is_shutdown():
        twist = Twist()
        cmd = self.speed * self.command
        twist.linear.x = cmd[0]
        twist.angular.z = cmd[1]

    # Get input from the terminal
    def get_key(self):
        tty.setraw(sys.stdin.fileno())[sys.stdin], [], [], 0)
        key ...
edit retag flag offensive close merge delete


Please include the full text of the error message in your question, and links to the other questions that you've tried (and any debug information those questions may have recommended)

ahendrix gravatar image ahendrix  ( 2017-05-17 20:58:08 -0500 )edit

It _seems_ like this is just a case of your ROS_PACKAGE_PATH being set incorrectly, but if you listed the steps that you've already tried it would be easier to give useful advice.

ahendrix gravatar image ahendrix  ( 2017-05-17 20:59:31 -0500 )edit

Hello @ahendrix We've edited the post with the information you asked. Thank you so much.

diegovargas34 gravatar image diegovargas34  ( 2017-05-18 20:09:43 -0500 )edit

Does rospack find rosgraph result in anthing?

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-05-18 21:00:16 -0500 )edit

It results in an error with a file called librospack. It says it can't open the libraries because the file or directory doesn't exists.

diegovargas34 gravatar image diegovargas34  ( 2017-05-18 21:08:14 -0500 )edit

Interesting. Normally, if a package doesn't exist it simply says "not found'. Like @ahendrix suggested it's probably something to do with the path. Can you type printenv | grep ROS and edit the question with the result.

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-05-18 21:12:53 -0500 )edit

Could you also tell us what sort of system this is, Linux distro & version you are running, version of ROS and how you installed that.

gvdhoorn gravatar image gvdhoorn  ( 2017-05-19 00:37:03 -0500 )edit

I'm so sorry guys for answering so late. This is the exact error when we execute rospack find rosgraph:

rospack: error while loading shared libraries: cannot open shared object file: No such file or directory

diegovargas34 gravatar image diegovargas34  ( 2017-05-22 18:32:23 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-19 12:00:45 -0500

ahendrix gravatar image

Your error message does not include a listing of the entries in the ROS_PACKAGE_PATH (normally these would be ROS path [0], ROS path [1], etc). Presumably this means that your ROS_PACKAGE_PATH is not set at all.

It looks like you need to source the setup.bash or for your workspace, which will set up your ROS_PACKAGE_PATH and the other environment variables that ROS needs.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-05-17 19:10:42 -0500

Seen: 1,018 times

Last updated: May 19 '17