gzworld
Syntax
Description
gzworld("reset") resets all Gazebo model configurations and Gazebo
simulation time.
Examples
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")Limitations
gzworldfunction 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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)