Main Content

packageGazeboPlugin

Create Gazebo plugin package for Simulink

    Description

    example

    packageGazeboPlugin creates a Gazebo plugin package as a zip archive. The function creates a folder containing plugin source code, named GazeboPlugin, in the current working directory and compresses it as GazeboPlugin.zip. Gazebo uses this plugin package to communicate with Simulink® for synchronized stepping, as well as sending and receiving messages.

    packageGazeboPlugin(packagePath) creates a Gazebo plugin at the specified location packagePath. packagePath must be a valid file name or a file path with the desired package folder name. The function creates the plugin folder with the specified name in the location specified in the packagePath argument and compresses it.

    example

    packageGazeboPlugin(packagePath,customMessagePath) creates a Gazebo plugin with custom message support using the specified custom message dependencies in customMessagePath. The dependencies must be specified as a valid path to a folder that contains the custom message dependencies.

    outputPath = packageGazeboPlugin(___) returns the path of the plugin folder in addition to any combination of input arguments from a previous syntax.

    Examples

    collapse all

    Create a folder in a local directory.

    folderPath = fullfile(pwd,'customMessage')
    folderPath = 
    '/tmp/Bdoc21b_1802166_71270/tpef5b4b68/robotics-ex62907275/customMessage'
    
    mkdir(folderPath)

    Create a .proto file inside the folder and define protobuf custom message fields.

    messageDefinition = {'message MyPose'
                         '{'
                         '   required double x = 1;'
                         '   required double y = 2;'
                         '   required double z = 3;'
                         '}'};
    fileID = fopen(fullfile(folderPath,'MyPose.proto'),'w');
    fprintf(fileID,'%s\n',messageDefinition{:});
    fclose(fileID);

    Use the gazebogenmsg function to generate dependences in the created folder.

    gazebogenmsg(folderPath)
    Validating ...
    Selected compiler details: "g++ 8.3.0"
    [libprotobuf WARNING] No syntax specified for the proto file: MyPose.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
    Building shared library ...
    Building MEX for "MyPose.proto" file ...
    Building with 'g++'.
    MEX completed successfully.
    Building with 'g++'.
    MEX completed successfully.
    Building custom message utilities  ...
    DONE.
     
    To use the gazebo custom messages, execute following commands:
     
    addpath('/tmp/Bdoc21b_1802166_71270/tpef5b4b68/robotics-ex62907275/customMessage/install')
    savepath
    

    Use the following commands to add and save the install path.

    addpath(fullfile(folderPath,'install'))

    savepath

    Create a Gazebo plugin package 'MyPlugin' inside the custom message folder using the packageGazeboPlugin function.

    packageGazeboPlugin(fullfile(folderPath,'MyPlugin'),folderPath)

    Create a folder in a local directory.

    folderPath = fullfile(pwd,'customMessage');
    mkdir(folderPath)
    cd(folderPath)

    Use the gazebogenmsg function to generate dependencies for a built-in gazebo message in the specified folder.

    gazebogenmsg(folderPath,"GazeboMessageList","gazebo.msgs.Image");
    Validating ...
    Selected compiler details: "g++ 8.3.0"
    Building shared library ...
    Building MEX for "image.proto" file ...
    Building with 'g++'.
    MEX completed successfully.
    Building with 'g++'.
    MEX completed successfully.
    Building custom message utilities  ...
    DONE.
     
    To use the gazebo custom messages, execute following commands:
     
    addpath('/tmp/Bdoc21b_1802166_71270/tpef5b4b68/robotics-ex40128733/customMessage/install')
    savepath
    

    Use the following commands to add and save the install path.

    addpath(fullfile(folderPath,'install'))

    savepath

    Create a Gazebo plugin package using the packageGazeboPlugin function.

    packageGazeboPlugin

    Input Arguments

    collapse all

    Name or path of the Gazebo plugin package folder, specified as a string scalar or a character vector.

    When specified as a folder name, the function creates a plugin folder and a compressed plugin file with the specified name in the current directory.

    Example: packageGazeboPlugin('MyPlugin')

    When specified as a file path, the function creates a plugin folder and a compressed plugin file with the specified file name in the specified folder.

    Example: packageGazeboPlugin('C:\GazeboPlugin\MyPlugin')

    Data Types: char | string

    Path of the Gazebo custom message folder, specified as a string scalar or a character vector.

    To create a Gazebo plugin with custom message support, specify the customMessagePath as a valid path to the folder that contains the desired custom message dependencies.

    When the packagePath argument is specified as a folder name, the function creates a plugin folder and a compressed plugin file with the specified package name in the current directory.

    Example: packageGazeboPlugin('MyPlugin','C:\GazeboCustomMsg')

    When the packagePath argument is specified as a file path inside the custom message folder, the function creates a plugin folder and a compressed plugin file with the specified file name in the specified folder.

    Example: packageGazeboPlugin('C:\GazeboCustomMsg\MyPlugin','C:\GazeboCustomMsg')

    Data Types: char | string

    Output Arguments

    collapse all

    Path of the plugin folder, returned as a character vector.

    Limitations

    • packageGazeboPlugin function not supported with MATLAB® Compiler™.

    Introduced in R2020b