{"id":650,"date":"2023-07-18T14:41:06","date_gmt":"2023-07-18T18:41:06","guid":{"rendered":"https:\/\/blogs.mathworks.com\/autonomous-systems\/?p=650"},"modified":"2023-07-19T22:46:09","modified_gmt":"2023-07-20T02:46:09","slug":"accelerate-aerial-autonomy-with-simulink-and-microsoft-project-airsim","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/autonomous-systems\/2023\/07\/18\/accelerate-aerial-autonomy-with-simulink-and-microsoft-project-airsim\/","title":{"rendered":"Accelerate Aerial Autonomy with Simulink and Microsoft Project AirSim"},"content":{"rendered":"<p>In this blog post, we&#8217;re going to take a deep dive into a co-simulation workflow using Microsoft\u2019s Project AirSim and MathWorks\u2019 Simulink\u00ae. You will learn how to integrate custom vehicle dynamics models from Simulink with photorealistic 3D simulation from Project AirSim. Let&#8217;s get started!<\/p>\n<p>With the rise of Advanced Air Mobility (AAM) applications, UAV use cases are expanding from last-mile delivery and inspections to logistics and flying taxis. Prior to an autonomous flight operation, Unmanned Aerial Vehicles (UAVs) go through rigorous simulation-based testing to ensure safety and efficient performance.<\/p>\n<p>To test and evaluate these applications, high-fidelity dynamics models of UAVs are simulated in photorealistic 3D scenarios. UAVs involve several sensors and simulating them helps with generating synthetic data to train AI models and test autonomy algorithms.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"624\" height=\"371\" class=\"alignnone size-full wp-image-653\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/07\/Picture1.png\" alt=\"\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><strong>The Integrated Workflow for Developing Autonomous Aerial Systems<\/strong><\/h3>\n<p>Before we dive into the co-simulation example, let&#8217;s quickly go over the workflow for developing unmanned aerial systems. There are many components that come into play, including:<\/p>\n<ul>\n<li>Modeling the vehicle<\/li>\n<li>Developing control and autonomy algorithms<\/li>\n<li>Analyzing data<\/li>\n<li>Virtual testing with sensor models<\/li>\n<li>Connecting or deploying to hardware<\/li>\n<\/ul>\n<p>Simulink interfaces with Project AirSim to combine capabilities for UAV development in use cases such as infrastructure inspection, delivery, air taxis, inspection and recon scenarios, multi-agent drones, as well as search and rescue.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"624\" height=\"416\" class=\"alignnone size-full wp-image-656\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/07\/Picture2.png\" alt=\"\" \/><\/p>\n<h3><strong>Project AirSim and Simulink Co-Simulation<\/strong><\/h3>\n<h4><strong>What is Project AirSim? <\/strong><\/h4>\n<p><a href=\"https:\/\/news.microsoft.com\/source\/features\/innovation\/microsoft-launches-project-airsim-an-end-to-end-platform-to-accelerate-autonomous-flight\/\">Microsoft Project AirSim<\/a> is an AI-first platform for safely creating, training, and validating autonomous agents which enables users to build autonomy solutions for UAVs in a dynamic 3D world.<\/p>\n<h4><strong>Why should you integrate Simulink and Project AirSim? <\/strong><\/h4>\n<p>An end-to-end simulation workflow requires a photorealistic 3D environment with real-world scenes and physics-based aircraft models. Further, it needs to send controller commands to the virtual aircraft and perform autonomy operations by simulating the aircraft sensors.<\/p>\n<p>The Model-Based Design approach with Simulink enables engineers to efficiently develop high-fidelity physics models and control systems. It lets flight dynamics engineers build custom aircraft designs such as VTOL. See <a href=\"https:\/\/blogs.mathworks.com\/autonomous-systems\/2023\/06\/06\/prevent-uav-crashes-with-integrated-simulation-workflows-insights-from-auvsi-xponential-2023\/\">this blog<\/a> to learn more about MathWorks\u2019 solutions for UAVs.<\/p>\n<p>Project AirSim provides 3D world rendering and sensor simulation with capabilities to import Bing Maps GIS data for real-world scenarios. It lets simulation engineers bring the flight dynamics to an easy-to-use simulation platform that can be scaled on the Azure cloud.<\/p>\n<h4><strong>How can you connect these two platforms? <\/strong><\/h4>\n<p>The initial integration is a Simulink <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/sfg\/what-is-an-s-function.html\">S-function<\/a> interface that passes physics data between Project AirSim and Simulink at every time step. This interface allows you to use a customizable Simulink dynamics model instead of the built-in simple FastPhysics model.<\/p>\n<p>The data is passed over a request-response TCP connection, which could be local or remote, on either Windows or Linux. The data that&#8217;s passed includes rotor forces and torque, wing control surface angles, environment, and collision information.<\/p>\n<p>The Simulink model can use this to calculate a new kinematic state for the vehicle&#8217;s pose, velocities, and accelerations, and pass that back to AirSim at each step.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"936\" height=\"273\" class=\"alignnone size-full wp-image-659\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/07\/Picture3.png\" alt=\"\" \/><\/p>\n<h3><strong>Advanced Air Mobility Demo with a VTOL Aircraft<\/strong><\/h3>\n<p>In this example, a VTOL aircraft carries out a mission in a real-world environment, showing how Simulink uses the Project AirSim S-function block to pass data signals in and out, while the visual flight instrument displays track vehicle motion. A Python client script for Project AirSim connects to the sim server and configures the scenario and vehicle to bring everything up. Once the PX4 flight controller starts running, the QGroundControl mission planner connects to it and locates the vehicle on the map based on the simulated GPS sensor data.<\/p>\n<p>From there, the vehicle starts flying the mission by taking off, climbing in multirotor mode, and then starts transitioning into fixed-wing flight mode. The aircraft soars over the Texas Motor Speedway, stays on its mapped trajectory and lands safely on the pad for a successful mission completion.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"1178\" height=\"664\" class=\"alignnone size-full wp-image-677\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/07\/Landing-GIF.gif\" alt=\"\" \/><\/p>\n<p><em>In this video, we see an advanced air mobility example showing a VTOL aircraft landing after completing a mission in the Dallas Fort Worth area of Texas using AirSim and Simulink. You can see the Project AirSim simulation server on the top left screen and MATLAB and Simulink model on the top right. The Simulink model contains Project AirSim\u2019s S-function block and an example dynamics model. <\/em><\/p>\n<p>The vehicle\u2019s motion during the flight is calculated using an example VTOL dynamics Simulink model that combines multirotor and fixed-wing forces and feeds them to a 6 degree-of-freedom dynamics block. Using Bing Maps geospatial data for the environment allows Project AirSim to switch the scenario to another area with just a scene configuration change to move the home geo-coordinate to another location\u2019s tile set.<\/p>\n<h3><strong>Summary<\/strong><\/h3>\n<p>In this blog, we walked you through the co-simulation workflow of integrating Microsoft\u2019s Project AirSim with Simulink. By combining these two platforms, engineers can create a simulation environment to run effective tests for UAV development including perception and autonomy algorithms. We\u2019d love to hear about how you plan to use Project AirSim and Simulink to bring your UAV applications to reality.<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/videos\/accelerate-aerial-autonomy-with-simulink-and-microsoft-project-airsim-1683545608155.html\">Get a deeper dive to this workflow<\/a> from MATLAB Expo 2023 video proceedings where Effendi Dufford and Balinder Malhi from Microsoft presented this integration alongside Fred Noto from MathWorks.<\/p>\n<p>Learn more about <a href=\"https:\/\/www.microsoft.com\/en-us\/ai\/autonomous-systems-project-airsim?activetab=pivot1%3aprimaryr3\">Project AirSim<\/a> and <a href=\"https:\/\/www.mathworks.com\/solutions\/robotics\/uav.html\">MathWorks\u2019 UAV solutions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"http:\/\/blogs.mathworks.com\/autonomous-systems\/files\/2023\/07\/Picture1.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>In this blog post, we&#8217;re going to take a deep dive into a co-simulation workflow using Microsoft\u2019s Project AirSim and MathWorks\u2019 Simulink\u00ae. You will learn how to integrate custom vehicle&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/autonomous-systems\/2023\/07\/18\/accelerate-aerial-autonomy-with-simulink-and-microsoft-project-airsim\/\">read more >><\/a><\/p>\n","protected":false},"author":188,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[32],"tags":[20,44,41,50,47,53,35,38],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts\/650"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/users\/188"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/comments?post=650"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts\/650\/revisions"}],"predecessor-version":[{"id":680,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/posts\/650\/revisions\/680"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/media?parent=650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/categories?post=650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/autonomous-systems\/wp-json\/wp\/v2\/tags?post=650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}