Ask Your Question
1

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

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

Xiuda gravatar image

I am using librviz in a GUI using python (PyQt/PySide) I started with the librviz tutorial (docs.ros.org/hydro/api/rviz_python_tutorial/html/) 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 (raw.githubusercontent.com/ros-visualization/visualization_tutorials/hydro-devel/rviz_python_tutorial/config.myviz) 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.imgur.com/j1rlQsf.png)

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: (i.imgur.com/nN7vKkF.png)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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

Xiuda gravatar image

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

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

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

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

Seen: 523 times

Last updated: Jul 11 '14