Pixhawk on Burn write Ardupilot tutorial routines after flight control does not work the workaround

Source: Internet
Author: User

In the official

Http://ardupilot.org/dev/docs/learning-ardupilot-the-example-sketches.html

In this tutorial, it should be seen that the terminal prints out a series of GPs values, but I am successful in compiling and burning after the terminal can not output any information. After reading the Ardupilot's underlying code in detail, I finally found the reason.

The original code (note in order to express the main problem of the code omitted):

 /// -*-Tab-width:4; mode:c++; C-basic-offset:4; Indent-tabs-mode:nil-*-  simple Hello World Sketch Andrew Tridgell September ( */  #include  <ap_hal/ap_hal.h>const  ap_hal::hal& HAL = Ap_hal::get_hal ();  void   Setup () {
Hal.console->println (" GPS AUTO Library Test "); Hal.console->println ("Hello world!"); Hal.scheduler ->delay (); }ap_hal_main ();

Post-Modification Code

#include <AP_HAL/AP_HAL.h>
Const ap_hal::hal& HAL = Ap_hal::get_hal ();
  
class gps_auto_test: public Span style= "color: #000000;" > ap_hal::hal::callbacks{ public : void Setup () {Hal.console println ( gps AUTO library test " ); void loop () {Hal.console->printl N ("Hello world!"); Hal.scheduler ->delay (); }}; Gps_auto_test Gat; // Register above functions in HAL board level Ap_hal_main_callbacks (&gat);

After Ap_hal_main_callbacks (&gat) is executed, the program automatically calls Gat.setup () and Gat.loop ().

Execution Result:

In fact Ap_hal_main_callbacks (&gat) and Ap_hal_main () Two macros are implemented in almost the same way, the latter will assemble the setup and loop into a class before using the former. I read the source code also did not find any problem, but really can not execute, so the best way is to package setup and loop into a class after the use of Ap_hal_main_callbacks (&gat) Form.

Note that the encapsulated class inherits the public Ap_hal::hal::callbacks class.

Pixhawk on Burn write Ardupilot tutorial routines after flight control does not work the workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.