Units

From PaparazziUAV
Revision as of 12:24, 19 February 2012 by Flixr (talk | contribs) (Created page with "Paparazzi tries to use SI units everywhere. All angles should be in radians and not in degrees! == Automatic unit conversion == For convenience Paparazzi handles some unit conv…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Paparazzi tries to use SI units everywhere.

All angles should be in radians and not in degrees!

Automatic unit conversion

For convenience Paparazzi handles some unit conversions automatically for you (dev and 4.0_beta branches):

In the Airframe_Configuration the unit and code_unit attributes are used for automatic conversion:

  • if unit and code_unit are specified the value is converted to code_unit and then written to the generated/airframe.h file
  • conversion is only done if the contents of the value attribute can be converted to float, otherwise string is simply copied like for any normal define
  • special treatment for unit="deg": if code_unit is not specified, code_unit="rad" is implicitly assumed!
    • if you really want the define in degrees, explicitly specify code_unit="deg"

E.g. now you can write

<section name="INS" prefix="INS_">
  <define name="ROLL_NEUTRAL_DEFAULT" value="-4.0" unit="deg"/>
  <define name="PITCH_NEUTRAL_DEFAULT" value="3.5" unit="deg"/>
</section>

instead of

<section name="INS" prefix="INS_">
  <define name="ROLL_NEUTRAL_DEFAULT" value="-0.0698" unit="rad"/>
  <define name="PITCH_NEUTRAL_DEFAULT" value="RadOfDeg(3.5)" unit="rad"/>
</section>

The units that you can use for unit and code_unit and their conversion are specified in conf/units.xml and hence can easily be extended.

Save settings

Also "save settings" now gracefully handles values containing RadOfDeg(x) or DegOfRad(x) and converts it to the correct unit when reading from the airframe file. When saving the new value it will be correctly written without that macro.

When saving the settings the values are still always displayed in the actual unit (e.g. rad).

defines still using degrees

Regarding radians in the code: the defines

  CAM_PAN_MAX
  CAM_PAN_MIN
  CAM_PAN_NEUTRAL
  CAM_PAN0
  CAM_PAN_POSITION_FOR_FPV
  CAM_TILT_MAX
  CAM_TILT_MIN
  CAM_TILT_NEUTRAL
  CAM_TILT0
  CAM_TILT_POSITION_FOR_FPV

are still in degrees and need to be defined in the airframe file either without any unit or with unit and code_unit both set to deg:

 <define name="TILT_MAX" value="45" unit="deg" code_unit="deg"/>