Monday, 21 March 2016

New Project - Sky walker FPV - UAV - Part 6 Testing and Turning The APM and Aircraft

Testing and Turning
- Before we actually starts the testing and turning, let us go thorough the APM Plane Manual.
- Here I am giving the extracted portions only - which I feel is relevant to my project.
- For detailed information please visit :-
- Please do not be tempted to skip over steps and rush into flight.
- This is robotics and aviation combined–both of which are quite complex on their own.
- Take some time to become familiar with the user manual, visit the APM Plane forum.
- Follow the steps patiently, and you will have your robot safely up in the air.
- I am using Mission Planner & APM 2.6
1. Setup Installing: hardware, software, and firmware.
2. Plugging in: Sensors, radios, batteries, motors, etc.
3. Configuration– Establish telemetry and control between: robot, ground-station, and RC-control transmitter.
4. Set up flight modes, program failsafe behavior, calibrate sensors and motor-controllers, verify correct motor rotation and prop orientation.
5.TuningVerify performance and behavior, adjusting parameters to suit
6. Mission planning and analysis – Programming missions, logging and analyzing telemetry data, ground-control set up.
7. FlyingSafe-skillful piloting and rules of the air, weather and location considerations, pre-flight checks, emergency procedures, operation examples
Ground Station
- A GCS can also be used to control a UAV in flight, uploading new mission commands and setting parameters.
- There are at least eight different ground control stations
Mission Planner,  APM Planner 2,  MAVProxy,  Tower (Droid Planner 3),  AndroPilot,  MAVPilot,  iDroneCtrl, QGroundControl -  that can be used to communicate with ArduPilot
Flight Controller
-          The APM2.6 board is no longer supported for Copter or Plane.
-          The last firmware builds that can be installed are AC v3.2.1 and Plane 3.3.0.
-          APM 2.6 is designed to be used with the 3DR GPS uBlox LEA-6 with Compass module.
-          The GPS/Compass module may be mounted further from noise sources than the APM itself.
-          APM 2.6 requires a GPS unit with an on board compass for full autonomy.
Analog input pins
-          Pin 0 to 8: The APM2 has a row of analog input pins down one side, labelled A0 to A8 on the underside of the board.
-          These are available as pin numbers 0 to 8 inclusive in PIN variables.
-          All these pins can take up to 5V and may be used for any general analog input.
-          They are commonly used for airspeed and sonar inputs.
-          Pin 12: power management connector current pin, accepts up to 5V, usually attached to 3DR power brick with 17:1 scaling
-          Pin 13: power management connector voltage pin, accepts up to 5V, usually attached to 3DR power brick with 10.1:1 scaling

Digital output pins
-          The APM2 uses the same set of 9 analog input pins as digital output pins.
-          They are configured as digital output pins automatically when you start to use them as digital outputs.
-          Pin 54 to 62: You need to add 54 to the pin number to convert from an analog pin number to a digital pin number.
-          So pin 54 is digital output pin on the A0 connector. Pin 58 is A4 etc.
-          These pins are usually used with the RELAY_PIN to RELAY_PIN4 parameters, allowing you to control things like camera shutter, bottle drop etc.
-          They are also used as sonar “stop” pins allowing you to have multiple sonars and not have them interfere with each other.
Setup for Plane
- Assembly
- Install Mission Planner
- Loading Firmware
- Connect Mission Planner to AutoPilot
- Configuration
Standard orientation
-          The Autopilot board should be housed within a case (which includes foam over the barometer) and should be mounted with the white arrow pointing directly towards the front of the vehicle.
-          It should be placed close to the center of gravity of the vehicle (both horizontally and vertically). 
-          Generally this means it should be placed within a few centimeters of the middle of the vehicle and level with the motors.
-          It is not critical that it is placed exactly at the middle but closer is better (there are no recorded cases of problems caused by the controller being far from the centre of gravity).
Connecting to APM 2.x
-          APM 2.6 is compatible with the 3DR UBlox GPS + Compass module.
-          To connect the GPS module to APM 2.6, attach the GPS port to the APM GPS port using the included 5-position-to-6-position cable (use the top-entry port, not the side-entry port), and attach the GPS MAG port to the APM I2C port using the included 4-position cable.
Solid red when powered
GPS lock
Flashing blue when 3D GPS lock acquired
Setting up the connection
-          To establish a connection you must first choose the communication method/channel you want to use, and then set up the physical hardware and Windows device drivers.
-          You can connect the PC and autopilot using USB cables, Telemetry RadiosBluetooth, IP connections etc.
Note:- The driver for your connection hardware must be present on Windows as this makes your connection’s COM port and default data rate available to Mission Planner. (typically the USB connection data rate is 11520 and the radio connection rate is 57600).
Plane Configuration
- This section contains topics related to configuring and testing Plane components, including those required for the operation of the autopilot.
- Mandatory Hardware Configuration
- Configuration Values for Common Airframes
- Throttle Arming in Plane
- Advanced Failsafe Configuration
- Sensor Testing
Note:- In addition to the configuration discussed in this section, you may also choose to Configure Optional Hardware including battery monitor, sonar, airspeed sensor, optical flow, OSD, camera gimbal, antenna tracker etc.
Mandatory Hardware Configuration
- This topic explains how to configure the components that are required for correct operation of the autopilot.
- The linked articles describe the process for configuring the RC transmitter/receiver, compass, and accelerometer and failsafe using Mission Planner.
- Accelerometer Calibration
- Radio Control Calibration
- RC Transmitter Flight Mode Configuration
- Compass Calibration
- Failsafe Function
Accelerometer Calibration in Mission Planner
- This article shows how to perform basic accelerometer calibration (using Mission Planner).
Note:- Accelerometer calibration is mandatory if you’re using EKF to estimate vehicle position.
Calibration steps
-          Under Initial Setup | Mandatory Hardware, select Accel Calibration from the left-side menu.
-          Mission Planner: Calibrate Acceleration
-          Click Calibrate Accel to start the calibration.
-          Mission Planner will prompt you to place the vehicle each calibration position.
-          Press any key to indicate that the autopilot is in position and then proceed to the next orientation.
-          The calibration positions are: level, on right side, left side, nose down, nose up and on its back.
Tip:- It is important that the vehicle is kept still immediately after pressing the key for each step.
- The level position is the most important to get right as this will be the attitude that your controller considers level while flying.
Warning:- Do not perform the press the Calibrate Level button. This function will overwrite your calibration values.
Radio Control Calibration in Mission Planner
Channel mappings- Plane:- Plane default channel mappings are:
Channel 1: Roll
Channel 2: Pitch
Channel 3: Throttle
Channel 4: Yaw
Channel 8 (default): Flight modes. Mode selection can be mapped to any unused parameter with the MODE_CH parameter.
Unused channels can be mapped to control additional peripherals.
Note:- The default channel mappings can be changed using the instructions in RCMAP Input Channel Mapping.
- Once you’ve calibrated the flight mode you can use the instructions in RC Transmitter Flight Mode Configuration to specify which vehicle modes are enabled by each switch position.
- Centre trims - Centre trims in manual RC mode before performing RC calibration. If trims are not centered you may need to do the RC calibration again after you have used the vehicle (this is easy to do at the field).
Note:- Trims are centered when a moving vehicle does not change direction/speed/orientation when travelling hands-off with all controls/sticks in neutral positions. If there is any deviation in direction, speed or orientation, adjust the associated servo to compensate.
Connect autopilot and turn on receiver
Tip:- The green bars should move in the same direction as the transmitter sticks (except for Pitch where the bars move opposite to stick movements – low values are forward, high values are back).  If the green bars move in the wrong direction, reverse them using your RC transmitter’s channel-reverse function (see your RC gear’s manual for guidance).
You should also calibrate the channel you have selected for controlling vehicle mode, and any other channels you have connected to the autopilot.
RC Transmitter Flight Mode Configuration
Note:- As you move your transmitter’s flight mode switch the green highlight bar will move to a different position. Use the drop-down on each line to select the flight mode for that switch position.
When finished press the Save Modes button.
Transmitter configuration
-          The transmitter must emit PWM signals in the correct range to allow us to map a mode to a switch position.
Note:- The correct PWM ranges for selectable modes are shown alongside each mode selection dropdown in the Mission Planner Flight Mode screen .
-          If you want to just support three modes (using a three position switch) then you would configure the transmitter to produce PWM pulse widths of 1165, 1425, and 1815 microseconds for the respective switch positions.
-          If you want to support 6 modes then the transmitter will need to emit PWM widths of around 1165, 1295, 1425, 1555, 1685, and 1815 milliseconds.
-          Typically this is achieved by configuring the transmitter to mix a two position switch and a three position switch (giving 6 modes in total).
-          You can also do this with an analog dial if one is available, but it’s hard to reliably turn a dial to just the right position for six distinct settings.
Compass Calibration in Mission Planner
This article explains how to perform basic compass calibration.
Note:- This article assumes that you’re the most common configuration — APM2.6 board with the compass mounted with the arrow facing toward the front of the vehicle and in the same direction as the arrow on the autopilot.
Calibration steps
- For APM 2.6, select APM with External Compass.
You shouldn’t need to do any more configuration, but you might want to confirm that the Enable compasses, Obtain declination automatically and Automatically learn offsets check boxes are checked.
Click the Live Calibration button.
A window should pop-up showing you the state of the live calibration.
-          Hold the vehicle in the air and rotate it slowly so that each side (front, back, left, right, top and bottom) points down towards the earth for a few seconds in turn.
-          If the Magnetometer board is mounted in its forward facing direction (Drone logo on the tab facing forward and in the opposite direction of the Y arrow) the (COMPASS_ORIENT) parameter will need to be set to (Normal) or “0”.
-          If you have the Y arrow pointing to the front (Drone on tab pointing to the back), set (COMPASS_ORIENT) to (Yaw 180).
-          You will need to set the Magnetometer Orientation Parameter (COMPASS_ORIENT) in the Mission Planner Advanced Parameter List correctly to accommodate the Magnetometer’s orientation.
-          If the Flight controller board is used in an alternate orientation (or upside down), the (COMPASS_ORIENT) parameter will need to also be adjusted to accommodate the Flight controller boards orientation as well as it’s own. (They are additive).
-          It can be confusing, but all orientations in 45 degree increments and even upside down can be accommodated.
-          This Quick Setup Procedure will always work and allow you to set up your compass even if you use a non-3DR magnetometer.
-          Set the (COMPASS_ORIENT) Yaw parameter so the direction your airframe is currently pointing agrees with the HUD in Mission Planner.
-          Now turn your air frame right or left and if the compass correctly follows the direction it is pointed you are done.
-          If the compass turned in the opposite direction of your airframe set (COMPASS_ORIENT) Roll to 180 (flips the compass over).
-          If you need to set Roll to 180 (COMPASS_ORIENT) will also need to include the Yaw from B. above(Example: Yaw 180 Roll 180).
-          Accurately setting up the compass is critical because it is the primary source of heading information.
-          Without an accurate heading the vehicle will not move in the correct direction in autopilot modes (i.e. AUTO, LOITER, PosHold, RTL, etc).
-          This can lead to circling (aka “toiletbowling”) or fly-aways.
-          ArduPilot currently allows up to three compasses to be connected.
-          Only one compass (specified using theCOMPASS_PRIMARY parameter) is used for navigation.
-          While many autopilots have an internal compass, most will instead use an external compass.
-          This provides more reliable data than an internal compass because of the separation from other electronics.
Standard configurations for the main autopilot boards are shown in the table below:
Not supported
Not supported
APM2.5 trace cut, external compass used
Not supported
-          Most users will only need to select their autopilot/compass configuration and perform the Live Calibration but details are also given on the less-used CompassMot and Manual Declination.
-          Most of this configuration can be performed from the Mission Planner‘s Initial Setup | Mandatory Hardware | Compass screen.
-          Other ground stations may have similar features.
Quick configuration
-          Mission Planner supports automatic configuration of almost all parameters for the most common autopilot boards.
-          All you need to do is select the button corresponding to your autopilot controller:
-          For APM 2.6, select APM with External Compass.
-          For APM 2.5, select APM (Internal Compass).
-          If your external compass is in a non-standard orientation, you must manually select the orientation in the combo box (change from ROTATION_NONE).
-          Compass orientations are relative to the flight controller, not the airframe!
-          Most users will then only need to press the Live Calibration button and perform a Live Calibration.
General settings
-          The general settings apply to all compasses connected to the autopilot controller:
-          Enable compasses: determines whether whether (any) compasses are enabled.
-          If enabled the flight controller will use the primary compass for heading data, otherwise the heading will be estimated from GPS.
-          Enabling this checkbox corresponds to setting parameter MAG_ENABLE=1.
Note:- Compasses should always be enabled for Copter/Rover, but may be disabled (not recommended) for Plane.
-          Primary Compass: specifies which compass ArduPilot will use for heading data (only one compass is used for navigation).
-          Normally this will be set to the first compass (“Compass1”).
-          This selection list corresponds to setting the parameter COMPASS_PRIMARY to a value from 0 to 2 (compasses are 0 indexed, even though labelled in the screen from 1 to 3).
-          Obtain declination automatically: sets the declination based on lookup tables following GPS lock.
-          Users can override this default behavior; after deselecting the checkbox (COMPASS_AUTODEC=0) they can manually enter declination in COMPASS_DEC.
-          Automatically learn offsets: TBD.
Compass specific settings
-          The settings that are specific to each compass are grouped together.
-          Some settings are only visible when the compass is enabled.
-          Use this compass: This checkbox enables a particular compass for use by the autopilot.
-          Each checkbox corresponds to a COMPASS_USEx parameter (where x is 0 to 2, depending on the compass).
Note:- Even if multiple COMPASS_USEx parameters are set to 1, the autopilot will still only uses the primary compass (COMPASS_PRIMARY).
-          Externally mounted: Set whether or not a particular compass is externally mounted (corresponds to COMPASS_EXTERNAL=1).
-          If the compass is internal it uses the flight controller’s orientation (AHRS_ORIENTATION).
-          If the compass is external, the orientation may differ from the flight controller (set using the selection list discussed next)
-          Compass orientation: sets the compass orientation for externally mounted compasses.
-          The value is saved as a COMPASS_ORIENTx parameter.
-          The OFFSETS (COMPASS_OFFSx) and and MOT (COMPASS_MOT) parameters are populated by the live calibration and Compass Mot procedures (see the calibration sections below).
Live calibration of offsets
-          Live calibration calculates offsets to compensate for “hard iron” distortions.
-          Click the Live Calibration button.
-          A window should pop-up showing you the state of the live calibration.
-          This shows a sphere for each compass with a red dot showing where the compass is pointing and six “white dot” targets around the sphere.
-          You rotate the vehicle so that the red dot reaches each white dot and causes it to disappear.
-          As you rotate the vehicle you will notice the red dot moves and (perhaps confusingly) the sphere itself also rotates.
-          A colored trail is left behind wherever the compass has already been: high values (> 400) will turn yellow and may indicate magnetic interference.
-          Offsets > 600 will turn red and generate a warning.
-          Hold the vehicle in the air and rotate it slowly so that each side (front, back, left, right, top and bottom) points down towards the earth for a few seconds in turn.
-          The calibration will automatically complete when it has data for all the positions.
-          At this point, another window will pop up telling you that it is saving the newly calculated offsets.
-          These are displayed on the main screen below each associated compass.
Note:- In Copter-3.2.1 and later offsets are considered acceptable provided their combined “length” is less than 600 (i.e. sqrt(offset_x^2+offset_y^2+offset_Z^2) < 600). Prior to Copter 3.2.1 the recommendation was that the absolute value of each offset be less than 150 (i.e. -150 < offset < 150).
Tip:- Some users recommend performing the calibration outdoors away from metal objects using wireless telemetry (primarily so you don’t get tangled in the cable) although no tests have been performed to confirm this is necessary.
Manual declination
-          By default the declination is looked up in a compressed table when the vehicle first achieves GPS lock.
-          This method is accurate to within 1 degree (which should be sufficient) but if you wish to use the uncompressed declination:- Open the Declination Website.
-          It should automatically figure out your location based on you IP address or you can enter your location
-          Uncheck the Obtain declination automatically checkbox and manually enter the declination (highlighted in red in the image above) into the mission planner’s declination field. In this example, we would enter “14” Degrees and “13” Minutes.
-          As soon as your cursor exits the field (i.e by pressing Tab) the value will be converted to decimal radians and saved to the COMPASS_DEC parameter.
Compass error messages
-          Compass Health: The compass has not sent a signal for at least half a second.
-          Compass Variance: In the EKF solution, compass heading disagrees with the heading estimate from other inertial sensors. Clicking the EKF button on the Mission Planner HUD will show the magnitude of the error.
-          Compass Not Calibrated: The compass needs to be calibrated.
-          Compass Offsets High: One of your compass offsets exceeds 600, indicating likely magnetic interference. Check for sources of interference and try calibrating again.
Plane Failsafe Function
-          Plane has a limited failsafe function which is designed to do three things:
-          Detect complete loss of RC signal (if the RC receiver is able to generate a predictable signal-loss behavior) and initiate a defined auto-mode response, such as returning to home.
-          Some RC equipment can do this, and some can’t (see below for details on how to use it if yours supports this function).
-          Detect loss of telemetry for more than 20 sec and switch to return to launch (RTL) mode (GCS Failsafe).
-          Detect loss of GPS for more than 20 seconds and switch into Dead Reckoning mode until GPS signal is regained.
Here’s what the failsafe will not do:
-          Detect if one or more individual RC channel has failed or become disconnected
-          Detect if you’re flying too far away or are about to hit the ground
-          Detect autopilot hardware failures, such as low-power brownouts or in-air reboots
-          Detect if the Plane software is not operating correctly
-          Detect other problems with the aircraft, such as motor failures or low battery situations (although the latter can be set up through the main code if you have the right voltage/current sensor) Otherwise stop you from making setup or flight mistakes
Plane Failsafe Documentation
Throttle Failsafe
-          How it works.
-          Your RC transmitter outputs a PWM signal that is captured by your receiver and relayed to the autopilot.
-          Each channel on your transmitter has a PWM range usually between 1100 – 1900 with 1500 being its neutral position.
-          When you start your radio calibration on the mission planner, all your values will be at 1500.
-          By moving your sticks, knobs and switches you will set your PWM range for each channel.
-          The autopilot monitors your throttle channel and if it notices a drop lower than THR_FS_VALUE (Default is 950) it will go into failsafe mode.
-          RC transmitters usually have a default range for each channel that goes from -100% to 100%, however most transmitters will allow you to extend this to -150% and 150% respectively.
-          In the default setup, bringing your throttle to -100% will translate to a value close to 1100 and bringing it to -150% will translate to a value closer to 900.
-          What we want to achieve is to let your receiver know that the throttle can go as low as -150% but keep the autopilot control range between -100% and 100%.
-          Meaning that when flying, our throttle values will range between 1100 – 1900.
-          If we lose RC communication, the receiver if set up properly, will drop to the lowest known throttle value of ~900.
-          This value falls bellow the THR_FS_VALUE and will trigger the autopilot to go into failsafe mode.
-          First the autopilot will go into short failsafe (FS_SHORT_ACTN, 0=Disabled, 1=Enabled) when it detects loss of signal for more than 1.5 sec.
-          The default setting for short failsafe is Circle mode.
-          If the RC signal is regained during the short failsafe, the flight will return to auto mode.
-          If the loss of signal is longer than 20 sec the autopilot will go into long failsafe (FS_LONG_ACTN, 0=Disabled, 1=Enabled).
-          The default setting for long failsafe is RTL (Return to Launch).
-          Once the long failsafe (RTL mode) has been entered at the conclusion of the short failsafe the RTL mode will continue even if your RC signal is reacquired.
-          Warning: In firmware releases prior to 2.75 there is a bug where the short failsafe goes to RTL mode instead of circle mode potentially resulting in a repeating loop mode failure.
-          This will be fixed and short failsafe will correctly go to circle mode as of version 2.75 of Plane firmware.
-          Enable throttle failsafe by setting THR_FS_Value to 1 (0=Disabled, 1=Enabled).
-          First turn on your transmitter and enable the throttle range to extend past -100%, we want to extend the throttle range past its low threshold.
-          Once this is done, bind with your receiver. This will let your receiver know the lowest possible value for your throttle channel.
-          Next revert the first change you made to the transmitter to limit the throttle to the original range.
-          Do the radio calibration using the Mission Planner.
-          Once the radio calibration is completed, drop the throttle on your transmitter and read what PWM value is being outputted to the mission planner on that channel.
-          Turn off the transmitter.
-          You should see the value drop significantly.
-          This will be the PWM value relayed to the autopilot in the event RC link was lost during flight.
-          Make sure THR_FS_VALUE is an adequate number to trigger the failsafe function on the autopilot.
-          Make sure FS_SHORT_ACTN and FS_LONG_ACTN are both enabled (set to 1).
-          Connect on the mission planner with your RC transmitter on.
-          Verify on the bottom right corner of the HUD that you are “flying” in a non auto mode (Manual, Stabilize, FBW are ok).
-          Turn off your transmitter.
-          After 1.5 sec the flight mode should switch to Circle.
-          After 20 sec the flight mode should switch to RTL. If you observe this behavior, your failsafe function has been set up correctly.
GCS Failsafe
-          How it works.
-          When flying while using telemetry on the GCS, the autopilot can be programmed to trigger into failsafe mode if it loses telemetry.
-          In the event that the autopilot stops receiving MAVlink (telemetry protocol) heartbeat messages for more than 20 sec, the GCS failsafe (FS_GCS_ENABL, 0=Disabled, 1=Enabled) will trigger the autopilot to go into long failsafe and change the flight mode to RTL.
-          Set FS_GCS_ENABL to 1 to enable it.
-          Connect to the Mission Planner via telemetry.
-          Verify on the bottom right corner of the HUD that you are “flying” in a non auto mode (Manual, Stabilize, FBW are ok).
-          Unplug one of the telemetry radios.
-          After a few minutes power off your autopilot. (Remember the autopilot will not go into failsafe until 20 seconds of MAVlink inactivity have passed).
-          Connect your autopilot to the mission planner and pull the logs.
-          Verify on the log that the autopilot went into RTL after 20 sec of MAVlink inactivity.
Failsafe Parameters and their meanings
-          Short failsafe action (Plane:FS_SHORT_ACTN)
-          The action to take on a short (1.5 seconds) failsafe event in AUTO, GUIDED or LOITER modes.
-          A short failsafe event in stabilization modes will always cause a change to CIRCLE mode.
-          In AUTO mode you can choose whether it will RTL (ReturnToLaunch) or continue with the mission.
-          If FS_SHORT_ACTN is 0 then it will continue with the mission, if it is 1 then it will enter CIRCLE mode, and then enter RTL if the failsafe condition persists for 20 seconds.
Long failsafe action (Plane:FS_LONG_ACTN)
-          The action to take on a long (20 second) failsafe event in AUTO, GUIDED or LOITER modes.
-          A long failsafe event in stabilization modes will always cause an RTL (Return To Launch).
-          In AUTO modes you can choose whether it will RTL or continue with the mission.
-          If FS_LONG_ACTN is 0 then it will continue with the mission, if it is 1 then it will enter RTL mode.
-          Note that if FS_SHORT_ACTN is 1, then the aircraft will enter CIRCLE mode after 1.5 seconds of failsafe, and will always enter RTL after 20 seconds of failsafe, regardless of the FS_LONG_ACTN setting.
Failsafe battery voltage (Plane:FS_BATT_VOLTAGE)
-          Battery voltage to trigger failsafe.
-          Set to 0 to disable battery voltage failsafe.
-          If the battery voltage drops below this voltage then the plane will RTL
-          Units: Volts
Failsafe battery milliAmpHours (Plane:FS_BATT_MAH)
-          Battery capacity remaining to trigger failsafe.
-          Set to 0 to disable battery remaining failsafe.
-          If the battery remaining drops below this level then the plane will RTL
-          Units: mAh
GCS failsafe enable (Plane:FS_GCS_ENABL)
-          Enable ground control station telemetry failsafe.
-          Failsafe will trigger after 20 seconds of no MAVLink heartbeat messages.
-      WARNING: Enabling this option opens up the possibility of your plane going into failsafe mode and running the motor on the ground it it loses contact with your ground station.
-          If this option is enabled on an electric plane then either use a separate motor arming switch or remove the propeller in any ground testing.
Configuration Values for Common Airframes
-          This page provides some approximate configuration values for common airframes.
Note:- These values are good enough to “get you off the ground”. For optimum performance you will still need to tune these parameters for your aircraft
Configuration values – not complete files
-          We do not not provide complete configuration files because we do not want to encourage sharing complete configuration files between APM users.
-          Sharing configuration files is often a bad idea because the correct settings for a specific plane are dependent on a lot more factors than just what base airframe type is being used:
-          the right tuning values depends on what type of servos you have installed (different servos respond at different speeds),
-          and which hole in the servo horns you connect the control arms to the right values also depend on your RC transmitter setup, especially the range of movement of each control axis
-          the right tuning values also depend on what motor and battery you have installed, and depends a lot on the total takeoff weight of your aircraft.
-          If one user has a camera installed and another user doesn’t then they will probably need different tuning values.
-          manufacturers often make changes to airframes, servos and motors without re-branding the airframe as a new model.
-          Sometimes they even change the direction that servos move different users have different optional sensors, which changes what configuration options are needed.
-          For example, some users install an airspeed sensor or an external compass.
-          new APM firmware releases frequently change the defaults for some critical parameters to avoid problems found by users.
-          If you load a config file from a user of an older firmware then that will revert those changes For all of these reasons you should not just download a configuration file from another user and expect it to work.
So what can you do?
-          If another user has tuned a similar aircraft, then you can look in their configuration file to find the key tuning parameter they used, and manually put those values into your APM as a starting point for tuning.
-          The key parameters you should look for are:
-          Setting those to an approximately correct value will give you a reasonable starting point for tuning your airframe.
-          After that you should follow the tuning guide.
-          Also note that the Plane parameters default to zero ‘I’ values.
-          The reason for this is that you need to tune the P value first, then tune the I value.
-          If you put in a non-zero I value when the P value is a long way off the aircraft may oscillate badly and could crash.
-          Once you have good P values then you should raise the I values a bit, as described in the tuning guide.
-          That will allow APM to cope better with wind.
-          For example, once the P values are setup correctly then setting the following will help with most aircraft:
              RLL2SRV_I: 0.05
              PTCH2SRV_I: 0.05
-          Available in foam or fibreglass. Current versions have longer wings (1.9m instead of 1.68m).
-          The skywalker has relatively small ailerons for the size of the aircraft, so you will probably need quite high gains.
-          The following parameters will be a good starting point for most users:
              RLL2SRV_P: 1.8
              PTCH2SRV_P: 1.5
              NAVL1_PERIOD: 20
Throttle Arming in Plane
-          A software safety feature that requires the throttle to be explicitly armed by a pilot is available for Plane (first introduced in version 2.77).  
-          This is especially applicable to electric planes.  The idea is to prevent an unexpected throttle up when someone’s hand is near a propeller.
Warning: This feature in no way removes the need to respect the prop!  When the plane is powered, ALWAYS avoid placing hands into the same plane that the propeller spins, even when the throttle is disarmed.  If all is not well with the autopilot electronics or software there is always a slight possibility that signal could unintentionally reach the motor.  Even though this is unlikely (and made even less likely by safety features such as this) it only takes one time to chew up a finger or hand!
-          Parameters governing throttle arming are introduced in the ARMING section of the parameters wiki page.  This page discusses throttle arming in greater detail and walks through the typical procedures for using this safety feature.  This page makes the assumption that you begin will all the ARMING_ parameters set to 0.  Modifying parameters is outside the scope of this page and varies depending which ground control software you are using.
-          In Mission Planner, it is easiest to find the ARMING_ parameters by using the Config/Tuning screen and selecting the “Full Parameter List” menu item.
A note about APM1 and channel 8
-          The APM1 has a hardware multiplexor on channel 8 which forces pass-thru of the first 4 channels if channel 8 is above 1750.
-          This means the arming code is bypassed if you use channel 8 for your flight mode switch.
-          So if you want to use arming on an APM1 then you should change FLTMODE_CH to another channel (say channel 5) and setup your transmitter/receiver to put the mode switch on that other channel.
IMPORTANT: RC Transmitter Calibration - It is essential that your RC radio transmitter be calibrated correctly before continuing.
-          During RC calibration throttle ups are possible, even with safeties enabled and you should therefore remove the propeller or move the plane to a safe area and secure it..
-          Depending on the ground control software you use, the RC3_MIN value may be continuously changing during calibration.
-          Also, if the RC3_MIN value is inadvertently set incorrectly the plane may throttle up after a bad calibration (e.g., if the low stick setting was not captured).
-          Note that if you have RCMAP_THROTTLE set to something other than 3, then the RCn_MIN value used will be the one for the channel you have selected as the throttle channel.
-          When calibrating your RC input you should also be careful to set the minimum value of the throttle (usually RC3_MIN) to the minimum value when in normal flight control.
-          Don’t set it to the value used by your transmitter when in throttle failsafe or you won’t be able to arm using the rudder as the APM will think you are at a non-zero throttle level.
-          Simplest Solution: Use Only ARMING_REQUIRE
-          The simplest way to use the throttle arming feature is to require the user to request the throttle to arm.  
-          ARMING_REQUIRE has three possible values, 0, 1 and 2.  
-          They have the following effect:
              ARMING_REQUIRE=0: No effect.  Throttle arming safety is not employed.
             ARMING_REQUIRE=1: Before the user arms throttle, send minimum PWM to the throttle channel  (which is usually channel 3). Therefore the RC3_MIN PWM value is sent on the servo output rail.
-          ARMING_REQUIRE=2: Before the user arms throttle, send no PWM signal to the throttle channel (usually channel 3). Some ESCs are not happy with this and will continuously beep, some will not.  Some users may prefer this setting as it ensures no signal is sent to the ESC when disarmed.
-          When the ARMING_REQUIRE parameter is set to 1 or 2 (and ARMING_CHECK and ARMING_DIS_RUD are set to 0), all that is required to arm the throttle is to either:
Arm the throttle via the ground control software.
Arm the throttle by applying full right rudder input for several seconds.
-          To arm throttle in Mission Planner, use the Flight Data screen, then select the Actions tab.  This provides an “Arm/Disarm” button that can be used to arm and disarm the throttle.
Location of the Arm/Disarm button in Mission Planner (button circled in red near the bottom of the image).
-          Alternatively, apply full right rudder to your RC transmitter for several seconds to arm the throttle.  
Whichever method you choose should result in a message from your ground control software stating that throttle arming was successful.  Mission planner displays a message in the artificial horizon on the Flight Data screen:
Message on the artificial horizon in Mission Planner stating that arming was successful.
Increased Safety: Perform System Checks Before Arming Throttle
-          If desired, the ARMING_CHECK parameter can also be set to 1 in order to perform system health checks before arming throttle when a user attempts to arm.
-          See wiki documentation on the ARMING_CHECK parameter to see what is checked.
-          One thing to be aware of if you typically do not fly with a ground control station: it will be difficult to determine why your autopilot is not arming if you are not connected to a ground control station when arming.  
-          The ARMING_CHECK parameter should probably be left at 0 when at the an airfield without a ground control station.
The following are possible system health messages that may return if ARMING_CHECK is enabled and the autopilot rejects a request to arm the throttle:
-          Message: “Battery failsafe on.”
-          Solution: Ensure your battery is charged.  If it is, ensure your battery failsafe values are set correctly. For more information on failsafes, see the Failsafe Functions wiki page.
-          Message: “Radio failsafe on.”
-          Solution: Ensure that the RC transmitter is able to communicate with the RC receiver.  For more information on this failsafe, see the documentation on the Throttle Failsafe.
-          Message: “Bad GPS Pos.”
-          Solution: Need to get a 3D fix with the GPS receiver.  After ensuring your GPS receiver is functioning properly, ensure nothing aboard the plane or in the immediate environment is interfering with GPS satellite signals.
-          Message: “No GPS detected.  Solution: ensure your GPS receiver is functioning.
-          Message: “No compass detected.”
-          Solution: If you do not intend to use a compass, then change the COMPASS_USE parameter to 0.  If you do, then you’ll need to ensure your compass is installed and healthy.
-          Message: “Compass not calibrated.”
-          Solution: Calibrate compass.  In Mission Planner this is accomplished in the Initial Setup screen, menu item Mandatory Hardware > Compass.
-          Message: “Compass not healthy.”
-          Solution: Ensure you do not have the compass installed near something that can induce a magnetic field, such as the motor. You also may try re calibrating the compass.
-          Message: “Baro not healthy.”
-          Solution: Try rebooting the autopilot.  If this fails you will have to diagnose what the problem is with the barometer.
Disabling Rudder Arming
-          Some pilots will not want to use the rudder arming capability.  
-          To only allow throttle arming via the ground control software set the ARMING_DIS_RUD parameter to 1.  
-          The autopilot will no longer arm throttle when full right rudder is applied on the RC transmitter.
Advanced Failsafe Configuration
-          The core failsafe functionality of Plane is based on RTL (Return to Launch).
-          It is able to initiate a RTL if the aircraft loses contact with the ground station or loses RC control.
-          That is fine for most users, but in some situations more advanced failsafe capabilities are needed.
-          That is what the Advanced Failsafe options are for.
-          The advanced failsafe options for Plane were added for the Outback Challenge competition, and the features are designed to fit the rules of that competition.
-          Whereas normal failsafe is oriented around saving the aircraft in case control is lost by the pilot, the OBC rules are oriented around ensuring safe operation in a defined region of airspace.
-          This means that the advanced failsafe options are designed to deliberately crash the aircraft if there is any risk that it may fly outside of the region of airspace defined by a geographic boundary and a maximum altitude.
-          While the advanced failsafe features of Plane were designed for the OBC competition, they can be useful in other situations, and are very flexible. They are also harder to configure, so please read this page carefully several times before deciding whether to enable these features on your aircraft.
Mission based
-          The key difference between normal failsafe and the advanced failsafe (AFS) options is that the AFS options are mission based.
-          When a failsafe option (such as loss of GPS lock or loss of ground station communications link) happens, the AFS options specify a waypoint number in the mission that the aircraft will switch to.
-          This allows the pilot to configure a complex series of actions to take when a failsafe event occurs – anything that can be scripted as an Plane mission can be made to happen on failsafe events.
-          Typically the pilot will setup the AFS options for failsafe conditions so that the aircraft will loiter at its current location for some period of time (say one minute) and then proceed back towards home via a pre-determined flight path.
-          It may also include changes in airspeed, changes in altitude, automatic landing or anything else that can be programmed in a mission.
-          If the failsafe event stops (for example GPS lock is regained) then the aircraft will switch back to the mission item it was previously flying towards and continue the mission.
-          This makes the AFS options only really appropriate for AUTO missions.
-          If you are primarily flying Plane in CRUISE mode or other modes then you should use the standard failsafe options.
Enabling the AFS failsafe system
-          To enable the AFS failsafe system you need to set the AFS_ENABLE parameter to 1. The default is zero, which means all the other options are disabled.
-          Note that the AFS system is only built into Plane by default on higher end autopilot boards like the PX4 and Pixhawk.
-          On the APM2 you must recompile the firmware yourself to use the AFS system.
AFS Termination
-          The concept of “flight termination” is key to understanding the AFS failsafe system. Termination is where the aircraft deliberately dives into the ground by setting all control surfaces to maximum and throttle to zero so as to enter a spin.
-          The AFS system will only start a termination if the AFS_TERM_ACTION is set to the magic value 42.
-          For any other value the AFS system will print a message on the GCS console saying that it wants to terminate, but won’t actually change the control surfaces at all.
-          Using a value other than 42 is useful for test flights where you don’t want the aircraft to terminate on a failsafe event.
-          Note that if AFS_TERM_ACTION is not set to 42 then other normal failsafe code is still active, for example if you have a geofence enabled then the aircraft will fly back to the geofence return point.
-          When enabled, the AFS termination system also sets up the secondary IO microcontroller on the Pixhawk autopilot to terminate the aircraft if communication is interrupted between the main FMU microcontroller and the IO microcontroller, for example if the flight firmware crashes.
-          An AFS flight termination is not recoverable. Once your aircraft starts a termination then is no way to recover.
Types of Failsafe Events
-          The AFS failsafe system supports five of types of failsafe events:
-          geofence breach
-          maximum pressure altitude breach
-          GPS loss
-          Ground station communications loss
-          barometer failure
Each of these types of failures has its own specific handling, which is described below.
Geofence Breach
-          If a geofence is enabled then the AFS failsafe module will monitor the aircraft for a breach of the boundaries of the geofence (and lower and upper geofence altitudes if set). If a breach happens then the AFS system will immediately terminate the flight (see termination above).
Maximum pressure altitude breach
-          When sharing airspace with other aircraft it is usual practice to define the available flight altitudes in terms of a common reference pressure, typically QNH (a reference to “nautical height”). The QNH reference pressure, measured in millibar, is distributed to all aircraft either via a radio message or through aviation internet and weather sites.
-          Aircraft then use their barometer to measure the pressure relative to that QNH pressure, which gives them an altitude reference which all aircraft in the area should be using.
-          The AFS failsystem system is able to enforce a pressure altitude limit by setting the QNH pressure in the AFS_QNH_PRESSURE parameter, as a value in millibars. The pilot should then also set a pressure altitude limit using the AFS_AMSL_LIMIT parameter (in meters). Note that this pressure altitude limit is relative to sea level (AMSL stands for “above mean sea level”).
-          If both of these parameters are set then the AFS system fill monitor pressure altitude and will initiate a termination if the pressure altitude rises above the AFS_AMSL_LIMIT.
-          You need to be very careful to set the right AFS_QNH_PRESSURE for your local conditions on the day of your flight, as the QNH pressure can be very different on different days.
-          In addition to the QNH pressure limit, the AFS system also monitors the health of your barometer. If the barometer is unhealthy for 5 seconds then the AFS system will check the AFS_AMSL_ERR_GPS parameter. If it is -1 (the default) then the aircraft will terminate immediately. If it is not -1 then the AFS system will use the AFS_AMSL_ERR_GPS value as a margin to add to the GPS height, and will allow the flight to continue if the GPS altitude plus the AFS_AMSL_ERR_GPS value (in meters) is below the AFS_AMSL_LIMIT value. The purpose of this margin is to account for the inaccuracy of GPS altitudes. A value of 200 is reasonable for safety to ensure the AFS_AMSL_LIMIT pressure altitude is not breached.
GPS Loss
-          The AFS system monitors the health of your GPS receivers throughout the flight. If all of your available GPS receivers lose position lock then this initiates a GPS failure failsafe.
-          When a GPS failure occurs (which is defines as loss of GPS lock for 3 seconds) the AFS system will look at the AFS_WP_GPS_LOSS parameter.
-          This parameter species a waypoint number in your mission to use when a GPS failure occurs. If AFS_WP_GPS_LOSS is non-zero the aircraft will change current waypoint to the waypoint number specified in AFS_WP_GPS_LOSS.
-          You should setup your mission so that the aircraft will perform whatever actions you want on GPS loss.
-          For example, you could have a set of waypoints starting at number 10 which first loiter on the spot for 30 seconds, and then proceed back to the airfield.
-          You would then set AFS_WP_GPS_LOSS to 10 to enable that part of the mission on loss of GPS lock.
-          When setting up mission items for GPS lock it is sometimes useful to include “loiter at the current location” waypoints. That is achieved by setting both the latitude and longitude of LOITER mission commands to zero.
-          If the GPS recovers after a GPS failsafe has started then the aircraft will automatically resume its mission where it left off.
-          If during a period of GPS loss the aircraft also loses communications with the ground station then this is termed a “dual loss”, and the aircraft will terminate.
-          If AFS_MAX_GPS_LOSS is set to a non-zero number, then it is used as a maximum count of the number of GPS failures that will be allowed while returning to the mission after GPS lock is re-established. This counter is only incremented if the 2nd GPS failure happens at least 30 seconds after the previous one (to account for a short period of GPS failure).
Ground station communications loss
-          The AFS system monitors the health of the link between your ground station and your aircraft. It does this by looking for HEARTBEAT MAVLink messages coming from the ground station.
-          If the aircraft does not receive a HEARTBEAT message for a period of 10 seconds then it enters a GCS failsafe state. It then looks for a AFS_WP_COMMS parameter, and if that is non-zero it will change the current target waypoint to the one given in AFS_WP_COMMS. You should set up a section of your mission with whatever actions you want to take on loss of communications.
-          If GPS lock is lost at the same time as GCS communications is lost then that is considered a “dual loss”, and the aircraft will immediately terminate.
-          Note that the monitoring of HEARTBEAT messages only tells the autopilot that it can see messages from the ground station. It does not mean the ground station can see messages from the aircraft. So it is quite possible for your ground station to be reporting loss of communication while the aircraft is still receiving HEARTBEAT messages.
-          If AFS_MAX_COM_LOSS is set to a non-zero number, then it is used as a maximum count of the number of communication failures that will be allowed while returning to the mission after communications is re-established.
-          This counter is only incremented if the 2nd comms failure happens at least 30 seconds after the previous one (to account for a short period of communications failure).
RC Loss
-          If RC control is lost a manual control mode for more than AFS_RC_FAIL_MS milliseconds then flight termination is activated. This termination mode is only enabled if AFS_RC_FAIL_MS is non-zero. For the OBC rules it should be set to 1500 (giving 1.5 seconds).
Monitoring the AFS system
-          The AFS system provides some additional parameters to make it easier to monitor the health of the failsafe system using external electronics (such as an external failsafe board).
The key parameters are:
-          AFS_TERM_PIN: This is a digital pin which is set to a high voltage if termination is started. Note that this pin will go high on termination even if the AFS_TERM_ACTION parameter is not set to 42.
-          AFS_HB_PIN: This is a digital pin number for a pin which is toggled at a rate of 10Hz by the failsafe system. If termination occurs and a AFS_TERM_PIN value is not set then the heartbeat pin will stop toggling.
-          AFS_MAN_PIN: This is a digital pin number for a pin which goes high when the aircraft is in MANUAL mode. It may be useful with some external failsafe boards to detect manual mode and behave differently.
Manual Termination
-          Apart from automatic termination it is also important for the aircrafts operator to be able to terminate the aircraft immediately if he think the aircraft is a danger to people or other aircraft.
-          To force an immediate termination you should use the AFS_TERMINATION parameter. By setting that parameter to 1 the aircraft will immediately terminate.
Example AFS failsafe mission
-          Setting up a AFS failsafe mission takes time, and needs to be done very carefully.
-          To help you understand what is possible you may find the following example files useful
A waypoint mission for the 2014 Outback Challenge with waypoints for different AFS failures commented in the file
-          A geofence file for the 2014 Outback Challenge
-          Testing the AFS system in SITL
-          It is highly recommended that you extensively test the AFS system using the SITL simulation system before using it on a real aircraft. You can simulate all types of in-flight failures using the SIM_* parameters. To start SITL in Kingaroy ready for OBC testing you would use:
- -L Kingaroy --console –map
-          The key parameters for failsafe testing in SITL are:
-          Test GPS failure: param set SIM_GPS_DISABLE 1
-          Test RC failure: param set SIM_RC_FAIL 1
-          Test comms failure: set heartbeat 0
-          Test fence failure: switch to CRUISE mode and fly across boundary
-          Test QNH failure: param set AFS_AMSL_LIMIT 100
 Additional tips for AFS failsafe users
-          You need to ensure that your geofence is enabled before takeoff.
-          This can either be done as part if your preflight checklist, or you could set it a FENCE_CHANNEL and enable it from within your transmitter, ensuring that if your transmitter is out of range that the fence remains enabled.
Sensor Testing
-          This article shows how to check that the main main sensors (including position and GPS) are working properly.
1 Checking the main sensors
2 Display Sensor Data on Graph
Checking the main sensors
-          With Mission Planner connected, move the flight controller board and you should see the artificial horizon move accordingly.
-          Note:- Remember how artificial horizons work: when the aircraft tilts to the right, the horizon tilts to the left (tilt your head and you’ll see what I mean). This is normal!
-          In the screenshot below, the vehicle is tilted a bit to the right.
-          The map will also show your current position using the GPS sensor if you have the GPS module connected, are outside and have GPS lock.
Display Sensor Data on Graph
-          You can see the output from all the various sensors by clicking on the Tuning checkbox on the bottom right of the display.
-          This will bring up the graphical sensor display.
-          If you click on the legend at the top of it , it will bring up a window “Graph This” that allows you to choose which sensors and data outputs to display.
First Flight
-          The following topics explain how to set up and configure your Plane for its first flight, and includes an explanation of the main Flight Modes that you will use.
Starting up and calibrating Plane
Arming Plane
Flight Modes
Tuning Plane
Automatic Tuning with AUTOTUNE
Starting up and calibrating Plane
-          This article describes the basic setup and calibration that should be performed before launching Plane.
1 Ground calibration
2 Setting the Home Position
3 First flight
4 Second flight
5 Level Adjustment
Ground calibration
-          Set your transmitter mode switch to “Manual”. This is a safe mode in which to start up the system.
-          When you power on your board at the field, you should leave the plane motionless on the ground until the three colored LEDs stop flashing (about 30 seconds). That means that the gyros have been calibrated and the plane is ready to fly (assuming you also already have GPS lock).
-          After the ground start completes you should wait for GPS lock before flying.
-          If you do not wait for GPS lock the home location will not be set correctly, and the barometric altimeter calibration will be incorrect.
-          It should take less than two minutes to get lock.
-          If you’re using the MediaTek module, the blue LED on the module will flash while it’s waiting for lock, then turn solid once it has it. Once that happens, the red LED on APM should stop flashing and turn solid. If the blue MediaTek LED turns solid but the red APM LED is still flashing, press the reset button on APM and once it reboots, the red LED should go solid.
-          Note:- On the UBLOX GPS module itself the LED is off while acquiring satellites and on blinking when satellites have been acquired.
Setting the Home Position
-          Tip:- It is very important to acquire GPS lock in order for RTL, Loiter, Auto or any GPS dependent mode to work properly.
-          For Plane the home position is initially established at the time the plane acquires its GPS lock. It is then continuously updated as long as the autopilot is disarmed.
-          This means that if you execute an RTL, your plane will return to the location at which it armed.
-          If the plane you arm is not a good return point then please setup a rally point instead. A rally point will be used in preference to the home location for RTL.
-          Before you take off, hold your aircraft in your hands and switch to FBWA mode, then pitch and tilt the plane it to confirm that the control surfaces move the correct way to return it to level flight. (The ailerons and elevators will move; the rudder only coordinates turns with the ailerons in flight, so it won’t move much on the ground).
-          This will ensure that you haven’t accidentally reversed a channel.
-          You should do this before every flight, just as you move your control surfaces with your RC transmitter to ensure that nothing’s reversed. 
-          Failing to do this is the #1 cause of crashes.
-          Note:- As a safety measure, your throttle will only arm on the ground in Manual mode, Stabilize or for an autotake off in Auto mode.
-          It will not come on in any other Auto mode until you are in motion in the air.
First flight
-          It is highly recommended that you switch into either Stabilize or Fly By Wire mode and observe the behavior of the control surfaces.
-          They should move to return the plane to level when you pitch or roll it. If it isn’t rock solid, you can tune the gains by following the instructions.
-          If you have not tuned your PID gains then you may like to consider doing the first takeoff in AUTOTUNE mode. That will start the tuning process as soon as you takeoff.
Second flight
-          For your second flight, change the third mode (position 3 of your RC mode switch) to RTL in the Mission Planner’s mode setup page.
-          This will test navigation. The aircraft should return to you and orbit overhead at a fixed altitude (which can be set with the Mission Planner).
-          If it does not return crisply and circle overhead in a near-perfect circle, you need to tune the autopilot a bit for your particular airframe. This can usually be done by adjusting the Roll parameters.
-          Once all this has checked out, you can program waypoint missions and test then in Auto mode.
Level Adjustment
- You may find after flying your plane in FBWA that it has a tendency to turn in one direction and/or gains or loses height on a mid throttle setting with the transmitter sticks centred. If this happens, perform the following:-
-       With your autopilot powered on the ground and connected to your mission planner, select FBWA on your transmitter, select the FLIGHT DATA tuning window and plot the nav_roll and nav_pitch data. With your transmitter sticks centred, these should both be zero as shown in this screenshot. If they are not, you need to repeat your RC calibration or adjust your transmitter trims and repeat the FBWA flight test
-          If they are zero, then you need to adjust the AHRS_TRIM_X (roll) and AHRS_TRIM_Y (pitch) for the difference in angle between the autopilot board and your planes attitude when flying straight and level. You can change these by going to CONFIG/TUNING | Full Parameter List and adjusting the parameters as shown in the screenshot below.
Warning:- These parameters are in radians (every 0.01 is about 0.6 of a degree) so adjust in increments of 0.01 initially. If the plane turns to the left, AHRS_TRIM_X should be increased. If the plane loses height with mid throttle, AHRS_TRIM_Y should be increased.
Next;- More about Turning

No comments:

Post a Comment