{"id":682,"date":"2021-11-10T17:08:37","date_gmt":"2021-11-10T15:08:37","guid":{"rendered":"https:\/\/med.upc.edu\/team4-2021\/?page_id=682"},"modified":"2022-01-05T16:24:28","modified_gmt":"2022-01-05T15:24:28","slug":"activity-13","status":"publish","type":"page","link":"https:\/\/med.upc.edu\/team4-2021\/activity-13\/","title":{"rendered":"Activity 13"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>INTERACTING WITH THE REAL AUTOPILOT<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This activity goes one step further than the previous one, in this case we will connect to the drone&#8217;s autopilot to extract some telemetry information but in a real way, not in a simulation (SITL).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As the same as before, the code is running in our machine, and we are connected to the autopilot to extract the data via USB cable.<\/p>\n\n\n\n<h5 class=\"has-text-align-center wp-block-heading\"><strong><em>TIP: THIS METHOD IS ONLY USEFUL WHEN THE DRONE IS DISARMED. TO EXTRACT DATA WHEN THE DRONE IS FLYING, WE WILL USE AN ONBOARD COMPUTER IN FUTURE ACTIVITIES<\/em><\/strong><\/h5>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>AUTOPILOT INFORMATION<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As we know, the autopilot is composed by two parts, the <a href=\"https:\/\/docs.cubepilot.org\/user-guides\/autopilot\/the-cube-module-overview#peripheral-ports\">orange cube<\/a> and the distribution board. The most important connections of this board are the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>USB: SERIAL0<\/li><li>TELEM1 (telemetry radio): SERIAL1<\/li><li>TELEM 2: SERIAL2<\/li><li>GPS: SERIAL3<\/li><li>ADS-B: SERIAL5<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The autopilot uses the MAVLink protocol to exchange the information with the connected devices. Through  the <a href=\"https:\/\/ardupilot.org\/copter\/docs\/common-telemetry-port-setup.html#common-telemetry-port-setuphttps:\/\/docs.cubepilot.org\/user-guides\/autopilot\/the-cube-module-over\">SERIAL1 and SERIAL2<\/a> we can stablish a connection between a ground station by using a telemetry radio.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong> ACTIVITY<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The fist step is connect to the computer (via USB) to the TELEM2 (SERIAL2) port as shown in the figure 1. By using this cable, our Python program will interact with the drone autopilot to extract some telemetry information. The library used is Dronekit.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-drone-768x1024.jpeg\" alt=\"\" class=\"wp-image-830\" width=\"418\" height=\"558\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-drone-768x1024.jpeg 768w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-drone-225x300.jpeg 225w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-drone-1152x1536.jpeg 1152w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-drone.jpeg 1536w\" sizes=\"(max-width: 418px) 100vw, 418px\" \/><figcaption><strong>Figure 1:<\/strong> Cable used for the activity.<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-768x1024.jpeg\" alt=\"\" class=\"wp-image-838\" width=\"238\" height=\"317\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-768x1024.jpeg 768w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-225x300.jpeg 225w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2-1152x1536.jpeg 1152w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/telem2.jpeg 1536w\" sizes=\"(max-width: 238px) 100vw, 238px\" \/><figcaption><strong>Figure 2:<\/strong> TELEM2 port.<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Once the computer and the drone are connected, we should identify in the computer the COM where the autopilot is connected. To do so go to &#8216;Administrador de dispositivos&#8217; or &#8216;Device Manager&#8217;, see figure 3:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/device_manager.png\" alt=\"\" class=\"wp-image-842\" width=\"419\" height=\"236\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/device_manager.png 567w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/device_manager-300x169.png 300w\" sizes=\"(max-width: 419px) 100vw, 419px\" \/><figcaption><strong>Figure 3:<\/strong> Device Manager.<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Then go to &#8216;Ports (COM and LYT)&#8217; and check the corresponding COM, see figure 4:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/ports.jpg\" alt=\"\" class=\"wp-image-845\" width=\"303\" height=\"49\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/ports.jpg 519w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/ports-300x49.jpg 300w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><figcaption><strong>Figure 4:<\/strong> Ports.<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Now, in the Mission Planner we sould configure SERIAL2_BAUD to 115. This will be the speed for the connection. Go to &#8216;CONFIG&#8217; &#8211; &#8216;Full parameters list&#8217; and search SERIAL2_BAUD, do not forget to write the params, see figure 5:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"115\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/serial-1024x115.jpg\" alt=\"\" class=\"wp-image-848\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/serial-1024x115.jpg 1024w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/serial-300x34.jpg 300w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/serial-768x86.jpg 768w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/serial.jpg 1468w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><strong>Figure 5: <\/strong>SERIAL2_BAUD configuration.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">At the moment the TELEM2 port is configured, we should reboot the autopilot, go to &#8216;DATA&#8217; &#8211; &#8216;Actions&#8217; &#8211; &#8216;Preflight_Reboot&#8217;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally we must run the code in our machine:<\/p>\n\n\n\n<h5 class=\"has-text-align-center wp-block-heading\"><strong><em>TIP: BEFORE RUN THE CODE, WRITE IN THE TERMINAL &#8216;pip install pyserial&#8217; TO DOWNLOAD THE PYTHON LIBRARY<\/em><\/strong><\/h5>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/code.jpeg\" alt=\"\" class=\"wp-image-853\" width=\"435\" height=\"200\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/code.jpeg 703w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/code-300x138.jpeg 300w\" sizes=\"(max-width: 435px) 100vw, 435px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/code2.jpeg\" alt=\"\" class=\"wp-image-859\" width=\"436\" height=\"108\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/code2.jpeg 585w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/01\/code2-300x74.jpeg 300w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><figcaption><strong>Figure 6:<\/strong> Code used in the activity and their results.<\/figcaption><\/figure><\/div>\n\n\n\n<h5 class=\"has-text-align-center wp-block-heading\"><strong><em>TIP: IF YOU HAVE SOME RUNTIME ERRORS DUE TO ADS-B PACKETS RECEPTION, YOU MUST DISABLE SERIAL5. GO TO &#8216;CONFIG&#8217; &#8211; &#8216;Full parameters list&#8217; &#8211; SERIAL5_PROTOCOL AND SELECT -1. FINALLY WRITE PARAMETERS AND REBOOT THE AUTOPILOT<\/em><\/strong><\/h5>\n\n\n\n<h3 class=\"wp-block-heading\"><strong> OPEN QUESTION<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We need one more connection between the autopilot and the computer, because is not possible to extract telemetry information from the autopilot connected to the SERIAL0 or SERIAL1 and using a Python program.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>INTERACTING WITH THE REAL AUTOPILOT This activity goes one step further than the previous one, in this case we will connect to the drone&#8217;s autopilot to extract some telemetry information but in a real way, not in a simulation (SITL). As the same as before, the code is running in our machine, and we are [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-682","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages\/682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/comments?post=682"}],"version-history":[{"count":34,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages\/682\/revisions"}],"predecessor-version":[{"id":867,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages\/682\/revisions\/867"}],"wp:attachment":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/media?parent=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}