Reprint: Pixhawk Source Note Seven: Gesture control preview

Source: Internet
Author: User
Tags apm

From: Sina @walkant the eighth part attitude Control preview

English reference: http://dev.ardupilot.com/wiki/apmcopter-programming-attitude-control-2/

This section is derived from: http://liung.github.io/blog/apm/2014-08-31-APM-ArduCopter Attitude control Overview. html

The manual flight mode, such as the stabilize mode, the stunt mode (Acro mode), and the elegant model (Drift modes), the program structure is as follows:



During the main loop execution (such as Pixhawk's task scheduling cycle 2.5ms,400hz;apm2.x to 10ms,100hz), each cycle, the program executes as follows:

    • First, the Update_flight_mode () function in the high-level file Flight_mode.pde is called. By checking the Control_mode variable, the flight mode of the front aircraft (using variables) and then the _run () function in the corresponding flight mode (such as the stabilize_run of the self-stabilizing mode, the return mode (RTL) Rtl_run, etc.) is performed. The result of executing _run is that the system will find a flight control file named control_.pde corresponding to the flight mode (for example: Control_ Stabilize.pde , control_rtl.pde , and so on. The
    • _run function Converts the user's input (read-in from g.rc_1.control_in,g.rc_2.control_in) to the tilt angle (lean angle) at this time in airplane mode, the roll speed rate (rotation rates), Climb (climb rate) and so on (that is, set the target value roll\pitch\yaw\throttle). For example: althold (fixed height, altitude hold) mode converts the user's roll and pitch input to a tilt angle (in units: Angle/°), converts the yaw input to the roll speed rate (in °/s), and converts the throttle input to climb (unit: cm/s). The last thing the
    • _run function must do is to pass the expected angle, rate, and so on parameters to the attitude control and/or azimuth control libraries (which are all placed inside the Ac_attitiudecontrol folder). The
    • ac_attitiudecontrol Library provides 5 possible ways to adjust the attitude of the aircraft, as described below for the three most common methods:

1) angle_ef_roll_pitch_rate_ef_yaw() : This function requires a rotational and yaw angle in the coordinate of the axis system, and a partial speed rate under the coordinate of the axis system. For example: three parameters passed to the function, respectively, on behalf of the roll = -1000 pitch = -1500 yaw = 500 aircraft at this time tilted to the left 10°, bowed to 15°, to the right yaw rate of 5°/s.

2) angle_ef_roll_pitch_yaw() : This function accepts the roll, pitch, and yaw angles of the axis system. Similar to the above function, but the parameter yaw = 500 represents the aircraft North East 5 °

3) rate_bf_roll_pitch_yaw() : This function accepts the roll, pitch, and yaw rate (°/s) of a body shaft system. For example: passed to the function three parameters: On behalf of the roll = -1000 pitch = -1500 yaw = 500 aircraft at this time left-leaning rate 10°/s, bow rate 15°/s, around the z-axis rate of 5°/s.

    • When these functions are called, the function is then called, converting the output of the AC_AttitudeControl::rate_controller_run() functions listed above into roll, yaw, and pitch inputs, and using set_roll,set_pitch,set_yaw and set_throttle methods to send these inputs to the ap_motors Library.

Other than that

    • Ac_poscontrol The library is used to control the 3D azimuth of the aircraft. However, it is usually only used to adjust the relatively simple z-axis direction (such as attitude control), because many flight modes that require complex 3D azimuth adjustments (such as hover loiter) use the "ac_wpnav Library". In summary, the methods commonly used in the Ac_poscontrol library are:

1) set_alt_target_from_climb_rate() : Use Climb (cm/s) as a parameter to update a relative height target that needs to be adjusted.

2) set_pos_target() : Accept a home 3D position vector (in cm) that takes the position of the system as the reference point.

    • If any of the methods in Ac_poscontrol are called, then the function must be called in this flight mode AC_PosControl::update_z_controller() . In this case, you can enable the z-axis azimuth control PID loop and send low-level throttle information to the ap_motors Library. Similarly, if you call a function of the XY axis, you must call the AC_PosControl::update_xy_controller() function.
    • The ap_motors Library contains the "Motor blending Mode" code. This code is responsible for converting the roll, pitch, yaw angle, and throttle value information sent from the Ac_attitudecontrol and Ac_poscontrol libraries to the relative output value of the motor (for example, PWM value). Therefore, such a high-level library would have to use the following function:

1) set_roll(),set_pitch(),set_yaw() : Accepts roll, pitch, and yaw angles within the [ -4500,4500] angle range. These parameters are not the desired angle or rate, more accurately, it is just a numeric value. For example, Set_roll (-4500) will roll to the left as fast as possible on behalf of the aircraft.

2) set_throttle() : Accepts a range of relative throttle values in [0,1000]. 0 means the motor is off and 1000 is full throttle state.

      • Although there are many different classes in the control code for different aircraft configurations (such as four rotors, Y6, traditional helicopters, etc.), there is one same function in these classes that output_armed converts these roll, pitch, yaw, and throttle values into the PWM type input values. During this conversion, the stability patch is applied to control the priority of the shafting due to aircraft configuration limitations (for example, the four motors of the four rotors are not able to achieve the maximum throttle of four motors at maximum speed, Because a part of the motor output must be less than the other part to cause rolling). At the end of the execution function output_armed , it is also called to hal.rcout->write() pass the desired PWM value to the ap_hal layer.
      • The Ap_hal library (Hardware abstraction layer) provides a unified interface for all flight control boards. In the actual control, the hal.rc_out->write() function will accept the PWM value from the Ap_motors class and output to the PWM port (pin end) corresponding to the flight Control Board.

Reprint: Pixhawk Source Note Seven: Gesture control preview

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.