Main Content

gzjoint

Assign and retrieve Gazebo model joint information

Since R2021a

    Description

    List = gzjoint("list",modelname) returns and displays a list of joint names List of the specified Gazebo model modelname.

    example

    [Status,Message] = gzjoint("set",modelname,jointname,Name,Value) assigns values to the joint parameters using one or more name-value pair arguments for the specified Gazebo model modelname and the joint jointname. The function returns the status of the value assignments Status and the message of their success and failure Message. For example, gzjoint("set","unit_box","joint","Position",[2 2 0.5]) sets the position of the joint in the model unit_box.

    [Output1,...,OutputN] = gzjoint("get",modelname,jointname,params) retrieves values of the joint parameters using one or more parameter names, params, for the specified Gazebo model modelname and the joint jointname. The function returns one or more outputs, Output1,...,OutputN, corresponding to the specified parameter names.

    Examples

    collapse all

    Set up a simulation between MATLAB and Gazebo, receive data from Gazebo, and send commands to Gazebo.

    Prerequisite

    Follow the instructions in Perform Co-Simulation Between Simulink and Gazebo to download the Linux virtual machine (VM) with Gazebo and set up multiSensorPluginTest.world.

    Configure and Perform Gazebo Co-Simulation

    Initialize connection settings and check connectivity with the Gazebo plugin running on 192.168.198.129 and port 14581.

    gzinit("192.168.198.129",14581)

    Assign and Retrieve Gazebo Model Information

    List the models available in the Gazebo world.

    modelList = gzmodel("list")
    modelList = 1×11 string
        "ground_plane"    "unit_box"    "camera0"    "camera1"    "depth_camera0"    "depth_camera1"    "imu0"    "imu1"    "hokuyo0"    "hokuyo1"    "velodyne"
    
    

    Assign values to the Position and SelfCollide parameters of the unit_box model.

    [status,message] = gzmodel("set","unit_box","Position",[2 2 0.5],"SelfCollide","on")
    status = 1×2 logical array
    
       1   1
    
    
    message = 1×2 string
        "Position parameter set successfully."    "SelfCollide parameter set successfully."
    
    

    Retrieve the values of the Position and SelfCollide parameters of the unit_box model.

    [position,selfcollide] = gzmodel("get","unit_box","Position","SelfCollide")
    position = 1×3
    
                             2                         2           0.4999999999951
    
    
    selfcollide = logical
       1
    
    

    Assign and Retrieve Gazebo Model Link Information

    List the links available in the unit_box model.

    linkList = gzlink("list","unit_box")
    linkList = 
    "link"
    

    Assign values to the link parameters Mass and Gravity of the link link in the unit_box model.

    [status,message] = gzlink("set","unit_box","link","Mass",2,"Gravity","off")
    status = 1×2 logical array
    
       1   1
    
    
    message = 1×2 string
        "Mass parameter set successfully."    "Gravity parameter set successfully."
    
    

    Retrieve the values of the link parameters Mass and Gravity of the link link in the unit_box model.

    [mass,gravity] = gzlink("get","unit_box","link","Mass","Gravity")
    mass = 
         2
    
    
    gravity = logical
       0
    
    

    Assign and Retrieve Gazebo Model Joint Information

    List the joints available in the unit_box model.

    jointList = gzjoint("list","unit_box")
    jointList = 
    "joint"
    

    Assign a value to the joint parameter Damping of the axis Axis0 for the joint joint in the unit_box model.

    [status,message] = gzjoint("set","unit_box","joint","Axis","0","Damping",0.25)
    status = logical
       1
    
    
    message = 
    "Damping parameter set successfully."
    

    Retrieve the value of the joint parameter Damping of the axis Axis0 for the joint joint in the unit_box model.

    damping = gzjoint("get","unit_box","joint","Axis0","Damping")
    damping = 
                          0.25
    
    

    Reset all Gazebo model configurations.

    gzworld("reset")

    Input Arguments

    collapse all

    Gazebo model name, specified as a string scalar or character vector.

    Data Types: char | string

    Associated joint name, specified as a string scalar or character vector.

    Data Types: char | string

    Gazebo model joint parameters, specified as a comma-separated list of string scalars or character vectors. Specify the list of parameters you want to retrieve the values, from these tables.

    Gazebo model joint axis parameters for Axis0 or Axis1, specified as the comma-separated arguments consisting of "Axis0" or "Axis1", respectively, and one or more of the options in this table.

    Option NameDescription
    "Angle"Get the angle parameter of the Gazebo model joint axis for Axis0 or Axis1.
    "Damping"Get the damping parameter of the Gazebo model joint axis for Axis0 or Axis1.
    "Friction"Get the friction parameter of the Gazebo model joint axis for Axis0 or Axis1.
    "XYZ"Get the position of the Gazebo model joint axis for Axis0 or Axis1.

    Gazebo model joint parameters:

    ParametersDescription
    "CFM"

    Get the CFM parameter of the Gazebo model joint.

    "FudgeFactor"

    Get the fudge factor parameter of the Gazebo model joint.

    "Orientation"

    Get the orientation parameter of the Gazebo model joint.

    "Position"

    Get the position of the Gazebo model joint.

    "SuspensionCFM"

    Get the suspension CFM parameter of the Gazebo model joint.

    "SuspensionERP"

    Get the suspension ERP parameter of the Gazebo model joint.

    Example: [ang,damp,cfm,pos] = gzjoint("get","unit_box","joint","Axis0","Angle","Damping","CFM","Position")

    Data Types: char | string

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: For example, gzjoint("set","unit_box","joint","Position",[2 2 0.5]) sets the position of the joint in the model unit_box.

    Gazebo model joint axis parameters, specified as the comma-separated pair consisting of 'Axis' and either "0" or "1". Then, specify one or more of the options in this table as the comma-separated pair consisting of an option name and its value.

    Option NameDescription
    "Angle"Set the angle parameter of the Gazebo model joint axis as a numeric scalar in radians.
    "Damping"Set the damping parameter of the Gazebo model joint axis as a numeric scalar in newton meter second per radians.
    "Friction"Set the friction parameter of the Gazebo model joint axis as a numeric scalar in newton.
    "XYZ"Set the position of the Gazebo model joint axis as a three-element vector of the form [X Y Z] in meters.

    Example: [status,message] = gzjoint("set","unit_box","joint","Axis","0","Damping",0.25)

    Data Types: single | double

    Gazebo model joint CFM parameter, specified as the comma-separated pair consisting of 'CFM' and a numeric scalar.

    Example: [status,message] = gzjoint("set","unit_box","joint","CFM",1);

    Data Types: single | double

    Gazebo model joint fudge factor parameter, specified as the comma-separated pair consisting of 'FudgeFactor' and a numeric scalar.

    Example: [status,message] = gzjoint("set","unit_box","joint","FudgeFactor",1);

    Data Types: single | double

    Gazebo model joint orientation parameter, specified as the comma-separated pair consisting of 'Orientation' and a four-element quaternion vector of the form [w x y z].

    Example: [status,message] = gzjoint("set","unit_box","joint","Orientation",[1 0 0 0]);

    Data Types: single | double

    Gazebo model joint position parameter, specified as the comma-separated pair consisting of 'Position' and a three-element vector of the form [x y z] in meters.

    Example: [status,message] = gzjoint("set","unit_box","joint","Position",[0 0 0]);

    Data Types: single | double

    Gazebo model joint suspension CFM parameter, specified as the comma-separated pair consisting of 'SuspensionCFM' and a numeric scalar.

    Example: [status,message] = gzjoint("set","unit_box","joint","SuspensionCFM",1);

    Data Types: single | double

    Gazebo model joint suspension ERP parameter, specified as the comma-separated pair consisting of 'SuspensionERP' and a numeric scalar.

    Example: [status,message] = gzjoint("set","unit_box","joint","SuspensionERP",1);

    Data Types: single | double

    Output Arguments

    collapse all

    List of joints in the model, returned as a cell array of character vectors.

    Status of the values assigned to the parameters, returned as a logical array.

    Success or failure message, returned as a string array.

    Values of specified parameters, returned as a numeric scalar or numeric vector based on the specified parameters. The following tables shows the returned data type of parameter values.

    Gazebo model joint axis parameters for Axis0 or Axis1:

    Option NameDescription
    "Angle"Gazebo model joint axis angle parameter for Axis0 or Axis1, returns a numeric scalar in radians.
    "Damping"Gazebo model joint axis damping parameter for Axis0 or Axis1, returns a numeric scalar in newton meter second per radians.
    "Friction"Gazebo model joint axis friction parameter for Axis0 or Axis1, returns a numeric scalar in newton.
    "XYZ"Gazebo model joint axis position parameter for Axis0 or Axis1, returns a three-element vector of the form [X Y Z] in meters.

    Gazebo model joint parameters:

    ParametersDescription
    "CFM"

    Gazebo model joint CFM parameter, returns a numeric scalar.

    "FudgeFactor"

    Gazebo model joint fudge factor parameter, returns a numeric scalar.

    "Orientation"

    Gazebo model joint orientation parameter, returns a four-element quaternion vector of the form [w x y z].

    "Position"

    Gazebo model joint position parameter, returns a three-element vector of the form [x y z] in meters.

    "SuspensionCFM"

    Gazebo model joint suspension CFM parameter, returns a numeric scalar.

    "SuspensionERP"

    Gazebo model joint suspension ERP parameter, returns a numeric scalar.

    Limitations

    • gzjoint function not supported with MATLAB® Compiler™.

    Version History

    Introduced in R2021a