MATLAB Answers

Perform Co-Simulation between Simulink and Gazebo

11 views (last 30 days)
yeongjian Toh
yeongjian Toh on 30 Sep 2020
Answered: Mohith Kulkarni on 8 Oct 2020
Hello
I am trying to understand how to simulate mobile robot on matlab by performing co-simulation between simulink and gazebo. I refer to this link https://www.mathworks.com/help/robotics/ug/perform-co-simulation-between-simulink-and-gazebo.html
In this website, it teaches us to include this line <plugin name="GazeboPlugin" filename="lib/libGazeboCoSimPlugin.so"><portNumber>14581</portNumber></plugin>
and export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:/home/user/src/GazeboPlugin/export
Now the problem comes, i do not know where to write these lines at, i tried to write it in the terminal window but nothing happens. Then when i read on further and it says to type in this line open_system("performCoSimulationWithGazebo")
again, i do not know where to type the code at, is it at the matlab script window or is it at the gazebo virtual machine (which i am using to do the co simulation). I tried typing in matlab script window but the file was not found.
There is no technical issues so far, but the problem for me right now is i do not know where to input these command lines and as such i am not even able to perform these examples. I hope you can clarify my doubts with regards to these issues.
Thank you.

  0 Comments

Sign in to comment.

Answers (1)

Mohith Kulkarni
Mohith Kulkarni on 8 Oct 2020
The multiSensorPluginTest.world is located in /home/user/src/GazeboPlugin/world folder. This world file includes the Gazebo plugin for co-simulation with Simulink using the following lines in its .xml body:
<plugin name="GazeboPlugin" filename="lib/libGazeboCoSimPlugin.so"><portNumber>14581</portNumber></plugin>
You can find this line in the .xml body of the world file.
And the export command is a MATLAB command, The filename field must be pointing to the location of the compiled Gazebo plugin. This path can be relative to the location Gazebo itself is launched, or you could add it to the Gazebo plugin search path by running:
export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:/home/user/src/GazeboPlugin/export
open_system is again a MATLAB function to open a model, library, subsystem, or block dialog box. Make sure the model is in the MATLAB path.
open_system("performCoSimulationWithGazebo")

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!