Gazebo Apply Command
Send command to Gazebo simulator
Libraries:
Robotics System Toolbox /
Gazebo Co-Simulation
Description
The Apply Command block sends commands to a Gazebo simulation. The block accepts a command message, input as a bus signal, and sends the command to the Gazebo server.
To send command messages, connect to a Gazebo simulation. Open the block mask and click Configure Gazebo network and simulation settings. For more information see Configure Gazebo Simulation.
This block is part of a co-simulation interface between MATLAB® and Gazebo for exchanging data and sending commands. To see a basic example, check Perform Co-Simulation Between Simulink and Gazebo.
Examples
Perform Co-Simulation Between Simulink and Gazebo
Set up a synchronized simulation between Simulink®and Gazebo to send commands and receive data from Gazebo.
Control Differential Drive Robot in Gazebo with Simulink
Control the Pioneer differential drive robot in Gazebo co-simulation using Simulink.
Limitations
Models that use this block do not support Code Generation or Rapid Accelerator mode.
Ports
Input
Cmd — Gazebo Command
bus
Gazebo command message, specified as a bus. The command is an instruction for a specified model link or joint. Specify the model name as part of the bus signal using the Gazebo Select Entity block.
There are seven different command types with specific fields:
ApplyLinkWrench
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator. You can specify this field using the Gazebo Select Entity block.link_name
–– Variable-sizeuint8
array representing the name of the link in the model in the Gazebo simulator. You can specify this field using the Gazebo Select Entity block.force_type
–– Variable-sizeuint8
array specified as'SET'
or'ADD'
.'SET'
overwrites any existing force command for the specified duration.'ADD'
adds the value with existing commands.Fx, fy, fz
––double
values specifying the amount of force applied to the Gazebo model link in world coordinates and Newtons.torque_type
–– Variable-sizeuint8
array specified as'SET'
or'ADD'
.'SET'
overwrites any existing torque command for the specified duration.'ADD'
adds the value with existing commands.Tx, ty, tz
––double
values specifying the amount of torque applied to the Gazebo model link in world coordinates and Newton-meters.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
ApplyJointTorque
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator. You can specify this field using the Gazebo Select Entity block.joint_name
–– Variable-sizeuint8
array representing the name of the joint in the model in the Gazebo simulator. You can specify this field using the Gazebo Select Entity block.index
––uint32
integer that identifies which joint axis the torque should be applied to.effort
––double
scalar value specifying the amount of torque or force to apply to the joint.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
SetLinkWorldPose
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator.link_name
–– Variable-sizeuint8
array representing the name of the link in the model in the Gazebo simulator.world_pose
–– Bus containing position and orientation as[x y z]
and[x y z w]
double
vectors, respectively.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
SetLinkLinearVelocity
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator.link_name
–– Variable-sizeuint8
array representing the name of the link in the model in the Gazebo simulator.velocity
–– Bus containing linear velocity as[x y z]
double
vector.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
SetLinkAngularVelocity
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator.link_name
–– Variable-sizeuint8
array representing the name of the link in the model in the Gazebo simulator.velocity
–– Bus containing angular velocity as[x y z]
double
vector.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
SetJointPosition
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator.joint_name
–– Variable-sizeuint8
array representing the name of the joint in the model in the Gazebo simulator.index
––uint32
integer that identifies which joint axis the torque should be applied to.position
––double
scalar value representing the joint position.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
SetJointVelocity
:model_name
–– Variable-sizeuint8
array representing the name of the model in the Gazebo simulator.joint_name
–– Variable-sizeuint8
array representing the name of the joint in the model in the Gazebo simulator.index
––uint32
integer that identifies which joint axis the torque should be applied to.velocity
––double
scalar value representing the joint velocity.duration
–– Bus containing seconds and nanoseconds asdouble
integers, which specify how long to apply the torque in simulation time.
Note
SetJointVelocity
uses the Set Instantaneous Velocity method to set the joint velocity. For more information see, Setting Velocity on Links And Joints.
Note
If a
duration
is1.005
seconds, it would be1
second and5000000
nanoseconds as a bus.
Data Types: bus
Parameters
Command type — Type of command
ApplyLinkWrench
(default) | ApplyJointTorque
| SetLinkWorldPose
| SetLinkLinearVelocity
| SetLinkAngularVelocity
| SetJointPosition
| SetJointVelocity
Click Select to get a list of command types available in
Gazebo. The input Cmd
must contain the correct command message
structure that matches this type.
Sample time — Sampling time of input
0.001
(default) | positive
Sample time indicates the interval which commands are sent to the Gazebo simulator.
More About
Configure Gazebo Simulation
Click Configure Gazebo network and simulation settings
in the block mask to launch the Configure Gazebo
Simulation dialog box, which configures the
synchronized stepping between Gazebo and Simulink. You can select the Network Address
and specify Hostname/IP Address
and
Port
of the computer running the Gazebo
simulator with the Gazebo plugin installed. Then click
Test to test the connection to the
running Gazebo simulator. You can also specify the Response
timeout
in seconds. These settings apply to all
Gazebo blocks for all open Simulink models.
Starting from R2022b, you can connect to multiple Gazebo simulations from one or more machines. You can now specify a cell array of IP addresses and a cell array of port numbers in the MATLAB workspace and then specify their variable names to the Hostname/IP Address
and Port
boxes, respectively.
To connect to a single Gazebo session from MATLAB, specify the port number and IP address of the computer running the Gazebo simulator.
portnum = 14580;
ipaddress = '172.18.250.125';
To connect to multiple Gazebo sessions from MATLAB, specify the port numbers and IP addresses of the computers running the Gazebo simulator.
portnum = {14580,14581}; ipaddress = {'172.18.250.125','172.18.250.125'};
Version History
Introduced in R2019b
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)