Co-simulation between MatLab and Gazebo
I want to control a robotic manipulator using co-simulation between Simulink and Gazebo. I created a Gazebo plugin package by running the packageGazeboPlugin command in Matlab and then compiled it in the user/home directory. I copied libGazeboCoSimPlugin.so file in the manipulator package (catkin_ws/devel/lib) then created a plugin file and included this file to the model .xacro file (i followed steps presented here -->http://kashishdhal.me/ros-tutorials/how-to-synchronize-gazebo-with-ros/).
but when I use the Gazebo pacer block to test if Gazebo has synchronized or not, I receive "failed to connect to Gazebo plugin". Do you have any idea what is the problem?
Asked by maria on 2021-08-18 02:04:27 UTC
Answers
Gazebo Co-Simulation plugin needs also another files to work properly. After compilation, several files and folders are created in export
folder. They are need to be existing and GAZEBO_PLUGIN_PATH
needs to be on/set to matlab_plugin/export/lib
. Since you provided only the .so
file, plugin was not able to find other files (for sommunication handlers, servers, ...). Note that also folder include
must exist, even though it is not in export
folder. This plugin is unfortunately a bit tricky with this...
Asked by m.bahno on 2021-08-31 02:32:47 UTC
Comments
Thank you for your answer. should I compile the Gazebo plugin package inside of my manipulator package? then, when I lunch the package the plugin package should be active?
and where should I add export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}: /home/user/src/GazeboPlugin/export
?.
Asked by maria on 2021-10-05 05:57:46 UTC
I compiled plugin in my ROS package, but it can be anywhere, as long as the path is in GAZEBO_PLUGIN_PATH
.
The plugin shall be added to model SDF file as any other plugin. And if you have the corresponding plugin .so file on the GAZEBO_PLUGIN_PATH
path, it should work fine. Of course, the plugin needs to be compiled.
You can export the value in the same terminal you run the roslaunch
(before running it) or you can use env
tag directly in .launch file.
Asked by m.bahno on 2021-10-15 02:39:25 UTC
Just a note to adding path: If you add only .../export/
to path, then you need to add plugin .so file as lib/libGazeboCoSimPlugin.so
. Alternatively, you can add to path .../export/lib
and then just libGazeboCoSimPlugin.so
, which is cleaner in my opinion. But in Matlab example files, it is for some reason the other way...
Asked by m.bahno on 2021-10-15 02:47:44 UTC
Comments