Thursday, 7 August 2014

Ardu Pirate's Motor Mixing Guidelines

Hi Pirates, based on Hein's comments, I'm going to try to explain how is the mixing of the motors done, depending on the layout/position of your ship's motors.
All mixing depends directly on the motor's positions and layout proportions. Depending on it's position each motor needs to apply different strength to pitch and roll axles. In other words, the farthest a motor is from a axle, the stronger it will have to pull.
This strength is set for each motor in the motor mixing (motors.pde) as meanings of a percentual value, that will multiply pitch and roll values used to calculate the final value for each motor.
When the percentage is 100%, it is not necessary to add any value, as we would be multiplying by 1.

Pitch and Roll Axles

Pitch and Roll axles will be used as reference to find the needed strength for each motor:
The axles layout will help to understand and locate what will the values for each motor be, and it's sign.
As for the Yaw, things are simpler, as it just depends on the rotation direction of the motor:
If Motor turns ClockWise (CW) Yaw is Negative.
If Motor turns CounterClockWise (CCW) Yaw is Positive.
I will try to explain it using exampes for the frames we commonly use:

Quad + mode

Ok, let's start with a simple Quad in + mode:
As all 4 motors are on the axles, they all will have 100% and 0% as strength values, in more detail:
MotorPitchRollYaw
0 Right CCW-0%-100%+
1 Left CCW+0%+100%+
2 Front CW+100%0%-
3 Back CW-100%0%-
Thus the resulting pseudo-code would have these signs and values:
rightCCW = - (0 * Pitch) - (1 * Roll) + Yaw
leftCCW = + (0 * Pitch) + (1 * Roll) + Yaw
frontCW = + (1 * Pitch) + (0 * Roll) - Yaw
backCW = - (1 * Pitch) - (0 * Roll) - Yaw
and the final code in Motors.pde, adding throttle and controlling total motor value not to get out of bounds, would be:
rightCCW = constrain(throttle - control_roll + control_yaw, minThrottle, 2000);
leftCCW = constrain(throttle + control_roll + control_yaw, minThrottle, 2000);
frontCW = constrain(throttle + control_pitch - control_yaw, minThrottle, 2000);
backCW = constrain(throttle - control_pitch - control_yaw, minThrottle, 2000);

I plan to do what is called a "pull" to made changes to the custom code regarding custom shaped copters.  
This change in code would only impacts irregular shaped quads, hexas, and octas when the pilot specifically opts to go custom versus the default (the standard X or +).  You have a custom quad if the:
o aspect ratio <> 1 (length is different than width).
o rotors are non symmetric around the
   - forward axis (y) going through the center of gravity (CG)
   - sideways axis (x) going through the CG
   - vertical axis (z) going through the CG
o has a front that is more open for a camera
o deviates from the pictures of a a + or X for the quad, hexa, or octa
o this includes ships described as spider, V, H, U, 88--88, C, etc.
o motor spin direction(s) are different than the pictures
o your CG is pushed somewhere else besides the centroid of the motors.
The advantages of going custom is that the motor factors will be tuned to the coordinate/spin system of your copter versus the coordinate/spin system of the regular copter.  They will fly better.  Pilots will probably not notice small deviations nor would they see significantly improved flight times.  Large deviations might be noticed and provide noticeable changes in flight duration.
Please reply with the motor number (the out-pin number on the APM), coordinates of the motor, and rotation direction of each rotor.  For example,
the owner of this copter would reply (motor number, x, y, CCW/CW):
o 1 (400, 200) CCW 
o 2 (-250, -200) CCW
o 3 (-400, 200), CW
o 4 (250, -200 CW
[note:  no need to tell us your units of measure just so long as you are consistent in measuring; say mm or inches]
Please note:
o The center of gravity of any quad spider or V is not necessarily where the bars cross.  The bars typically cross behind the CG.  .
o The CG is the center of the coordinates or (0,0) where x=0 and y=0
If you decide to participate by replying, the idea is that you will be able to access your custom motor factors without having to compile firmware.  No promises at this point.  First we see what's out there.  But if you do reply, it's far more likely that your design will be implemented in the library.  
If you have any questions or difficulties in doing this, let me know so I can help.

Monday, 28 July 2014

Saturday, 26 July 2014

How to build your own Quadcopter Autopilot / Flight Controller

Back to my home page
How to build your own Quadcopter Autopilot / Flight ControllerBy Dr Gareth Owen (drgowen@gmail.com)3DR QuadcopterFig 1: 3DR Quadcopter

Friday, 25 July 2014

Pseudovector

Physical examples of pseudovectors include magnetic fieldtorquevorticity, and the angular momentum.
Each wheel of a car driving away from an observer has an angular momentum pseudovector pointing left. The same is true for the mirror image of the car.
Consider the pseudovector angular momentum L = r × p. Driving in a car, and looking forward, each of the wheels has an angular momentum vector pointing to the left. If the world is reflected in a mirror which switches the left and right side of the car, the "reflection" of this angular momentum "vector" (viewed as an ordinary vector) points to the right, but the actual angular momentum vector of the wheel (which is still turning forward in the reflection) still points to the left, corresponding to the extra minus sign in the reflection of a pseudovector.
The distinction between vectors and pseudovectors becomes important in understanding the effect of symmetry on the solution to physical systems. Consider an electrical current loop in the z = 0 plane that inside the loop generates a magnetic field oriented in the z direction. This system is symmetric (invariant) under mirror reflections through this plane, with the magnetic field unchanged by the reflection. But reflecting the magnetic field as a vector through that plane would be expected to reverse it; this expectation is corrected by realizing that the magnetic field is a pseudovector, with the extra sign flip leaving it unchanged.
http://www.altdev.co/2013/03/15/what-is-gimbal-lock-and-why-do-we-still-have-to-worry-about-it/
In linear algebra, an orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors), i.e.
Q^\mathrm{T} Q = Q Q^\mathrm{T} = I,


In mathematics, a linear map (also called a linear mapping, linear transformation or, in some contexts, linear function) is a mapping V ↦ W between two modules (includingvector spaces) that preserves (in the sense defined below) the operations of addition and scalar multiplication. 


In mathematics, the orthogonal group of dimension n, denoted O(n), is the group of distance-preserving transformations of aEuclidean space of dimension n that preserve a fixed point, where the group operation is given by composing transformations. 
Equivalently, it is the group of n×n orthogonal matrices of a given dimension, where the group operation is given by matrix multiplication, and an orthogonal matrix is a real matrix whose inverse equals its transpose.

The determinant of an orthogonal matrix being either 1 or −1, an important subgroup of O(n) is the special orthogonal group, denoted SO(n), of the orthogonal matrices of determinant 1

Thursday, 24 July 2014

mode control

-----------control_mode.pde--------------triggered by scheduler_tasks[] -> rc_loop() -> read_control_switch()
set_mode(flight_modes[switchPosition])
exit_mode(control_mode, mode);
control_mode = mode;
Log_Write_Mode(control_mode);
end

-----------flight_mode.pde--------------
triggered by update_flight_mode()
100hz or more (pixhawk 400hz, called directly in fast_loop)

switch (control_mode)
-- stabilize_run();
end

-----------control_stabilize.pde--------------
inside stabilize_run();

// convert pilot input to lean angles
get_pilot_desired_lean_angles(g.rc_1.control_in, g.rc_2.control_in, target_roll, target_pitch); (range 4500)
  • where does control_in come from:
    --radio.pde--
    init_rc_in()
  • g.rc_1.set_angle(ROLL_PITCH_INPUT_MAX); //4500
    g.rc_2.set_angle(ROLL_PITCH_INPUT_MAX);
    g.rc_3.set_range(g.throttle_min, g.throttle_max);
    g.rc_4.set_angle(4500);

    g.rc_1.set_type(RC_CHANNEL_TYPE_ANGLE_RAW);
    g.rc_2.set_type(RC_CHANNEL_TYPE_ANGLE_RAW);
    g.rc_4.set_type(RC_CHANNEL_TYPE_ANGLE_RAW);

    --RCchannel.cpp--
    --set_pwm_no_deadzone(int16_t pwm)--
    if (_type == RC_CHANNEL_TYPE_RANGE) {
            control_in = pwm_to_range_dz(0);
        } else {
            //RC_CHANNEL_ANGLE, RC_CHANNEL_ANGLE_RAW
            control_in = pwm_to_angle_dz(0);
        }

// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(g.rc_4.control_in);

// get pilot's desired throttle
pilot_throttle_scaled = get_pilot_desired_throttle(g.rc_3.control_in);

// call attitude controller
attitude_control.angle_ef_roll_pitch_rate_ef_yaw_smooth(target_roll, target_pitch, target_yaw_rate, get_smoothing_gain());
parameter used above : RC_FEEL_RP, ACCEL_RP_MAX
  •  // calculate earth-frame feed forward roll rate using linear response when close to the target, sqrt response when we're further away
        angle_to_target = roll_angle_ef (=target_roll,-4500~+4500) - _angle_ef_target.x (angle controller earth-frame targets);
angle_to_target -> calculate rate_ef_desired (linear or sqrt response) -> limit the rate _rate_ef_desired.x ->update new _angle_ef_target,angle_ef_error, update_ef_roll_angle_and_error(_rate_ef_desired.x, angle_ef_error (to be received from the funtion), AC_ATTITUDE_RATE_STAB_ROLL_OVERSHOOT_ANGLE_MAX);


// body-frame rate controller is run directly from 100hz loop

// output pilot's throttle
attitude_control.set_throttle_out(pilot_throttle_scaled, true);

Wednesday, 23 July 2014

Acc and mag direction

Accelerometer: 
x +: accelerate to the front
y +: accelerate to the right
z +: accelerate to the up

Magnetometer:
x +: rotating to the right
y +: rotating to the back
z +: yawing to the right

Roll, Pitch, Yaw:
Roll +: roll to the right
Pitch +: pitch backwards
Yaw +: CW angle from N pole

RCIN:
RC1 +: roll right
RC2 +: pitch backwards
RC3 +: throttle up
RC4 +: yaw right

Monday, 21 July 2014





我来说下,重心无论在上还是下对稳定性没有什么影响,lz要知道即使重心低也不能使四轴和直升机这两类飞行器的稳定能力增加,因为普通四轴在飞行的时候螺旋桨产生的拉力始终是垂直于四个螺旋桨平面的(四个桨在同一平面),飞行器并不会产生一种可以使其重的部位朝下而轻的部位朝上的力矩,这不同于我们提篮子时篮子收到的力,篮子收到的力是始终竖直向上的,所以重的部位才会下垂,而在空气中飞行则不会有始终向上的力,机身一旦偏转那么拉力也跟着偏转了。除非只有一种情况下低重心才能起到稳定效果,那就是像固定翼那样,机翼有上反角,四轴则是四个螺旋桨朝向中心安装,未完稍后继续






对于普通四轴而已,重心离开螺旋桨平面越远只能增加飞行器的惰性,(无论重心在上还是下都是一样的效果),为什么会这样呢?因为重心越远,机身做伏仰和侧倾动作的时候螺旋桨所需要克服的力矩会大大增大,所以使动作变得缓慢迟钝,不适合机动飞行,控制变得缓慢而笨重,此时如果还是使用原来的参数则会显得过底,所以需要把感度调高才行,再次强调:重心在上在下只要距离一样那效果也是一样的,除非螺旋桨内倾才能显出区别!!!













这是理论上的,实际上重力趋稳几乎对四轴没用(对飞控操作的飞行器来说,理论上重心远离运动轴心都是有害的)。
因为飞控的校正速度很快,其加速度是大于重力力臂产生的加速度的,所以飞控校正过程中,远离轴心的重心由于惯性的原因其实是起阻碍飞控校正作用的(重力加速度G是远小于飞控校正加速度的,因此基本上是飞控校正力带着重心围绕轴心在跑)。同时,校正过程中四轴到了水平点后,由于重心远离运动轴心,重心在惯性作用下继续推动四轴绕轴心运动,破坏水平,造成飞控不得不再次校正,反复摇摆。因此不管在上面还是在下面,重心远离四轴轴心都是有害的(轴心在哪,看我前贴,我是这么认为的,不一定对)。
On a quadcopter, there isn’t this point of inefficiency, but having to continuously slow down and speed up the props to remain in the air does waste a lot of energy (however regenerative braking would reduce this wastage, but not many models do this at the moment). What’s interesting is that the effect of this was very evident when we were tuning our quadcopter – our quadcopters were designed to lift about 1kg of payload, but they could be made to lift a brick (about 2.3-2.6kg) ONLY if the stabilization tunings were relaxed so that the craft was less stable in the air, but wasted less energy trying to stay absolutely level. Either way, aerodynamically, larger and slower spinning props are more efficient than small fast-spinning props.
This comes down to a lot of aerodynamics, but in effect it’s to do with the fact that the formula for kinetic energy is 1/2mv^2: it takes four times more energy to move a mass of air at twice the speed; compared to only twice the amount of energy to move twice the mass of air. In both cases, the same amount of momentum is conferred (m*v). So it turns out that it takes less energy to exchange momentum with a large amount of air at slow speed than it is to exchange momentum with a small amount of air at high speed. Therefore a large, slower-moving prop is more efficient than a small large-moving prop, especially at hover.

Sunday, 20 July 2014

How does an ESC work

Some brushless motors use hall effect sensors to sense the magnet position and provide feedback. However, most of the brushless motors used for RC are sensorless. When energizing the 3 coils, at any given time one wire is driven positive, one is driven negative and the third is undriven. The magnets on the spinning rotor induce a voltage in the undriven coil which the sensorless controller detects and uses to determine when to switch to the next step in the sequence. 

One problem with the sensorless motors is that voltage induced in a coil is proportional to the speed of the magnet moving past it. At very low speed there is not enough voltage to detect so at startup, the controller has to drive the motor without feedback until it is spinning fast enough to induce a detectable voltage.

4-POLE BRUSHLESS DC MOTOR ANIMATION

Todo

Test slip current of motor

Thursday, 17 July 2014

GPS Glitch

  1. The vehicle is loitering normally and then suddenly takes off in the wrong direction.  This is generally caused by a GPS Glitch.  There is no 100% reliable protection against these which means the pilot should always be ready to take-over manual control.  Beyond that ensuring a good GPS HDOP before take-off is always good and it may help to reduce the GPSGLITCH_RADIUS and/or GPSGLITCH_ACCEL parameters (see GPSGlitch wiki page for details) to tighten up on the glitch detection.


ERR-GPS 2 means a GPS glitch. ERR-GPS 0 means a recovery.


FS_GPS_ENABLE should be set to 1