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

    This example shows how to generate dependencies for user-defined gazebo custom message.

    Create a folder in the local directory.

    folderPath = fullfile(pwd,'customMessage')
    folderPath = 
    '/tmp/Bdoc20b_1465442_44205/tpead699b1/robotics-ex62907275/customMessage'
    
    mkdir(folderPath)

    Create one or more '.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);

    Run the gazebogenmsg function and specify the folder path.

    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/Bdoc20b_1465442_44205/tpead699b1/robotics-ex62907275/customMessage/install')
    savepath
    

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

    %addpath(fullfile(folderPath,'install'))
    %savepath

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

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

    This example shows how to generate dependencies for built-in Gazebo message.

    Create a folder in the local directory.

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

    Run the gazebogenmsg function and specify the folder path and select one or more built-in gazebo message from the list.

    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/Bdoc20b_1465442_44205/tpead699b1/robotics-ex40128733/customMessage/install')
    savepath
    

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

    % addpath(fullfile(folderPath,'install'))
    % savepath

    Create 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.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Introduced in R2020b