gzjoint
Syntax
Description
[
assigns values to the joint parameters using one or more name-value pair arguments for the
specified Gazebo model Status
,Message
] = gzjoint("set",modelname
,jointname
,Name,Value
)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
.
[
retrieves values of the joint parameters using one or more parameter names,
Output1,...,OutputN
] = gzjoint("get",modelname
,jointname
,params
)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
Perform Co-Simulation Between MATLAB and Gazebo
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
modelname
— Gazebo model name
string scalar | character vector
Gazebo model name, specified as a string scalar or character vector.
Data Types: char
| string
jointname
— Associated joint name
string scalar | character vector
Associated joint name, specified as a string scalar or character vector.
Data Types: char
| string
params
— Gazebo model joint parameters
string scalars | character vectors
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 Name | Description |
---|---|
"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:
Parameters | Description |
---|---|
"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
.
Axis
— Gazebo model joint axis parameters
"0"
| "1"
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 Name | Description |
---|---|
"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
CFM
— Gazebo model joint constraint force mixing (CFM) parameter
numeric scalar
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
FudgeFactor
— Gazebo model joint fudge factor parameter
numeric scalar
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
Orientation
— Gazebo model joint orientation parameter
four-element vector
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
Position
— Gazebo model joint position
three-element vector
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
SuspensionCFM
— Gazebo model joint suspension CFM parameter
numeric scalar
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
SuspensionERP
— Gazebo model joint suspension error reduction parameter (ERP) parameter
numeric scalar
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
List
— List of joints in model
cell array of character vectors
List of joints in the model, returned as a cell array of character vectors.
Status
— Status of values assigned to parameters
logical array
Status of the values assigned to the parameters, returned as a logical array.
Message
— Success or failure message
string array
Success or failure message, returned as a string array.
Output1,...,OutputN
— Values of specified parameters
numeric scalar | numeric vector
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 Name | Description |
---|---|
"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:
Parameters | Description |
---|---|
"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 |
"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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)