[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Paparazzi-devel] Use of shifting operators in Paparazzi

From: Felix Ruess
Subject: Re: [Paparazzi-devel] Use of shifting operators in Paparazzi
Date: Mon, 2 Nov 2015 18:52:18 +0100

Hi Srinath,

gv_adapt_Xmeas is the ratio of vertical acceleration over thrust command.
If these would be floating point variables you would simply write
gv_adapt_Xmeas = g_m_zdd / thrust_applied;
But since they are fixed point variables, the rounding is done by adding/subtracting 0.5 * thrust_applied before dividing it...

Cheers, Felix

On Sat, Oct 31, 2015 at 8:33 PM, Sreenath Dama <address@hidden> wrote:
Hi All,

I have been looking into the code of guidance_v_adapt.c and came across the following lines.

  if (g_m_zdd > 0) {
    gv_adapt_Xmeas = (g_m_zdd + (thrust_applied >> 1)) / thrust_applied;
  } else {
    gv_adapt_Xmeas = (g_m_zdd - (thrust_applied >> 1)) / thrust_applied;

I understand that g_m_zdd represents the acceleration measured by the (IMU-9.81). It would be very helpful if someone could explain from where does the formula of gv_adapt_Xmeas come. Also g_m_zdd is left shifted by 24 while thrust is shifted by 0 (on scale of 0 to 9600) Hence, why are we adding variables with different shifts?


On Tue, Oct 27, 2015 at 2:24 PM, Alexandre Bustico <address@hidden> wrote:
Le 26/10/2015 18:41, Flavio Justino a écrit :
Thanks for replying Felix ;) One last question: what about Double instead of float? What is the main difference (not theoretically as a programming type but for the case of paparazzi objectives). Do you think that it will have any interference in the results relatively to float? Thanks man =)

In term of performance, float (single precision floating point) is done by hardware on stm32f4 class of microcontroler,
but double (double precision floating point) is not accelerated and done by a library which come with gcc.
Using double will add cpu load which must be evaluated.

Future microcontrolers, based on arm cortex m7 core, will have accelerated double precision in hardware.


Paparazzi-devel mailing list

Paparazzi-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]