Gazebo | Ignition | Community
Ask Your Question
0

How to set GAZEBO_PLUGIN_PATH correctly and add the plugin into Gazebo_ros ?

asked 2016-05-25 15:16:31 -0500

wyxf007 gravatar image

updated 2016-05-30 03:23:23 -0500

Hi, I am using gazebo to simulate a sonar. Thus I will use hector_sonar_plugin. While after I install the hector plugins from source and call it in my sdf, errors come.

At first, an error appear asking me to add libhector_sonar_plugin.so to gazebo_ros package.

I cannot understand it and thought it cannot find the plugin. Thus,I use

export GAZEBO_PLUGIN_PATH=`pwd`:$GAZEBO_PLUGIN_PATH

to add hector_plugin folder into path, then more error come:

Error [Plugin.hh:156] Failed to load plugin libRayPlugin.so: libRayPlugin.so: cannot open shared object file: No such file or directory
[FATAL] [1464103865.820981859]: A ROS node for Gazebo has not been initialized, unable to load plugin. Load the Gazebo system plugin 'libgazebo_ros_api_plugin.so' in the gazebo_ros package)

Could someone tell me how to set the GAZEBO_PLUGIN_PATH correctly (or reset it correctly)? And if I want to use plug-Ins such as hector's, what should I do? (just copy .so to the model folder or ...?)

I am using Indigo full desktop, and thus version should be gazebo2

Thank you.

edit retag flag offensive close merge delete

Comments

Can you show line of SDF file, where you include plugin ? Frequent problem is a relative path to the plugin.

Aiven92 gravatar imageAiven92 ( 2016-05-27 17:55:27 -0500 )edit

Can you check out the current GAZEBO_PLUGIN_PATH? Run $echo $GAZEBO_PLUGIN_PATH to see whether the path is right.

Weiwei gravatar imageWeiwei ( 2016-05-28 01:23:11 -0500 )edit

I just use <plugin name="gazebo_ros_sonar_data" filename="libhector_gazebo_ros_sonar.so"> <gaussiannoise>0.005</gaussiannoise> <topicname>radiofence</topicname> <frameid>radiofence1</frameid> </plugin> </sensor> to call the plugin in my sensor sdf file.

wyxf007 gravatar imagewyxf007 ( 2016-05-28 08:24:49 -0500 )edit

After echo GAZEBO_PLUGIN_PATH in Terminal, I just get the result GAZEBO_PLUGIN_PATH

wyxf007 gravatar imagewyxf007 ( 2016-05-28 08:26:19 -0500 )edit

I have zero string result of echo $GAZEBO_PLUGIN_PATH, but I'm use ABSOLUTE path to the plugin *.so file and all work fine.

Aiven92 gravatar imageAiven92 ( 2016-05-28 11:58:08 -0500 )edit

Could you tell me how to use the ABSOLUTE path? do changes in URDF file ?

wyxf007 gravatar imagewyxf007 ( 2016-05-30 03:09:58 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2016-05-31 08:23:20 -0500

m4k gravatar image

updated 2016-06-29 04:57:24 -0500

as already mentioned previously you can see your current GAZEBO_PLUGIN_PATH by the command echo $GAZEBO_PLUGIN_PATH. The path should point directly to the folder where the .so file is located (for example the build folder).

the export GAZEBO_PLUGIN_PATH=´pwd´:$GAZEBO_PLUGIN_PATH doesn't overwrite the path it just append the current directory(pwd) to the variable. (you can also use $PWD which is handier) Resulting you have a mess after several tries. In addition, export is just temporary and depends on the current terminal. (don't confuse yourself with too many tabs / terminals)

To clean the variable use unset GAZEBO_PLUGIN_PATH , then check again the variable: echo $GAZEBO_PLUGIN_PATH (no nothing should be returned)

Now you have to navigate in terminal to the folder where the .so file is located (since pwd is the current folder). After using export GAZEBO_PLUGIN_PATH=$PWD your variable should be set correctly. (overwrites existing values)

If you want to append your path to the variable use export GAZEBO_PLUGIN_PATH=$PWD:$GAZEBO_PLUGIN_PATH.

(Hint: you can also set the path directly for example: export GAZEBO_PLUGIN_PATH=/home/#USERNAME#/Documents/testplugin/build)

To have the GAZEBO_PLUGIN_PATH permanent you can include the "export xx=xx" line into your ~/.bashrc file

Edit/Remark:

The default gazebo plugins are loading since gazebo is sourcing its default environment variables before the start. This is carried out using the file /usr/share/gazebo/setup.sh or /usr/share/gazebo-X.X/setup.sh(the X.X is your respective gazebo version)

To be aware of this behavior and be able to see its default values, you can use source /usr/share/gazebo/setup.sh

Again, to have this permanent in every console instance, add the line to your .bashrc file.

edit flag offensive delete link more

Comments

1

Thank you! I was quite confused why echo GAZEBO_PLUGIN_PATH just return a same name a same name, even if the gazebo default plugin setting still works. But at least I can use your method now.

wyxf007 gravatar imagewyxf007 ( 2016-06-02 13:34:29 -0500 )edit
Login/Signup to Answer

Question Tools

5 followers

Stats

Asked: 2016-05-25 15:16:31 -0500

Seen: 21,371 times

Last updated: Jun 29 '16