Gazebo | Ignition | Community
Ask Your Question
0

Setting GAZEBO_PLUGIN_PATH crashes Gazebo

asked 2013-04-30 18:52:41 -0500

Ben B gravatar image

updated 2013-04-30 18:53:19 -0500

Hi all,

So I have a model of a WAM Arm. I wrote a plugin that moves its joints through a list of joint positions.

When I:

  • don't have the GAZEBO_PLUGIN_PATH set
  • cd into the directory of the model
  • then run Gazebo

I can insert the model from the "insert" menu. It then executes the joint movements.

If I try running Gazebo from outside that directory, I can still insert the model, but it won't go through the movements.

Then, if I try setting the GAZEBO_PLUGIN_PATH to the model directory, inserting the model results in an errorless crash.

Any thoughts?

edit retag flag offensive close merge delete

Comments

You may also need to set the LD_LIBRARY_PATH to include the model directory as well. Can you try that?

scpeters gravatar imagescpeters ( 2013-05-01 12:20:21 -0500 )edit

I still have both problems: The plugin isn't found when I launch Gazebo from outside of the model/plugin directory. Also, Gazebo still crashed when I set the GAZEBO_PLUGIN_PATH

Ben B gravatar imageBen B ( 2013-05-01 13:59:02 -0500 )edit

Can you get a backtrace of the crash using gdb? gdb gzserver in one terminal, gzclient in another, and then insert the model. If it crashes, then bt in the gdb terminal.

scpeters gravatar imagescpeters ( 2013-05-01 23:45:20 -0500 )edit

Thanks for the help, scpeters. In the end, the problem was my fault. See below.

Ben B gravatar imageBen B ( 2013-05-02 20:00:14 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-05-02 19:53:49 -0500

Ben B gravatar image

updated 2013-05-03 11:45:43 -0500

In case this happens to anyone else:

The plugin was designed to read in a list of joint coordinates from a file. The file was placed in the same directory as the SDF file.

So: When I ran Gazebo from the directory containing the model & plugin, it found the plugin and found the joint file. No problem.

When I ran Gazebo from outside of the directory without the GAZEBO_PLUGIN_PATH set, it wouldn't find the plugin, and it handled that gracefully by inserting the model, not running the plugin and giving me a "plugin not found" message.

When I ran Gazebo from outside of the directory with the GAZEBO_PLUGIN_PATH set, it found the plugin, but the plugin couldn't find the joint file and segfaulted. This brought Gazebo down with it.

Solution: In the plugin code: Use an absolute file path instead of a file path that was relative to the plugin. Or, in the plugin code, handle missing joint files more gracefully.

edit flag offensive delete link more

Comments

Can you clarify which environment variables you set? I don't think GAZEBO\_MODEL\_PLUGIN is right.

scpeters gravatar imagescpeters ( 2013-05-03 11:36:46 -0500 )edit

Also, if you want to store additional files in your model directory, you can find them using [gazebo::common::SystemPaths::FindFileURI()](http://gazebosim.org/api/dev/classgazebo_1_1common_1_1SystemPaths.html) with the uri "model://model_name/path/to/file"

scpeters gravatar imagescpeters ( 2013-05-03 11:42:50 -0500 )edit

Also, if you want to store additional files in your model directory, you can find them using gazebo::common::SystemPaths::FindFileURI() with the uri "model://model_name/path/to/file"

scpeters gravatar imagescpeters ( 2013-05-03 11:43:06 -0500 )edit

Right you are :) I meant GAZEBO_PLUGIN_PATH. Thanks for the tip on FindFileURI!

Ben B gravatar imageBen B ( 2013-05-03 16:08:28 -0500 )edit

Actually, I'm a bit confused how to use this. SystemPaths is a class, right? So I try to instantiate an object inside the load function of my plugin : `common::SystemPaths sys_path_obj;` and then I get the error: `/usr/include/gazebo-1.7/gazebo/common/SystemPaths.hh:60:16: error: ‘gazebo::common::SystemPaths::SystemPaths()’ is private`. Is that telling me the constructor is private?

Ben B gravatar imageBen B ( 2013-05-03 17:01:05 -0500 )edit

You don't need to instantiate that class; you should be able to just call the gazebo::common::SystemPaths::FindFileURI(), as long as you have the header included.

scpeters gravatar imagescpeters ( 2013-05-03 17:17:00 -0500 )edit

Doing this: ` std::string pathy = gazebo::common::SystemPaths::FindFileURI("model://WAM Model/forGazebo");` gives `/home/benjaminblumer/.../set_joints.cc: In member function ‘virtual void gazebo::SetJoints::Load(gazebo::physics::ModelPtr, sdf::ElementPtr)’: /home/benjaminblumer/.../plugins/set_joints.cc:49:99: error: cannot call member function ‘std::string gazebo::common::SystemPaths::FindFileURI(const string&)’ without object`

Ben B gravatar imageBen B ( 2013-05-03 17:22:23 -0500 )edit

And I'm including the common/common.hh header.

Ben B gravatar imageBen B ( 2013-05-03 17:25:39 -0500 )edit
1

My apologies, based on ModelDatabase.cc:396, you should use gazebo::common::SystemPaths::Instance()->FindFileURI().

scpeters gravatar imagescpeters ( 2013-05-03 17:56:00 -0500 )edit

Ah. That works great. Thanks, SC.

Ben B gravatar imageBen B ( 2013-05-03 18:11:19 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-30 18:52:41 -0500

Seen: 441 times

Last updated: May 03 '13