ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Why would librviz (in Python) only sometimes read the config file?

asked 2014-07-02 18:18:17 -0500

Xiuda gravatar image

I am using librviz in a GUI using python (PyQt/PySide) I started with the librviz tutorial ( and was able to use my own config files to show the panels and views that I want. The problem is that it is extremely sporadic.

I have tried:

  • alternating config files
  • downloading the tutorial and testing my config file with the tutorial script
  • using the tutorial config file ( with my script
  • using the tutorial config file with the original tutorial code.
  • restarting the computer
  • Loading the config files into rviz (this works)

When it doesn't work, it looks something like this (tutorial script + tutorial config file): Broken image-

I note that it probably isn't reading the config file properly, because one of the first functions in the tutorial pulls from the file and changes the title, and it does not manage to even do that.

When it is working (my code + my config): Working image: (

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-08 16:43:15 -0500

Xiuda gravatar image

updated 2014-07-11 17:44:28 -0500

There was an issue with it not finding the correct path to the config.rviz file. I realized it when it worked in a terminal window that was in the package directory but not in one where it was not. Adding a launchfile that specifies the location of the file as a parameter fixes this problem.

        import rospkg

and in the init for the class we have

    reader = rviz.YamlConfigReader()
    config = rviz.Config()

# We use rospack to find the filepath for the package using rviz.
    rospack = rospkg.RosPack()
    package_path = rospack.get_path('demo')
#Now you can grab this filepath from either roslaunch and using the launch file or just rosrun with the file in a config folder
    config_file = rospy.get_param('demo/rviz_config', package_path + "/config/myConfig.rviz")
    reader.readFile( config, config_file )
    self.frame.load( config )
edit flag offensive delete link more


Hi, I'm having the same problem except with c++, what exactly is self.frame in your working code? Could you post the line where you assign that value?

DyuAdi gravatar image DyuAdi  ( 2021-07-27 06:20:29 -0500 )edit

Question Tools

1 follower


Asked: 2014-07-02 18:18:17 -0500

Seen: 975 times

Last updated: Jul 11 '14