Power and thrust

Firmware/software/electronics/mechanics
Post Reply
Danmark
Beginner
Posts: 16
Joined: Mon Jul 15, 2013 11:44 pm
Location: Sweden

Power and thrust

Post by Danmark »

in the method distributePower() in stabilizer.c thrust and power seems to be considered proportional but according to http://en.wikipedia.org/wiki/Thrust#Thrust_to_power they are related as P^2=T^3.

Am I missing something or is it something worth looking into?
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Power and thrust

Post by tobias »

I think it is worth looking into. We did some test with this a long time ago without any noticeable difference, if I remembered correctly, but that was with different motors and HW. It should be a small change and might improve the stability so no reason not to test ;)
Danmark
Beginner
Posts: 16
Joined: Mon Jul 15, 2013 11:44 pm
Location: Sweden

Re: Power and thrust

Post by Danmark »

hopefully i'll have some time tonight to test this.
Danmark
Beginner
Posts: 16
Joined: Mon Jul 15, 2013 11:44 pm
Location: Sweden

Re: Power and thrust

Post by Danmark »

got to do some tests yesterday.
felt a bit more stable bot not as fast.
which you would expect as i didn't change the PID parameters and i scaled the power so that if the thrust was UINT16_MAX the power would be UINT16_MAX. so in all other cases(between 0 and UINT16_MAX) the power will be lower than before.
here's a plot describing what i mean http://www.wolframalpha.com/input/?i=pl ... 0+to+65535

so i don't really know if the increase in stability is due to the slower system or if the cf is actually more stable.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Power and thrust

Post by tobias »

Do you have the code you can point to so I can have a look (bitbucket?).
Danmark
Beginner
Posts: 16
Joined: Mon Jul 15, 2013 11:44 pm
Location: Sweden

Re: Power and thrust

Post by Danmark »

i'll push it later today..

from the top of my head it was something like this...

Code: Select all

...

#include "math.h"

...

static int32_t calculatePower(int32_t thrust);

...

#ifdef QUAD_FORMATION_X
  roll = roll >> 1;
  pitch = pitch >> 1;
  motorPowerM1 = limitThrust(calculatePower(thrust - roll + pitch + yaw));
  motorPowerM2 = limitThrust(calculatePower(thrust - roll - pitch - yaw));
  motorPowerM3 =  limitThrust(calculatePower(thrust + roll - pitch + yaw));
  motorPowerM4 =  limitThrust(calculatePower(thrust + roll + pitch - yaw));
#else // QUAD_FORMATION_NORMAL
  motorPowerM1 = limitThrust(calculatePower(thrust + pitch + yaw));
  motorPowerM2 = limitThrust(calculatePower(thrust - roll - yaw));
  motorPowerM3 =  limitThrust(calculatePower(thrust - pitch + yaw));
  motorPowerM4 =  limitThrust(calculatePower(thrust + roll - yaw));
#endif

  motorsSetRatio(MOTOR_M1, motorPowerM1);
  motorsSetRatio(MOTOR_M2, motorPowerM2);
  motorsSetRatio(MOTOR_M3, motorPowerM3);
  motorsSetRatio(MOTOR_M4, motorPowerM4);
}

static int32_t calculatePower(int32_t thrust)
{
  return pow(UINT16_MAX, -0.5) * pow(thrust, 1.5);
}

static uint16_t limitThrust(int32_t value)
{
  if(value > UINT16_MAX)
  {
    value = UINT16_MAX;
  }
  else if(value < 0)
  {
    value = 0;
  }

  return (uint16_t)value;
}
in my code I've also renamed limitThrust to limitPower.
danhamilt1
Beginner
Posts: 13
Joined: Wed Jul 17, 2013 1:59 pm

Re: Power and thrust

Post by danhamilt1 »

I tried the above and it works, however the crazyflie will crash (both literally and logically) when it has to recover from some extreme movement (shaking it with throttle on replicates this) unfortunately I cannot get my logging to work! I am trying to look at the values the pow() function gives out when this scenario happens.
I am thinking it might be when the values are exceptionally big on multiple motors, the crazyflie cannot compute the power values quick enough using pow()?

EDIT: I also do realise that you wrote that code off the top of your head, so it might just be that something was missing :D
danhamilt1
Beginner
Posts: 13
Joined: Wed Jul 17, 2013 1:59 pm

Re: Power and thrust

Post by danhamilt1 »

Ok so I have found a power function that works for this. I have implemented what Danmark wrote above with the new power function and it now flies. As for stability improvement it is very hard to tell. It does certainly fly slower but it does kind of seem more stable, very negligable difference and hard to tell. Like Danmark said it might seem more stable due to the slower flight. Seems a bit more wobbly when hovering (close to the ground is a good way to see this) possibly due to finer adjustments by the stabalizer? Not sure!!
Apologies for the inclusion of the motor beeps in this branch as well, the Crazyflie will beep when it has been disconnected for a length of time, and on start-up.
Available at the stabilizer branch: https://bitbucket.org/danhamilt1/crazyf ... stabalizer
marco.tognon
Member
Posts: 38
Joined: Mon Sep 16, 2013 10:22 am

Re: Power and thrust

Post by marco.tognon »

Did you find some relationship between the value of motorPowerMX in the firmware and the real torque/strength/angular velocity of the motor????

I'm trying to develop a more complex controller which need to set directly the torque for each motors. But for this I need the map from real torque and motorPowerMX value!!!
Post Reply