text: (window.webpackJsonp=window.webpackJsonp||[]).push([[239],{1266:function(t,e,a){t.exports=a.p+"assets/img/gazebo_follow.63ac701a.jpg"},1267:function(t,e,a){t.exports=a.p+"assets/img/sitl_video_stream.f6092293.png"},1268:function(t,e,a){t.exports=a.p+"assets/img/qgc_gazebo_video_stream_udp.47655229.png"},1269:function(t,e,a){t.exports=a.p+"assets/img/qgc_gazebo_video_stream_typhoon.a55b4228.jpg"},1774:function(t,e,a){"use strict";a.r(e);var s=a(18),n=Object(s.a)({},(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"gazebo-simulation"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#gazebo-simulation"}},[t._v("#")]),t._v(" Gazebo Simulation")]),t._v(" "),s("p",[s("a",{attrs:{href:"http://gazebosim.org",target:"_blank",rel:"noopener noreferrer"}},[t._v("Gazebo"),s("OutboundLink")],1),t._v(" is a powerful 3D simulation environment for autonomous robots that is particularly suitable for testing object-avoidance and computer vision.\nThis page describes its use with SITL and a single vehicle.\nGazebo can also be used with "),s("RouterLink",{attrs:{to:"/en/simulation/hitl.html"}},[t._v("HITL")]),t._v(" and for "),s("RouterLink",{attrs:{to:"/en/simulation/multi-vehicle-simulation.html"}},[t._v("multi-vehicle simulation")]),t._v(".")],1),t._v(" "),s("p",[s("strong",[t._v("Supported Vehicles:")]),t._v(" Quad ("),s("RouterLink",{attrs:{to:"/en/airframes/airframe_reference.html#copter_quadrotor_wide_3dr_iris_quadrotor"}},[t._v("Iris")]),t._v(" and "),s("RouterLink",{attrs:{to:"/en/airframes/airframe_reference.html#copter_quadrotor_x_3dr_solo"}},[t._v("Solo")]),t._v(", Hex (Typhoon H480), "),s("RouterLink",{attrs:{to:"/en/airframes/airframe_reference.html#vtol_standard_vtol_generic_quad_delta_vtol"}},[t._v("Generic quad delta VTOL")]),t._v(", Tailsitter, Plane, Rover, Submarine/UUV.")],1),t._v(" "),s("div",{staticClass:"custom-block warning"},[s("p",{staticClass:"custom-block-title"},[t._v("WARNING")]),t._v(" "),s("p",[t._v("Gazebo is often used with "),s("RouterLink",{attrs:{to:"/en/ros/"}},[t._v("ROS")]),t._v(", a toolkit/offboard API for automating vehicle control.\nIf you plan to use PX4 with ROS you "),s("strong",[t._v("should follow the")]),t._v(" "),s("RouterLink",{attrs:{to:"/en/simulation/ros_interface.html"}},[t._v("ROS Instructions")]),t._v(" to install both ROS and Gazebo (and thereby avoid installation conflicts).")],1)]),t._v(" "),s("p",[t._v("{% youtube %}https://www.youtube.com/watch?v=qfFF9-0k4KA&vq=hd720{% endyoutube %}")]),t._v(" "),s("p",[s("a",{attrs:{href:"https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggTFI7XG4gIEdhemViby0tPlBsdWdpbjtcbiAgUGx1Z2luLS0-TUFWTGluaztcbiAgTUFWTGluay0tPlNJVEw7IiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifSwidXBkYXRlRWRpdG9yIjpmYWxzZX0",target:"_blank",rel:"noopener noreferrer"}},[s("img",{attrs:{src:"https://mermaid.ink/img/eyJjb2RlIjoiZ3JhcGggTFI7XG4gIEdhemViby0tPlBsdWdpbjtcbiAgUGx1Z2luLS0-TUFWTGluaztcbiAgTUFWTGluay0tPlNJVEw7IiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifSwidXBkYXRlRWRpdG9yIjpmYWxzZX0",alt:"Mermaid Graph: Gazebo plugin"}}),s("OutboundLink")],1)]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("See "),s("RouterLink",{attrs:{to:"/en/simulation/"}},[t._v("Simulation")]),t._v(" for general information about simulators, the simulation environment, and simulation configuration (e.g. supported vehicles).")],1)]),t._v(" "),s("p",[s("a",{attrs:{id:"installation"}})]),t._v(" "),s("h2",{attrs:{id:"installation"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#installation"}},[t._v("#")]),t._v(" Installation")]),t._v(" "),s("p",[t._v("Gazebo 9 setup is included in our standard build instructions:")]),t._v(" "),s("ul",[s("li",[s("strong",[t._v("macOS:")]),t._v(" "),s("RouterLink",{attrs:{to:"/en/dev_setup/dev_env_mac.html"}},[t._v("Development Environment on Mac")])],1),t._v(" "),s("li",[s("strong",[t._v("Linux:")]),t._v(" "),s("RouterLink",{attrs:{to:"/en/dev_setup/dev_env_linux_ubuntu.html#gazebo-jmavsim-and-nuttx-pixhawk-targets"}},[t._v("Development Environment on Ubuntu LTS / Debian Linux > Gazebo, JMAVSim and NuttX (Pixhawk) Targets")])],1),t._v(" "),s("li",[s("strong",[t._v("Windows:")]),t._v(" Not supported.")])]),t._v(" "),s("p",[t._v("Additional installation instructions can be found on "),s("a",{attrs:{href:"http://gazebosim.org/tutorials?cat=guided_b&tut=guided_b1",target:"_blank",rel:"noopener noreferrer"}},[t._v("gazebosim.org"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("h2",{attrs:{id:"running-the-simulation"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#running-the-simulation"}},[t._v("#")]),t._v(" Running the Simulation")]),t._v(" "),s("p",[t._v("Run a simulation by starting PX4 SITL and gazebo with the airframe configuration to load (multicopters, planes, VTOL, optical flow and multi-vehicle simulations are supported).")]),t._v(" "),s("p",[t._v("The easiest way to do this is to open a terminal in the root directory of the PX4 "),s("em",[t._v("PX4-Autopilot")]),t._v(" repository and call "),s("code",[t._v("make")]),t._v(" for the desired target.\nFor example, to start a quadrotor simulation (the default):")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("cd")]),t._v(" /path/to/PX4-Autopilot\n"),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" px4_sitl gazebo\n")])])]),s("p",[t._v("The supported vehicles and "),s("code",[t._v("make")]),t._v(" commands are listed below (click links to see vehicle images).")]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("For the full list of build targets run "),s("code",[t._v("make px4_sitl list_vmd_make_targets")]),t._v(" (and filter on those that start with "),s("code",[t._v("gazebo_")]),t._v(").")])]),t._v(" "),s("table",[s("thead",[s("tr",[s("th",[t._v("Vehicle")]),t._v(" "),s("th",[t._v("Command")])])]),t._v(" "),s("tbody",[s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#quadrotor"}},[t._v("Quadrotor")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#quadrotor_optical_flow"}},[t._v("Quadrotor with Optical Flow")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_iris_opt_flow")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#3dr_solo"}},[t._v("3DR Solo (Quadrotor)")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_solo")])])]),t._v(" "),s("tr",[s("td",[s("span",{attrs:{id:"typhoon_h480"}}),s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#typhoon_h480"}},[t._v("Typhoon H480 (Hexrotor)")]),t._v(" (supports video streaming)")],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_typhoon_h480")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#standard_plane"}},[t._v("Standard Plane")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_plane")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#standard_plane_catapult"}},[t._v("Standard Plane (with catapult launch)")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_plane_catapult")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#standard_vtol"}},[t._v("Standard VTOL")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_standard_vtol")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#tailsitter_vtol"}},[t._v("Tailsitter VTOL")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_tailsitter")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#ugv"}},[t._v("Ackerman vehicle (UGV/Rover)")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_rover")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#uuv"}},[t._v("HippoCampus TUHH (UUV: Unmanned Underwater Vehicle)")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_uuv_hippocampus")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#usv"}},[t._v("Boat (USV: Unmanned Surface Vehicle)")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_boat")])])]),t._v(" "),s("tr",[s("td",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_vehicles.html#airship"}},[t._v("Cloudship (Airship)")])],1),t._v(" "),s("td",[s("code",[t._v("make px4_sitl gazebo_cloudship")])])])])]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("The "),s("RouterLink",{attrs:{to:"/en/dev_setup/dev_env.html"}},[t._v("Installing Files and Code")]),t._v(" guide is a useful reference if there are build errors.")],1)]),t._v(" "),s("p",[t._v("The commands above launch a single vehicle with the full UI.\nOther options include:")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#start_px4_sim_separately"}},[t._v("Starting PX4 and Gazebo separately")]),t._v(" so that you can keep Gazebo running and only re-launch PX4 when needed (quicker than restarting both).")]),t._v(" "),s("li",[t._v("Run the simulation in "),s("a",{attrs:{href:"#headless"}},[t._v("Headless Mode")]),t._v(", which does not start the Gazebo UI (this uses fewer resources and is much faster).")])]),t._v(" "),s("h2",{attrs:{id:"taking-it-to-the-sky"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#taking-it-to-the-sky"}},[t._v("#")]),t._v(" Taking it to the Sky")]),t._v(" "),s("p",[t._v("The "),s("code",[t._v("make")]),t._v(" commands above first build PX4, and then run it along with the Gazebo simulator.")]),t._v(" "),s("p",[t._v("Once PX4 has started it will launch the PX4 shell as shown below.")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("______  __   __    ___ \n| ___ \\ \\ \\ / /   /   |\n| |_/ /  \\ V /   / /| |\n|  __/   /   \\  / /_| |\n| |     / /^\\ \\ \\___  |\n\\_|     \\/   \\/     |_/\n\npx4 starting.\n\nINFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0\nINFO  [param] selected parameter default file eeprom/parameters_10016\n[param] Loaded: eeprom/parameters_10016\nINFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes\nINFO  [simulator] Waiting for simulator to connect on TCP port 4560\nGazebo multi-robot simulator, version 9.0.0\nCopyright (C) 2012 Open Source Robotics Foundation.\nReleased under the Apache 2 License.\nhttp://gazebosim.org\n...\nINFO  [ecl/EKF] 5188000: commencing GPS fusion\n")])])]),s("p",[t._v("The console will print out status as PX4 loads the airframe-specific initialisation and parameter files, waits for (and connects to) the simulator.\nOnce there is an INFO print that [ecl/EKF] is "),s("code",[t._v("commencing GPS fusion")]),t._v(" the vehicle is ready to arm.")]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("Right-clicking the quadrotor model allows to enable follow mode from the context menu, which is handy to keep it in view.")])]),t._v(" "),s("p",[s("img",{attrs:{src:a(1266),alt:"Gazebo UI"}})]),t._v(" "),s("p",[t._v("You can bring it into the air by typing:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("pxh"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" commander takeoff\n")])])]),s("h2",{attrs:{id:"usage-configuration-options"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#usage-configuration-options"}},[t._v("#")]),t._v(" Usage/Configuration Options")]),t._v(" "),s("p",[s("a",{attrs:{id:"headless"}})]),t._v(" "),s("h3",{attrs:{id:"headless-mode"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#headless-mode"}},[t._v("#")]),t._v(" Headless Mode")]),t._v(" "),s("p",[t._v("Gazebo can be run in a "),s("em",[t._v("headless")]),t._v(' mode in which the Gazebo UI is not launched.\nThis starts up more quickly and uses less system resources (i.e. it is a more "lightweight" way to run the simulation).')]),t._v(" "),s("p",[t._v("Simply prefix the normal "),s("code",[t._v("make")]),t._v(" command with "),s("code",[t._v("HEADLESS=1")]),t._v(" as shown:")]),t._v(" "),s("div",{staticClass:"language-bash extra-class"},[s("pre",{pre:!0,attrs:{class:"language-bash"}},[s("code",[s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("HEADLESS")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" px4_sitl gazebo_plane\n")])])]),s("p",[s("a",{attrs:{id:"custom_takeoff_location"}})]),t._v(" "),s("h3",{attrs:{id:"set-custom-takeoff-location"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#set-custom-takeoff-location"}},[t._v("#")]),t._v(" Set Custom Takeoff Location")]),t._v(" "),s("p",[t._v("The takeoff location in SITL Gazebo can be set using environment variables.\nThis will override both the default takeoff location, and any value "),s("a",{attrs:{href:"#set_world_location"}},[t._v("set for the world")]),t._v(".")]),t._v(" "),s("p",[t._v("The variables to set are: "),s("code",[t._v("PX4_HOME_LAT")]),t._v(", "),s("code",[t._v("PX4_HOME_LON")]),t._v(", and "),s("code",[t._v("PX4_HOME_ALT")]),t._v(".")]),t._v(" "),s("p",[t._v("For example:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("export PX4_HOME_LAT=28.452386\nexport PX4_HOME_LON=-13.867138\nexport PX4_HOME_ALT=28.5\nmake px4_sitl gazebo\n")])])]),s("h3",{attrs:{id:"change-simulation-speed"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#change-simulation-speed"}},[t._v("#")]),t._v(" Change Simulation Speed")]),t._v(" "),s("p",[t._v("The simulation speed can be increased or decreased with respect to realtime using the environment variable "),s("code",[t._v("PX4_SIM_SPEED_FACTOR")]),t._v(".")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("export PX4_SIM_SPEED_FACTOR=2\nmake px4_sitl_default gazebo\n")])])]),s("p",[t._v("For more information see: "),s("RouterLink",{attrs:{to:"/en/simulation/#simulation_speed"}},[t._v("Simulation > Run Simulation Faster than Realtime")]),t._v(".")],1),t._v(" "),s("h3",{attrs:{id:"change-wind-speed"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#change-wind-speed"}},[t._v("#")]),t._v(" Change Wind Speed")]),t._v(" "),s("p",[t._v("To simulate wind speed, add this plugin to your world file and replace "),s("code",[t._v("SET_YOUR_WIND_SPEED")]),t._v(" with the desired speed:")]),t._v(" "),s("div",{staticClass:"language-xml extra-class"},[s("pre",{pre:!0,attrs:{class:"language-xml"}},[s("code",[t._v("  "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("plugin")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token attr-value"}},[s("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")]),t._v("wind_plugin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")])]),t._v(" "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("filename")]),s("span",{pre:!0,attrs:{class:"token attr-value"}},[s("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")]),t._v("libgazebo_wind_plugin.so"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")])]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("frameId")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("base_link"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("frameId")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("robotNamespace")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("/>")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("xyzOffset")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("1 0 0"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("xyzOffset")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windDirectionMean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("0 1 0"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windDirectionMean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windVelocityMean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("SET_YOUR_WIND_SPEED"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windVelocityMean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windGustDirection")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("0 0 0"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windGustDirection")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windGustDuration")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("0"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windGustDuration")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windGustStart")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("0"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windGustStart")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windGustVelocityMean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("0"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windGustVelocityMean")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n      "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("windPubTopic")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("world_wind"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("windPubTopic")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n    "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("plugin")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n")])])]),s("p",[t._v("You can see this how this is done in "),s("a",{attrs:{href:"https://github.com/PX4/PX4-SITL_gazebo/blob/master/worlds/windy.world#L15-L26",target:"_blank",rel:"noopener noreferrer"}},[t._v("PX4/PX4-SITL_gazebo/worlds/windy.world"),s("OutboundLink")],1),t._v(".")]),t._v(" "),s("h3",{attrs:{id:"using-a-joystick"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#using-a-joystick"}},[t._v("#")]),t._v(" Using a Joystick")]),t._v(" "),s("p",[t._v("Joystick and thumb-joystick support are supported through "),s("em",[t._v("QGroundControl")]),t._v(" ("),s("RouterLink",{attrs:{to:"/en/simulation/#joystickgamepad-integration"}},[t._v("setup instructions here")]),t._v(").")],1),t._v(" "),s("h3",{attrs:{id:"improving-distance-sensor-performance"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#improving-distance-sensor-performance"}},[t._v("#")]),t._v(" Improving Distance Sensor Performance")]),t._v(" "),s("p",[t._v("The current default world is "),s("a",{attrs:{href:"https://github.com/PX4/sitl_gazebo/tree/master/worlds",target:"_blank",rel:"noopener noreferrer"}},[t._v("PX4/sitl_gazebo/worlds/"),s("strong",[t._v("iris.world")]),s("OutboundLink")],1),t._v("), which uses a heightmap as ground.")]),t._v(" "),s("p",[t._v("This can cause difficulty when using a distance sensor.\nIf there are unexpected results we recommend you change the model in "),s("strong",[t._v("iris.model")]),t._v(" from "),s("code",[t._v("uneven_ground")]),t._v(" to "),s("code",[t._v("asphalt_plane")]),t._v(".")]),t._v(" "),s("p",[s("a",{attrs:{id:"gps_noise"}})]),t._v(" "),s("h3",{attrs:{id:"simulating-gps-noise"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#simulating-gps-noise"}},[t._v("#")]),t._v(" Simulating GPS Noise")]),t._v(" "),s("p",[t._v("Gazebo can simulate GPS noise that is similar to that typically found in real systems (otherwise reported GPS values will be noise-free/perfect).\nThis is useful when working on applications that might be impacted by GPS noise - e.g. precision positioning.")]),t._v(" "),s("p",[t._v("GPS noise is enabled if the target vehicle's SDF file contains a value for the "),s("code",[t._v("gpsNoise")]),t._v(" element (i.e. it has the line: "),s("code",[t._v("<gpsNoise>true</gpsNoise>")]),t._v(").\nIt is enabled by default in many vehicle SDF files: "),s("strong",[t._v("solo.sdf")]),t._v(", "),s("strong",[t._v("iris.sdf")]),t._v(", "),s("strong",[t._v("standard_vtol.sdf")]),t._v(", "),s("strong",[t._v("delta_wing.sdf")]),t._v(", "),s("strong",[t._v("plane.sdf")]),t._v(", "),s("strong",[t._v("typhoon_h480")]),t._v(", "),s("strong",[t._v("tailsitter.sdf")]),t._v(".")]),t._v(" "),s("p",[t._v("To enable/disable GPS noise:")]),t._v(" "),s("ol",[s("li",[s("p",[t._v("Build any gazebo target in order to generate SDF files (for all vehicles).\nFor example:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("make px4_sitl gazebo_iris\n")])])]),s("div",{staticClass:"custom-block tip"},[s("p",{staticClass:"custom-block-title"},[t._v("TIP")]),t._v(" "),s("p",[t._v("The SDF files are not overwritten on subsequent builds.")])])]),t._v(" "),s("li",[s("p",[t._v("Open the SDF file for your target vehicle (e.g. "),s("strong",[t._v("./Tools/sitl_gazebo/models/iris/iris.sdf")]),t._v(").")])]),t._v(" "),s("li",[s("p",[t._v("Search for the "),s("code",[t._v("gpsNoise")]),t._v(" element:")]),t._v(" "),s("div",{staticClass:"language-xml extra-class"},[s("pre",{pre:!0,attrs:{class:"language-xml"}},[s("code",[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("plugin")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("name")]),s("span",{pre:!0,attrs:{class:"token attr-value"}},[s("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")]),t._v("gps_plugin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")])]),t._v(" "),s("span",{pre:!0,attrs:{class:"token attr-name"}},[t._v("filename")]),s("span",{pre:!0,attrs:{class:"token attr-value"}},[s("span",{pre:!0,attrs:{class:"token punctuation attr-equals"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")]),t._v("libgazebo_gps_plugin.so"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("'")])]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n  "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("robotNamespace")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("/>")])]),t._v("\n  "),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("<")]),t._v("gpsNoise")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("true"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("gpsNoise")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token tag"}},[s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("</")]),t._v("plugin")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(">")])]),t._v("\n")])])]),s("ul",[s("li",[t._v("If it is present, GPS is enabled.\nYou can disable it by deleting the line: "),s("code",[t._v("<gpsNoise>true</gpsNoise>")])]),t._v(" "),s("li",[t._v("If it is not preset GPS is disabled.\nYou can enable it by adding the "),s("code",[t._v("gpsNoise")]),t._v(" element to the "),s("code",[t._v("gps_plugin")]),t._v(" section (as shown above).")])])])]),t._v(" "),s("p",[t._v("The next time you build/restart Gazebo it will use the new GPS noise setting.")]),t._v(" "),s("p",[s("a",{attrs:{id:"set_world"}})]),t._v(" "),s("h2",{attrs:{id:"loading-a-specific-world"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#loading-a-specific-world"}},[t._v("#")]),t._v(" Loading a Specific World")]),t._v(" "),s("p",[t._v("PX4 supports a number of "),s("RouterLink",{attrs:{to:"/en/simulation/gazebo_worlds.html"}},[t._v("Gazebo Worlds")]),t._v(", which are stored in "),s("a",{attrs:{href:"https://github.com/PX4/sitl_gazebo/tree/master/worlds",target:"_blank",rel:"noopener noreferrer"}},[t._v("PX4/sitl_gazebo/worlds"),s("OutboundLink")],1),t._v(")\nBy default Gazebo displays a flat featureless plane, as defined in "),s("a",{attrs:{href:"https://github.com/PX4/sitl_gazebo/blob/master/worlds/empty.world",target:"_blank",rel:"noopener noreferrer"}},[t._v("empty.world"),s("OutboundLink")],1),t._v(".")],1),t._v(" "),s("p",[t._v("You can load any of the worlds by specifying them as the final option in the PX4 configuration target.")]),t._v(" "),s("p",[t._v("For example, to load the "),s("em",[t._v("warehouse")]),t._v(" world, you can append it as shown:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("make px4_sitl_default gazebo_plane_cam__warehouse\n")])])]),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("There are "),s("em",[t._v("two underscores")]),t._v(" after the model ("),s("code",[t._v("plane_cam")]),t._v(") indicating that the default debugger is used (none).\nSee "),s("RouterLink",{attrs:{to:"/en/dev_setup/building_px4.html#px4-make-build-targets"}},[t._v("Building the Code > PX4 Make Build Targets")]),t._v(".")],1)]),t._v(" "),s("p",[t._v("You can also specify the full path to a world to load using the "),s("code",[t._v("PX4_SITL_WORLD")]),t._v(" environment variable.\nThis is useful if testing a new world that is not yet included with PX4.")]),t._v(" "),s("div",{staticClass:"custom-block tip"},[s("p",{staticClass:"custom-block-title"},[t._v("TIP")]),t._v(" "),s("p",[t._v("If the loaded world does not align with the map, you may need to "),s("a",{attrs:{href:"#set_world_location"}},[t._v("set the world location")]),t._v(".")])]),t._v(" "),s("p",[s("a",{attrs:{id:"set_world_location"}})]),t._v(" "),s("h2",{attrs:{id:"set-world-location"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#set-world-location"}},[t._v("#")]),t._v(" Set World Location")]),t._v(" "),s("p",[t._v("The vehicle gets spawned very close to the origin of the world model at some simulated GPS location.")]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("The vehicle is not spawned exactly at the Gazebo origin (0,0,0), but using a slight offset, which can highlight a number of common coding issues.")])]),t._v(" "),s("p",[t._v('If using a world that recreates a real location (e.g. a particular airport) this can result in a very obvious mismatch between what is displayed in the simulated world, and what is shown on the ground station map.\nTo overcome this problem you can set the location of the world origin to the GPS co-ordinates where it would be in "real life".')]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("You can also set a "),s("a",{attrs:{href:"#custom_takeoff_location"}},[t._v("Custom Takeoff Location")]),t._v(" that does the same thing.\nHowever adding the location to the map is easier (and can still be over-ridden by setting a custom location if needed).")])]),t._v(" "),s("p",[t._v("The location of the world is defined in the "),s("strong",[t._v(".world")]),t._v(" file by specifying the location of the origin using the "),s("code",[t._v("spherical_coordinates")]),t._v(" tag.\nThe latitude, longitude, elevation must all be specified (for this to be a valid).")]),t._v(" "),s("p",[t._v("An example can be found in the "),s("a",{attrs:{href:"https://github.com/PX4/sitl_gazebo/blob/master/worlds/sonoma_raceway.world",target:"_blank",rel:"noopener noreferrer"}},[t._v("sonoma_raceway.world"),s("OutboundLink")],1),t._v(":")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("    <spherical_coordinates>\n      <surface_model>EARTH_WGS84</surface_model>\n      <latitude_deg>38.161479</latitude_deg>\n      <longitude_deg>-122.454630</longitude_deg>\n      <elevation>488.0</elevation>\n    </spherical_coordinates>\n")])])]),s("p",[t._v("You can test this by spawning a rover in the "),s("RouterLink",{attrs:{to:"/en/simulation/gazebo_worlds.html#sonoma-raceway"}},[t._v("Sonoma Raceway World")]),t._v(" using the following "),s("code",[t._v("make")]),t._v(" command (note that spawning takes longer the first time as the model needs to be downloaded from the model database):")],1),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("make px4_sitl gazebo_rover__sonoma_raceway\n")])])]),s("p",[t._v("The video below shows that the location of the environment is aligned with the gazebo world:\n{% youtube %}\nhttps://youtu.be/-a2WWLni5do\n{% endyoutube %}")]),t._v(" "),s("p",[s("a",{attrs:{id:"start_px4_sim_separately"}})]),t._v(" "),s("h2",{attrs:{id:"starting-gazebo-and-px4-separately"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#starting-gazebo-and-px4-separately"}},[t._v("#")]),t._v(" Starting Gazebo and PX4 Separately")]),t._v(" "),s("p",[t._v("For extended development sessions it might be more convenient to start Gazebo and PX4 separately or even from within an IDE.")]),t._v(" "),s("p",[t._v("In addition to the existing cmake targets that run "),s("code",[t._v("sitl_run.sh")]),t._v(" with parameters for px4 to load the correct model it creates a launcher targets named "),s("code",[t._v("px4_<mode>")]),t._v(" that is a thin wrapper around original sitl px4 app.\nThis thin wrapper simply embeds app arguments like current working directories and the path to the model file.")]),t._v(" "),s("p",[t._v("To start Gazebo and PX4 separately:")]),t._v(" "),s("ul",[s("li",[t._v("Run gazebo (or any other sim) server and client viewers via the terminal specifing an "),s("code",[t._v("_ide")]),t._v(" variant:"),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" px4_sitl gazebo___ide\n")])])]),t._v("or"),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[s("span",{pre:!0,attrs:{class:"token function"}},[t._v("make")]),t._v(" px4_sitl gazebo_iris_ide\n")])])])]),t._v(" "),s("li",[t._v("In your IDE select "),s("code",[t._v("px4_<mode>")]),t._v(" target you want to debug (e.g. "),s("code",[t._v("px4_iris")]),t._v(")")]),t._v(" "),s("li",[t._v("Start the debug session directly from IDE")])]),t._v(" "),s("p",[t._v("This approach significantly reduces the debug cycle time because simulator (e.g. Gazebo) is always running in background and you only re-run the px4 process which is very light.")]),t._v(" "),s("h2",{attrs:{id:"simulated-survey-camera"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#simulated-survey-camera"}},[t._v("#")]),t._v(" Simulated Survey Camera")]),t._v(" "),s("p",[t._v("The "),s("em",[t._v("Gazebo")]),t._v(" survey camera simulates a "),s("a",{attrs:{href:"https://mavlink.io/en/services/camera.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAVLink camera"),s("OutboundLink")],1),t._v(" that captures geotagged JPEG images and sends camera capture information to a connected ground station.\nThe camera also supports video streaming.\nIt can be used to test camera capture, in particular within survey missions.")]),t._v(" "),s("p",[t._v("The camera emits the "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#CAMERA_IMAGE_CAPTURED",target:"_blank",rel:"noopener noreferrer"}},[t._v("CAMERA_IMAGE_CAPTURED"),s("OutboundLink")],1),t._v(" message every time an image is captured.\nThe captured images are saved to: "),s("strong",[t._v("PX4-Autopilot/build/px4_sitle_default/tmp/frames/DSC_n_.jpg")]),t._v(" (where "),s("em",[t._v("n")]),t._v(" starts as 00000 and is iterated by one on each capture).")]),t._v(" "),s("p",[t._v("To simulate a plane with this camera:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("make px4_sitl_default gazebo_plane_cam\n")])])]),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("The camera also supports/responds to the following MAVLink commands: "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_CAMERA_CAPTURE_STATUS",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_REQUEST_CAMERA_CAPTURE_STATUS"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_STORAGE_INFORMATION",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_REQUEST_STORAGE_INFORMATION"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_CAMERA_SETTINGS",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_REQUEST_CAMERA_SETTINGS"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_CAMERA_INFORMATION",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_REQUEST_CAMERA_INFORMATION"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_RESET_CAMERA_SETTINGS",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_RESET_CAMERA_SETTINGS"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_STORAGE_FORMAT",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_STORAGE_FORMAT"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_SET_CAMERA_ZOOM",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_SET_CAMERA_ZOOM"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_IMAGE_START_CAPTURE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_IMAGE_START_CAPTURE"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_IMAGE_STOP_CAPTURE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_IMAGE_STOP_CAPTURE"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_VIDEO_STREAM_INFORMATION",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_REQUEST_VIDEO_STREAM_INFORMATION"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_REQUEST_VIDEO_STREAM_STATUS",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_REQUEST_VIDEO_STREAM_STATUS"),s("OutboundLink")],1),t._v(", "),s("a",{attrs:{href:"https://mavlink.io/en/messages/common.html#MAV_CMD_SET_CAMERA_MODE",target:"_blank",rel:"noopener noreferrer"}},[t._v("MAV_CMD_SET_CAMERA_MODE"),s("OutboundLink")],1),t._v(".")])]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("The simulated camera is implemented in "),s("a",{attrs:{href:"https://github.com/PX4/sitl_gazebo/blob/master/src/gazebo_geotagged_images_plugin.cpp",target:"_blank",rel:"noopener noreferrer"}},[t._v("PX4/sitl_gazebo/src/gazebo_geotagged_images_plugin.cpp"),s("OutboundLink")],1),t._v(".")])]),t._v(" "),s("p",[s("a",{attrs:{id:"flight_termination"}})]),t._v(" "),s("h2",{attrs:{id:"simulated-parachute-flight-termination"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#simulated-parachute-flight-termination"}},[t._v("#")]),t._v(" Simulated Parachute/Flight Termination")]),t._v(" "),s("p",[s("em",[t._v("Gazebo")]),t._v(" can be used to simulate deploying a "),s("RouterLink",{attrs:{to:"/en/peripherals/parachute.html"}},[t._v("parachute")]),t._v(" during "),s("RouterLink",{attrs:{to:"/en/advanced_config/flight_termination.html"}},[t._v("Flight Termination")]),t._v(" (flight termination is triggered by the PWM command that is simulated in "),s("em",[t._v("Gazebo")]),t._v(").")],1),t._v(" "),s("p",[t._v("The "),s("code",[t._v("if750a")]),t._v(" target has a parachute attached to the vehicle.\nTo simulate the vehicle, run the following command:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("make px4_sitl gazebo_if750a\n")])])]),s("p",[t._v("To put the vehicle into flight termination state, you can force it to fail a "),s("RouterLink",{attrs:{to:"/en/config/safety.html"}},[t._v("safety check")]),t._v(" that has flight termination set as the failsafe action.\nFor example, you could do this by forcing a "),s("RouterLink",{attrs:{to:"/en/config/safety.html#geofence-failsafe"}},[t._v("Geofence violation")]),t._v(".")],1),t._v(" "),s("p",[t._v("For more information see:")]),t._v(" "),s("ul",[s("li",[s("RouterLink",{attrs:{to:"/en/advanced_config/flight_termination.html"}},[t._v("Flight Termination")])],1),t._v(" "),s("li",[s("RouterLink",{attrs:{to:"/en/peripherals/parachute.html"}},[t._v("Parachute")])],1),t._v(" "),s("li",[s("RouterLink",{attrs:{to:"/en/config/safety.html"}},[t._v("Safety Configuration (Failsafes)")])],1)]),t._v(" "),s("p",[s("a",{attrs:{id:"video"}})]),t._v(" "),s("h2",{attrs:{id:"video-streaming"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#video-streaming"}},[t._v("#")]),t._v(" Video Streaming")]),t._v(" "),s("p",[t._v("PX4 SITL for Gazebo supports UDP video streaming from a Gazebo camera sensor attached to a vehicle model.\nWhen streaming is enabled, you can connect to this stream from "),s("em",[t._v("QGroundControl")]),t._v(" (on UDP port 5600) and view video of the Gazebo environment from the simulated vehicle - just as you would from a real camera.\nThe video is streamed using a "),s("em",[t._v("gstreamer")]),t._v(" pipeline and can be enabled/disabled using a button in the Gazebo UI.")]),t._v(" "),s("p",[t._v("The Gazebo camera sensor is supported/enabled on the following frames:")]),t._v(" "),s("ul",[s("li",[s("a",{attrs:{href:"#typhoon_h480"}},[t._v("Typhoon H480")])])]),t._v(" "),s("h3",{attrs:{id:"prerequisites"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#prerequisites"}},[t._v("#")]),t._v(" Prerequisites")]),t._v(" "),s("p",[s("em",[t._v("Gstreamer 1.0")]),t._v(" is required for video streaming.\nThe required dependencies should already have been "),s("a",{attrs:{href:"#installation"}},[t._v("installed when you set up Gazebo")]),t._v(" (they are included in the standard PX4 installation scripts/instructions for macOS and Ubuntu Linux).")]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("FYI only, the dependencies include: "),s("code",[t._v("gstreamer1.0-plugins-base")]),t._v(", g"),s("code",[t._v("streamer1.0-plugins-good")]),t._v(", "),s("code",[t._v("gstreamer1.0-plugins-bad")]),t._v(", "),s("code",[t._v("gstreamer1.0-plugins-ugly")]),t._v(", "),s("code",[t._v("libgstreamer-plugins-base1.0-dev")]),t._v(".")])]),t._v(" "),s("h3",{attrs:{id:"start-stop-video-streaming"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#start-stop-video-streaming"}},[t._v("#")]),t._v(" Start/Stop Video Streaming")]),t._v(" "),s("p",[t._v("Video streaming is automatically started when supported by the target vehicle.\nFor example, to start streaming video on the Typhoon H480:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("make px4_sitl gazebo_typhoon_h480\n")])])]),s("p",[t._v("Streaming can be paused/restarted using the Gazebo UI "),s("em",[t._v("Video ON/OFF")]),t._v(" button..")]),t._v(" "),s("p",[s("img",{attrs:{src:a(1267),alt:"Video ON/OFF button"}})]),t._v(" "),s("h3",{attrs:{id:"how-to-view-gazebo-video"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#how-to-view-gazebo-video"}},[t._v("#")]),t._v(" How to View Gazebo Video")]),t._v(" "),s("p",[t._v("The easiest way to view the SITL/Gazebo camera video stream is in "),s("em",[t._v("QGroundControl")]),t._v(".\nSimply open "),s("strong",[t._v("Application Settings > General")]),t._v(" and set "),s("strong",[t._v("Video Source")]),t._v(" to "),s("em",[t._v("UDP h.264 Video Stream")]),t._v(" and "),s("strong",[t._v("UDP Port")]),t._v(" to "),s("em",[t._v("5600")]),t._v(":")]),t._v(" "),s("p",[s("img",{attrs:{src:a(1268),alt:"QGC Video Streaming Settings for Gazebo"}})]),t._v(" "),s("p",[t._v("The video from Gazebo should then display in "),s("em",[t._v("QGroundControl")]),t._v(" just as it would from a real camera.")]),t._v(" "),s("p",[s("img",{attrs:{src:a(1269),alt:"QGC Video Streaming Gazebo Example"}})]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("The Typhoon world is not very interesting.")])]),t._v(" "),s("p",[t._v("It is also possible to view the video using the "),s("em",[t._v("Gstreamer Pipeline")]),t._v(".\nSimply enter the following terminal command:")]),t._v(" "),s("div",{staticClass:"language-sh extra-class"},[s("pre",{pre:!0,attrs:{class:"language-sh"}},[s("code",[t._v("gst-launch-1.0  -v udpsrc "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("port")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("5600")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("caps")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[t._v("'application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264'")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v(" rtph264depay "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v(" avdec_h264 "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v(" videoconvert "),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v(" autovideosink fps-update-interval"),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),s("span",{pre:!0,attrs:{class:"token number"}},[t._v("1000")]),t._v(" "),s("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("sync")]),s("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("false\n")])])]),s("h3",{attrs:{id:"verbose-logging"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#verbose-logging"}},[t._v("#")]),t._v(" Verbose Logging")]),t._v(" "),s("p",[t._v("SITL fails silently when there is something wrong with the gazebo model.\nYou can enable more verbose logging using "),s("code",[t._v("VERBOSE_SIM")]),t._v(", as shown:")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("export VERBOSE_SIM=1\nmake px4_sitl gazebo\n")])])]),s("p",[t._v("or")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("VERBOSE_SIM=1 make px4_sitl gazebo\n")])])]),s("h2",{attrs:{id:"extending-and-customizing"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#extending-and-customizing"}},[t._v("#")]),t._v(" Extending and Customizing")]),t._v(" "),s("p",[t._v("To extend or customize the simulation interface, edit the files in the "),s("code",[t._v("Tools/sitl_gazebo")]),t._v(" folder.\nThe code is available on the "),s("a",{attrs:{href:"https://github.com/px4/sitl_gazebo",target:"_blank",rel:"noopener noreferrer"}},[t._v("sitl_gazebo repository"),s("OutboundLink")],1),t._v(" on Github.")]),t._v(" "),s("div",{staticClass:"custom-block note"},[s("p",{staticClass:"custom-block-title"},[t._v("Note")]),t._v(" "),s("p",[t._v("The build system enforces the correct GIT submodules, including the simulator.\nIt will not overwrite changes in files in the directory.")])]),t._v(" "),s("h2",{attrs:{id:"further-information"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#further-information"}},[t._v("#")]),t._v(" Further Information")]),t._v(" "),s("ul",[s("li",[s("RouterLink",{attrs:{to:"/en/simulation/ros_interface.html"}},[t._v("ROS with Gazebo Simulation")])],1),t._v(" "),s("li",[s("RouterLink",{attrs:{to:"/en/simulation/gazebo_octomap.html"}},[t._v("Gazebo Octomap")])],1)])])}),[],!1,null,null,null);e.default=n.exports}}]);