Difference between revisions of "Telemetry"

From PaparazziUAV
Jump to navigation Jump to search
m (Added a note that field names in messages.xml are not allowed to contain any spaces)
 
(37 intermediate revisions by 16 users not shown)
Line 1: Line 1:
== Messages ==
== Messages ==
Telemetry messages (sent from the aircraft to the ground) are defined in the telemetry class of [https://github.com/paparazzi/paparazzi/blob/master/conf/messages.xml conf/messages.xml].
See also the generated documentation: http://docs.paparazziuav.org/latest/paparazzi_messages.html
== Sending periodic messages ==
The set of periodic messages sent over the downlink channel by an aircraft to the ground station is configurable
The set of periodic messages sent over the downlink channel by an aircraft to the ground station is configurable
with the help of one XML file, located in the <tt>conf/telemetry</tt> directory. This file must follow the
with the help of one XML file, located in the <tt>conf/telemetry</tt> directory. This file is referenced by <tt>conf/conf.xml</tt> and must follow the
<tt>telemetry.dtd</tt> syntax. The <tt>default.xml</tt> is provided as an example and should be suitable for most users:
<tt>telemetry.dtd</tt> syntax. The <tt>fixedwing_default.xml</tt> and <tt>rotorcraft_default.xml</tt> are provided as an example and should be suitable for most users.
 
{{Box Code|default.xml|
  <tt><!DOCTYPE telemetry SYSTEM "telemetry.dtd">
  <source lang="xml"><!DOCTYPE telemetry SYSTEM "telemetry.dtd">
  <telemetry>
  <telemetry>
   <process name="Ap">
   <process name="Ap">
Line 10: Line 15:
     <message name="ATTITUDE" period="0.5"/>
     <message name="ATTITUDE" period="0.5"/>
     <message name="PPRZ_MODE" period="5"/>
     <message name="PPRZ_MODE" period="5"/>
    <message name="SOME_MODULE_MSG" period="2" module="module_name"/>
     ...
     ...
     </mode>
     </mode>
Line 25: Line 31:
     </mode>
     </mode>
   </process>
   </process>
  </telemetry></tt>
  </telemetry></source>
}}
 
If a [[Modules|module]] attribute is specified for a message, it will be included in the telemetry only if the corresponding module is loaded.
 
It is even possible to create your own telemetry XML definition. By the time you need that, it is highly likely you are already an advanced paparazzi user and know why you would and how you will.
 
===Add Messages===
 
This section provides instructions of an example case of how one would add a new message to Paparazzi and send the data to the ground station. The example is a little old and considers the addition of the AIRSPEED message, which is already present in newer versions of paparazzi. The user will have to implement her own message objects instead of the AIRSPEED message.


The description is divided into <tt>process</tt> and <tt>mode</tt>s. There are currently only two processes in the autopilot, '''Ap''' and '''Fbw'''. Any number of modes is allowed per process, the default is the first of the sequence. A mode contains a list of messages with their period in seconds. In this example, the '''ATTITUDE''' message will be sent by the '''Ap''' process at 2Hz in the default mode and at 10Hz in the '''fast attitude''' mode. The maximum allowed frequency is 60Hz (0.017s) and the maximum period is 1092s.
==== Step 1 ====
 
In sw/ext/pprzlink/message_definitions/v1.0/messages.xml add an airspeed message:
{{Box Code|sw/ext/pprzlink/message_definitions/v1.0/messages.xml|
<source lang="xml">
  <message name="AIRSPEED" id="54">
    <field name="adc_airspeed" type="uint16"/>
    <field name="estimator_airspeed"  type="float" unit="m/s"/>
    <field name="airspeed_setpoint"    type="float" unit="m/s"/>
    <field name="airspeed_controlled"  type="float" unit="m/s"/>
    <field name="groundspeed_setpoint" type="float" unit="m/s"/>
  </message>
</source>}}
Where id="54" has to be unique. To find an new ID to use there is a script file located at ${PAPARAZZI_HOME}/sw/tools/find_free_msg_id.out (yes it is really a script).
 
Type: ${PAPARAZZI_SRC}/sw/tools/find_free_msg_id.out
 
NOTE: Be sure your Paparazzi source and home environment variables are set correctly in your shell [[Installation#Launching_the_Software]])
 
Every field in the output is a variable from Paparazzi. The field name is not allowed to contain spaces. The type must be the type of a variable in your code (ie. look in your code). Add your message along with the frequency to be sent over the messaging bus (AKA telemetry messages).
 
After making the modifications to the messages.xml file, make your paparazzi again (i.e. cd ${PAPARAZZI_HOME} && make) so that your changes to the messages.xml file are reflected in the paparazzi/var/include/messages.h file. This will create a DOWNLINK_SEND_AIRSPEED macro (in ${PAPARAZZI_HOME}/var/include/messages.h). If you do not make paparazzi, this macro will not be created.
 
==== Step 2 ====
 
Add a message to your telemetry file (for example conf/telemetry/default_fixedwing.xml). The message name in telemetry file usually match the message name in messages.xml file, but can be different or even group several messages.
{{Box Code|conf/telemetry/default.xml|
<source lang="xml">
<telemetry>
  <process name="Ap">
    <mode name="default">
      <message name="ALIVE"          period="5"/>
      <message name="GPS"            period="0.25"/>
      <message name="AIRSPEED"      period="1"/>
      ....
</source>
}}
 
The result is a generated file in ${PAPARAZZI_HOME}/var/aircrafts/<AC>/generated/periodic_telemetry.h which consist in a (static) scheduler to that calls specific functions.
 
==== Step 3 ====
 
Create a function in your C source file that will send your message(s) (using the generated DOWNLINK_SEND_* macros) and register it to the telemetry system so that it will be send automatically for you. You also need to include the header <tt>subsystems/datalink/telemetry.h</tt>:
{{Box Code|firmware/fixedwing/autopilot.c|
 
<source lang="c">
...
#include "subsystems/datalink/telemetry.h"
 
static void send_airspeed(struct transport_tx *trans, struct link_device *dev)
{
  pprz_msg_send_AIRSPEED(trans, dev, AC_ID,
                        &airspeed, &v_ctl_auto_airspeed_setpoint,
                        &v_ctl_auto_airspeed_controlled, &v_ctl_auto_groundspeed_setpoint);
}
 
...
void autopilot_init(void) {
...
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AIRSPEED, send_airspeed);
...
}
</source>
}}
where the second parameter in the register function is the id of the message (use the define <tt>PPRZ_MSG_ID_<MESSAGE_NAME></tt>).
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="width:800px">
Prior to '''v5.0''':
<div class="mw-collapsible-content">Past Reference for Paparazzi v5.0 or older:
Create a PERIODIC_SEND_AIRSPEED with the following code in the firmware specific telemetry header file (In ap_downlink.h/fbw_downlink.h for fixedwing or telemetry.h for rotorcraft) :
{{Box Code|conf/telemetry/default.xml|
<source lang="c">
#ifdef USE_AIRSPEED
#define PERIODIC_SEND_AIRSPEED(_chan) DOWNLINK_SEND_AIRSPEED (_chan, _dev  &adc_airspeed_val,&estimator_airspeed,&v_ctl_auto_airspeed_setpoint,&v_ctl_auto_airspeed_controlled,&v_ctl_auto_groundspeed_setpoint)
#else
#define PERIODIC_SEND_AIRSPEED(_chan) {}
#endif
</source>
</div></div>
 
===Configuring the Downlink Data Rate===
 
The limited throughput of our RF modems results in a need to carefully choose which data to send, as well as the frequency at which to send it.  A sophisticated set of files and parameters have been developed in order to tailor the data downlink behavior automatically, manually, temporarily, or permanently according to any desired parameter.  This allows the user to create an almost unlimited possibility of downlink configurations.  For example:
* Tailor the data rate to work with very slow modems (9600 baud or slower)
* Reduce the data rate of some messages so that others can be increased:
*: Automatically send GPS data at a very high rate by sacrificing navigation data when not flying (to help GPS/RFI troubleshooting) then automatically reduce the GPS data rate and send normal navigation data when the launch is initiated.
*: Automatically switch to sending only position data upon landing to conserve power and increase the chance of the operator receiving a position packet when recovering a distant aircraft.
*: Manually send selected sensor data at very high speeds (60Hz) for real time tuning.
* Maintain independent telemetry configurations for aircraft with different modems, sensors, or mission profiles.
 
Any number of configuration files can be created in the <tt>conf/telemetry</tt> directory and selected from the <tt>conf/conf.xml</tt> file. The telemetry downlink is divided into two processes, '''Ap''' and '''Fbw''' each with a possible <tt>mode</tt> option. Any number of modes could be created, the default is the first in the sequence. A mode contains the list of messages to be sent as well as the period of each message in seconds. In this example, the '''ATTITUDE''' message will be sent by the '''Ap''' process at 2Hz in the default mode and at 10Hz in the '''fast attitude''' mode. The maximum allowed frequency is 60Hz (0.017s) and the maximum period is 1092s.


The mode can be chosen in the airframe file by setting the '''TELEMETRY_MODE_FBW''' constant:
The mode can be chosen in the airframe file by setting the '''TELEMETRY_MODE_FBW''' constant:
  <tt><define name="TELEMETRY_MODE_FBW" value="1"/></tt>
  <source lang="xml"><define name="TELEMETRY_MODE_FBW" value="1"/></source>
where the (default) first mode is numbered '''0'''.
where the (default) first mode is numbered '''0'''.


Line 37: Line 143:
Note that an (undocumented!) subset of the messages is required to be able to use ground station properly. So it is not advisable to completely remove messages for the '''Ap''' process listed in the default mode.
Note that an (undocumented!) subset of the messages is required to be able to use ground station properly. So it is not advisable to completely remove messages for the '''Ap''' process listed in the default mode.


== Settings ==
==Specific Messages==
 
===GPS_SOL===
Specification in telemetry file
<source lang="xml">
<message name="GPS_SOL"        period="2.0"/>
</source>
Example from logfile(.data):
6.742 1 GPS_SOL 232 43 198 8
 
Meaning of tokens:
Timestamp, Aircraft-Number, GPS_SOL, Pacc, Sacc, PDOP, numSV


The <tt>settings</tt> attribute in the description of the aircraft in <tt>conf.xml</tt> allows the user to specify a list of variables for which values can be changed in-flight:
*Pacc = Position accuracy (units: CM)
<tt><aircraft
*Sacc = Speed accuracy (units: CM/sec ?)
  name="Microjet"
*PDOP = Position [http://en.wikipedia.org/wiki/Dilution_of_precision_%28GPS%29 Dilution_of_precision_(GPS)] , if this value is high the value of position will be less accurate
  ...
*numSV = number of Space Vehicles (Satellites) used in Nav Solution
  settings="settings/basic.xml"
  ...
/></tt>


with the <tt>basic.xml</tt> file located in <tt>conf/settings/</tt>. A <tt>dl_setting</tt> element in this file associates [[GCS#Settings|buttons or sliders in the GCS interface]] to autopilot variables:
===PPRZ_MODE===
<tt><!DOCTYPE settings SYSTEM "settings.dtd">
Specification in telemetry file
<settings>
<source lang="xml">
  <dl_settings>
<message name="PPRZ_MODE"     period="5."/>
    <dl_settings NAME="flight params">
</source>
      <dl_setting MAX="1000" MIN="-50" STEP="10" VAR="altitude_shift"/>
Example from logfile(.data):
    </dl_settings>
20.433 2 PPRZ_MODE 0 1 2 0 0 1
    <dl_settings NAME="mode">
      <dl_setting MAX="2" MIN="0" STEP="1" VAR="pprz_mode">
        <strip_button name="AUTO2" value="2"/>
      </dl_setting>
      <dl_setting MAX="1" MIN="0" STEP="1" VAR="launch">
        <strip_button name="Launch" value="1"/>
      </dl_setting>
      <dl_setting MAX="1" MIN="0" STEP="1" VAR="kill_throttle"/>
    </dl_settings>
  </dl_settings>
</settings></tt>
where <tt>dl_settings</tt> elements can be nested at any depth. A <tt>dl_setting</tt> element just specifies the name of the variable, the allowed range for the setting (<tt>min</tt> and <tt>max</tt> attributes) and the minimal <tt>step</tt>.


A notebook page will be associated in the GUI to each <tt>dl_settings</tt> element. A slider will be associated to each <tt>dl_setting</tt> entry except if the range is small (typically less than 3) and discrete (step=1): in the latter case, a set of radio buttons will be displayed.
Meaning of tokens:
Timestamp, Aircraft-Number, PPRZ_MODE, ap_mode, ap_gaz, ap_horizontal, if_calib_mode, mcul_status
*ap_mode = (0 = MANUAL, 1 = AUTO1, 2 = AUTO2, 3 = HOME mode (Circle Home waypoint), 4 = NO_GPS (GPS not working), 5 = NB (?)
*ap_gaz = ?
*ap_horizontal = ?
*if_calib_mode = ?
*mcul_status = ?


The <tt>strip_button</tt> element adds a button to the [[GCS#Strip|GCS strip]] for commonly used tasks like "Launch" or "Circle". Multiple buttons can be used to assign different values to the same variable.
== Audio-based downlink ==


== R/C Transmitter Data Uplink (Obsolete) ==
The audio-based downlink has been removed from current hardware designs however using the old designs it is possible to implement. With the current low prices of a simple video transmitter, data over audio may come in as a welcomed addition. Feel free to experiment and revive this classical feature.


With the advent of small modems such as the popular Zigbee-based models, the value of the R/C transmitter based data-link is substantially reduced and the audio-based downlink has also been removed from current hardware designs.  Nevertheless, this feature may still prove useful for extremely minimal hardware configurations.
[[Category:Software]] [[Category:User_Documentation]] [[Category:Telemetry]]
The <tt>tuning_rc.xml</tt> file is located in <tt>conf/settings</tt>.
<tt><aircraft
  name="Microjet"
  ...
  settings="settings/tuning_rc.xml"
  ...
/></tt>
A <tt>rc_settings</tt> element in this file associates switches and sliders of the RC to airborne variables:
<tt><!DOCTYPE settings SYSTEM "settings.dtd">
<!-- A conf to use to tune an A/C using only the rc -->
<settings>
  <rc_settings>
    <rc_mode NAME="AUTO1">
      <rc_setting VAR="ir_pitch_neutral" RANGE="2" RC="gain_1_up" TYPE="float"/>
      <rc_setting VAR="ir_roll_neutral" RANGE="-2" RC="gain_1_down" TYPE="float"/>
    </rc_mode>
    <rc_mode NAME="AUTO2">
      <rc_setting VAR="course_pgain" RANGE="0.1" RC="gain_1_up" TYPE="float"/>
      <rc_setting VAR="pitch_of_roll" RANGE=".2" RC="gain_1_down" TYPE="float"/>
    </rc_mode>
  </rc_settings>
</settings></tt>
First, settings are sorted by mode (<tt>AUTO1</tt> or <tt>AUTO2</tt>). Then a setting is composed of a <tt>var</tt>iable name, a <tt>range</tt> (corresponding to the range of the RC slider) and a <tt>RC</tt> name. The RC name prefix can be ''gain_1'' or ''gain_2'', which corresponds to the <tt>GAIN1</tt> and <tt>GAIN2</tt> channels of your RC transmitter [[Radio_Control|configuration]]. The RC name suffix can be ''up'' or ''down'', which is related to the position of the <tt>CALIB</tt> switch on the RC transmitter.

Latest revision as of 08:12, 25 September 2019

Messages

Telemetry messages (sent from the aircraft to the ground) are defined in the telemetry class of conf/messages.xml. See also the generated documentation: http://docs.paparazziuav.org/latest/paparazzi_messages.html

Sending periodic messages

The set of periodic messages sent over the downlink channel by an aircraft to the ground station is configurable with the help of one XML file, located in the conf/telemetry directory. This file is referenced by conf/conf.xml and must follow the telemetry.dtd syntax. The fixedwing_default.xml and rotorcraft_default.xml are provided as an example and should be suitable for most users.

File: default.xml
<!DOCTYPE telemetry SYSTEM "telemetry.dtd">
 <telemetry>
  <process name="Ap">
    <mode name="default">
     <message name="ATTITUDE" period="0.5"/>
     <message name="PPRZ_MODE" period="5"/>
     <message name="SOME_MODULE_MSG" period="2" module="module_name"/>
     ...
    </mode>
    <mode name="fast attitude">
      <message name="ATTITUDE" period="0.1"/>
    </mode>
 </process>
  <process name="Fbw">
    <mode name="default">
      <message name="COMMANDS" period="1"/>
      ...
    </mode>
    <mode name="debug">
      <message name="PPM" period="0.5"/>
    </mode>
  </process>
 </telemetry>

If a module attribute is specified for a message, it will be included in the telemetry only if the corresponding module is loaded.

It is even possible to create your own telemetry XML definition. By the time you need that, it is highly likely you are already an advanced paparazzi user and know why you would and how you will.

Add Messages

This section provides instructions of an example case of how one would add a new message to Paparazzi and send the data to the ground station. The example is a little old and considers the addition of the AIRSPEED message, which is already present in newer versions of paparazzi. The user will have to implement her own message objects instead of the AIRSPEED message.

Step 1

In sw/ext/pprzlink/message_definitions/v1.0/messages.xml add an airspeed message:

File: sw/ext/pprzlink/message_definitions/v1.0/messages.xml
   <message name="AIRSPEED" id="54">
    <field name="adc_airspeed" type="uint16"/>
    <field name="estimator_airspeed"   type="float" unit="m/s"/>
    <field name="airspeed_setpoint"    type="float" unit="m/s"/>
    <field name="airspeed_controlled"  type="float" unit="m/s"/>
    <field name="groundspeed_setpoint" type="float" unit="m/s"/>
  </message>

Where id="54" has to be unique. To find an new ID to use there is a script file located at ${PAPARAZZI_HOME}/sw/tools/find_free_msg_id.out (yes it is really a script).

Type: ${PAPARAZZI_SRC}/sw/tools/find_free_msg_id.out 

NOTE: Be sure your Paparazzi source and home environment variables are set correctly in your shell Installation#Launching_the_Software)

Every field in the output is a variable from Paparazzi. The field name is not allowed to contain spaces. The type must be the type of a variable in your code (ie. look in your code). Add your message along with the frequency to be sent over the messaging bus (AKA telemetry messages).

After making the modifications to the messages.xml file, make your paparazzi again (i.e. cd ${PAPARAZZI_HOME} && make) so that your changes to the messages.xml file are reflected in the paparazzi/var/include/messages.h file. This will create a DOWNLINK_SEND_AIRSPEED macro (in ${PAPARAZZI_HOME}/var/include/messages.h). If you do not make paparazzi, this macro will not be created.

Step 2

Add a message to your telemetry file (for example conf/telemetry/default_fixedwing.xml). The message name in telemetry file usually match the message name in messages.xml file, but can be different or even group several messages.

File: conf/telemetry/default.xml
 <telemetry>
   <process name="Ap">
    <mode name="default">
      <message name="ALIVE"          period="5"/>
      <message name="GPS"            period="0.25"/>
      <message name="AIRSPEED"       period="1"/>
      ....

The result is a generated file in ${PAPARAZZI_HOME}/var/aircrafts/<AC>/generated/periodic_telemetry.h which consist in a (static) scheduler to that calls specific functions.

Step 3

Create a function in your C source file that will send your message(s) (using the generated DOWNLINK_SEND_* macros) and register it to the telemetry system so that it will be send automatically for you. You also need to include the header subsystems/datalink/telemetry.h:

File: firmware/fixedwing/autopilot.c


 ...
 #include "subsystems/datalink/telemetry.h"

 static void send_airspeed(struct transport_tx *trans, struct link_device *dev)
 {
   pprz_msg_send_AIRSPEED(trans, dev, AC_ID,
                         &airspeed, &v_ctl_auto_airspeed_setpoint,
                         &v_ctl_auto_airspeed_controlled, &v_ctl_auto_groundspeed_setpoint);
 }

 ...
 void autopilot_init(void) {
 ...
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AIRSPEED, send_airspeed);
 ...
 }

where the second parameter in the register function is the id of the message (use the define PPRZ_MSG_ID_<MESSAGE_NAME>).


Prior to v5.0:

Past Reference for Paparazzi v5.0 or older:

Create a PERIODIC_SEND_AIRSPEED with the following code in the firmware specific telemetry header file (In ap_downlink.h/fbw_downlink.h for fixedwing or telemetry.h for rotorcraft) : {{Box Code|conf/telemetry/default.xml|

 #ifdef USE_AIRSPEED
 #define PERIODIC_SEND_AIRSPEED(_chan) DOWNLINK_SEND_AIRSPEED (_chan, _dev   &adc_airspeed_val,&estimator_airspeed,&v_ctl_auto_airspeed_setpoint,&v_ctl_auto_airspeed_controlled,&v_ctl_auto_groundspeed_setpoint)
 #else
 #define PERIODIC_SEND_AIRSPEED(_chan) {}
 #endif

Configuring the Downlink Data Rate

The limited throughput of our RF modems results in a need to carefully choose which data to send, as well as the frequency at which to send it. A sophisticated set of files and parameters have been developed in order to tailor the data downlink behavior automatically, manually, temporarily, or permanently according to any desired parameter. This allows the user to create an almost unlimited possibility of downlink configurations. For example:

  • Tailor the data rate to work with very slow modems (9600 baud or slower)
  • Reduce the data rate of some messages so that others can be increased:
    Automatically send GPS data at a very high rate by sacrificing navigation data when not flying (to help GPS/RFI troubleshooting) then automatically reduce the GPS data rate and send normal navigation data when the launch is initiated.
    Automatically switch to sending only position data upon landing to conserve power and increase the chance of the operator receiving a position packet when recovering a distant aircraft.
    Manually send selected sensor data at very high speeds (60Hz) for real time tuning.
  • Maintain independent telemetry configurations for aircraft with different modems, sensors, or mission profiles.

Any number of configuration files can be created in the conf/telemetry directory and selected from the conf/conf.xml file. The telemetry downlink is divided into two processes, Ap and Fbw each with a possible mode option. Any number of modes could be created, the default is the first in the sequence. A mode contains the list of messages to be sent as well as the period of each message in seconds. In this example, the ATTITUDE message will be sent by the Ap process at 2Hz in the default mode and at 10Hz in the fast attitude mode. The maximum allowed frequency is 60Hz (0.017s) and the maximum period is 1092s.

The mode can be chosen in the airframe file by setting the TELEMETRY_MODE_FBW constant:

<define name="TELEMETRY_MODE_FBW" value="1"/>

where the (default) first mode is numbered 0.

This mode can also be changed dynamically with a datalink setting or with a set stage in the flight plan.

Note that an (undocumented!) subset of the messages is required to be able to use ground station properly. So it is not advisable to completely remove messages for the Ap process listed in the default mode.

Specific Messages

GPS_SOL

Specification in telemetry file

 <message name="GPS_SOL"        period="2.0"/>

Example from logfile(.data):

6.742 1 GPS_SOL 232 43 198 8

Meaning of tokens:

Timestamp, Aircraft-Number, GPS_SOL, Pacc, Sacc, PDOP, numSV
  • Pacc = Position accuracy (units: CM)
  • Sacc = Speed accuracy (units: CM/sec ?)
  • PDOP = Position Dilution_of_precision_(GPS) , if this value is high the value of position will be less accurate
  • numSV = number of Space Vehicles (Satellites) used in Nav Solution

PPRZ_MODE

Specification in telemetry file

 <message name="PPRZ_MODE"      period="5."/>

Example from logfile(.data):

20.433 2 PPRZ_MODE 0 1 2 0 0 1

Meaning of tokens:

Timestamp, Aircraft-Number, PPRZ_MODE, ap_mode, ap_gaz, ap_horizontal, if_calib_mode, mcul_status
  • ap_mode = (0 = MANUAL, 1 = AUTO1, 2 = AUTO2, 3 = HOME mode (Circle Home waypoint), 4 = NO_GPS (GPS not working), 5 = NB (?)
  • ap_gaz = ?
  • ap_horizontal = ?
  • if_calib_mode = ?
  • mcul_status = ?

Audio-based downlink

The audio-based downlink has been removed from current hardware designs however using the old designs it is possible to implement. With the current low prices of a simple video transmitter, data over audio may come in as a welcomed addition. Feel free to experiment and revive this classical feature.