paparazzi-commits
[Top][All Lists]
Advanced

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

[paparazzi-commits] [5214] add a system monitoring module for FW and Qua


From: Gautier Hattenberger
Subject: [paparazzi-commits] [5214] add a system monitoring module for FW and Quads
Date: Wed, 04 Aug 2010 16:23:56 +0000

Revision: 5214
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5214
Author:   gautier
Date:     2010-08-04 16:23:56 +0000 (Wed, 04 Aug 2010)
Log Message:
-----------
add a system monitoring module for FW and Quads

Modified Paths:
--------------
    paparazzi3/trunk/conf/messages.xml

Added Paths:
-----------
    paparazzi3/trunk/conf/modules/sys_mon.xml
    paparazzi3/trunk/sw/airborne/modules/core/
    paparazzi3/trunk/sw/airborne/modules/core/sys_mon.c
    paparazzi3/trunk/sw/airborne/modules/core/sys_mon.h

Modified: paparazzi3/trunk/conf/messages.xml
===================================================================
--- paparazzi3/trunk/conf/messages.xml  2010-08-04 15:56:02 UTC (rev 5213)
+++ paparazzi3/trunk/conf/messages.xml  2010-08-04 16:23:56 UTC (rev 5214)
@@ -229,6 +229,15 @@
    <field name="long" type="float" unit="deg"/>
  </message>
 
+ <message name="SYS_MON" id="33">
+   <field name="periodic_time" type="uint16" unit="usec" alt_unit="msec" 
alt_unit_coef="0.001"/>
+   <field name="periodic_cycle" type="uint16" unit="usec" alt_unit="msec" 
alt_unit_coef="0.001"/>
+   <field name="periodic_cycle_min" type="uint16" unit="usec" alt_unit="msec" 
alt_unit_coef="0.001"/>
+   <field name="periodic_cycle_max" type="uint16" unit="usec" alt_unit="msec" 
alt_unit_coef="0.001"/>
+   <field name="event_number" type="uint16"/>
+   <field name="cpu_load" type="uint8" unit="%"/>
+ </message>
+
  <message name="MOTOR" id="34">
    <field name="rpm" type="uint16" unit="Hz"/>
    <field name="current" type="int32" unit="mA"/>
@@ -381,9 +390,25 @@
   </message>
 
  <message name="DEBUG_IR_I2C" id="53">
+    <field name="ir1" type="int16" unit="adc"></field>
+    <field name="ir2" type="int16" unit="adc"></field>
     <field name="top" type="int16" unit="adc"></field>
+    <field name="phi" type="float" unit="rad" alt_unit="deg" 
alt_unit_coef="57.3"/>
+    <field name="theta" type="float" unit="rad" alt_unit="deg" 
alt_unit_coef="57.3"/>
  </message>
 
+ <message name="BARO_ETS" id="56">
+   <field name="adc" type="uint16"/>
+   <field name="offset" type="uint16"/>
+   <field name="scaled" type="float"/>
+ </message>
+
+ <message name="AIRSPEED_ETS" id="57">
+   <field name="adc" type="uint16"/>
+   <field name="offset" type="uint16"/>
+   <field name="scaled" type="float"/>
+ </message>
+
   <message name="H_CTL_A" id="60">
     <field name="roll_sum_err" type="float"/>
     <field name="ref_roll_angle" type="float" unit="rad" alt_unit="deg" 
alt_unit_coef="57.3"/>
@@ -601,14 +626,19 @@
 
   <message name="TCAS_RA" id="121">
     <field name="ac_id" type="uint8"/>
+    <field name="resolve" type="uint8" values="NONE|LEVEL|CLIMB|DESCEND"/>
   </message>
 
-  <message name="TCAS_DEBUG" id="122">
+  <message name="TCAS_RESOLVED" ID="122">
     <field name="ac_id" type="uint8"/>
+  </message>
+
+  <message name="TCAS_DEBUG" id="123">
+    <field name="ac_id" type="uint8"/>
     <field name="tau" type="float"/>
   </message>
 
-  <message name="POTENTIAL" id="123">
+  <message name="POTENTIAL" id="124">
     <field name="east" type="float"/>
     <field name="north" type="float"/>
     <field name="alt" type="float"/>
@@ -616,7 +646,7 @@
     <field name="climb" type="float"/>
   </message>
 
-  <message name="VERTICAL_ENERGY" id="124">
+  <message name="VERTICAL_ENERGY" id="125">
     <field name="Epot_err" type="float"/>
     <field name="Ekin_err" type="float"/>
     <field name="Etot_err" type="float"/>
@@ -873,7 +903,7 @@
     <field name="carrot_east"   type="int32" alt_unit="m" 
alt_unit_coef="0.0039063"/>
     <field name="carrot_north"  type="int32" alt_unit="m" 
alt_unit_coef="0.0039063"/>
     <field name="carrot_up"     type="int32" alt_unit="m" 
alt_unit_coef="0.0039063"/>
-    <field name="carrot_psi"    type="int32" alt_unit="degres" 
alt_unit_coef="0.0139882"/>
+    <field name="carrot_psi"    type="int32" alt_unit="degres" 
alt_unit_coef="0.0000546"/>
     <field name="thrust"        type="int32"/>   
     <field name="flight_time"   type="uint16" unit="s"/>
   </message>
@@ -882,6 +912,17 @@
     <field name="tbd"      type="float"/>
   </message>
 
+  <message name="BOOZ2_GUIDANCE_H_REF_INT" id="149"> 
+    <field name="sp_x"    type="int32" alt_unit="m"     
alt_unit_coef="0.0039063"/>   
+    <field name="ref_x"   type="int32" alt_unit="m"     
alt_unit_coef="0.0039063"/>
+    <field name="ref_xd"  type="int32" alt_unit="m/s"   
alt_unit_coef="0.0000019"/>
+    <field name="ref_xdd" type="int32" alt_unit="m/s2"  
alt_unit_coef="0.0009766"/>
+    <field name="sp_y"    type="int32" alt_unit="m"     
alt_unit_coef="0.0039063"/>   
+    <field name="ref_y"   type="int32" alt_unit="m"     
alt_unit_coef="0.0039063"/>
+    <field name="ref_yd"  type="int32" alt_unit="m/s"   
alt_unit_coef="0.0000019"/>
+    <field name="ref_ydd" type="int32" alt_unit="m/s2"  
alt_unit_coef="0.0009766"/>
+  </message>
+
   <message name="BOOZ2_TUNE_HOVER" id="150">
     <field name="rc_roll"    type="int16" alt_unit="-100/100" 
alt_unit_coef="0.01041670"/>   
     <field name="rc_pitch"   type="int16" alt_unit="-100/100" 
alt_unit_coef="0.01041670"/>   
@@ -1686,6 +1727,12 @@
   <field name="ac_id" type="uint8"/>
  </message>
 
+  <message name="TCAS_RESOLVE" id="17" link="forwarded">
+    <field name="ac_id" type="uint8"/>
+    <field name="ac_id_conflict" type="uint8"/>
+    <field name="resolve" type="uint8" values="NONE|LEVEL|CLIMB|DESCEND"/>
+  </message>
+
  <message name="WINDTURBINE_STATUS" id="50" link="broadcasted">
    <field name="ac_id" type="uint8"/>
    <field name="tb_id" type="uint8"/>
@@ -1721,6 +1768,24 @@
    <field name="h_sp_3" type="int32"/>
    <field name="ac_id"  type="uint8"/>
  </message>
+
+ <message name="BOOZ_NAV_STICK" id="150" link="forwarded">
+   <field name="ac_id" type="uint8"/>
+   <field name="vx_sp" type="int8"/>
+   <field name="vy_sp" type="int8"/>
+   <field name="vz_sp" type="int8"/>
+   <field name="r_sp"  type="int8"/>
+ </message>
+
+ <message name="EXTERNAL_FILTER_SOLUTION" id="151" link="forwarded">
+   <field name="ac_id"  type="uint8"/>
+   <field name="status" type="uint8"/>
+   <field name="x"      type="float" unit="m"/>
+   <field name="xd"     type="float" unit="m"/>
+   <field name="y"      type="float" unit="m"/>
+   <field name="yd"     type="float" unit="m"/>
+ </message>
+
 </class>
 
 

Added: paparazzi3/trunk/conf/modules/sys_mon.xml
===================================================================
--- paparazzi3/trunk/conf/modules/sys_mon.xml                           (rev 0)
+++ paparazzi3/trunk/conf/modules/sys_mon.xml   2010-08-04 16:23:56 UTC (rev 
5214)
@@ -0,0 +1,15 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<module name="core">
+  <header>
+    <file name="sys_mon.h"/>
+  </header>
+  <init fun="init_sysmon()"/>
+  <periodic fun="periodic_report_sysmon()" freq="1."/>
+  <periodic fun="periodic_sysmon()"/>
+  <event fun="event_sysmon()"/>
+  <makefile>
+    <file name="sys_mon.c"/>
+  </makefile>
+</module>
+

Added: paparazzi3/trunk/sw/airborne/modules/core/sys_mon.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/core/sys_mon.c                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/core/sys_mon.c 2010-08-04 16:23:56 UTC 
(rev 5214)
@@ -0,0 +1,102 @@
+/*
+ * $Id:  $
+ *  
+ * Copyright (C) 2010  Gautier Hattenberger
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA. 
+ *
+ */
+
+#include "sys_mon.h"
+#include "sys_time.h"
+
+/* Global vars */
+uint8_t cpu_load;
+uint16_t periodic_time, periodic_cycle, periodic_cycle_min, periodic_cycle_max;
+uint16_t event_time, event_number;
+
+/* Local vars */
+uint16_t n_periodic, n_event;
+uint32_t time_periodic, time_event;
+uint32_t sum_time_periodic, sum_cycle_periodic, sum_time_event, sum_n_event;
+
+void init_sysmon(void) {
+  cpu_load = 0;
+  periodic_time = 0;
+  periodic_cycle = 0;
+  periodic_cycle_min = 0xFFFF;
+  periodic_cycle_max = 0;
+  event_time = 0;
+  event_number = 0;
+
+  n_periodic = 0;
+  n_event = 0;
+  sum_time_periodic = 0;
+  sum_cycle_periodic = 0;
+  sum_time_event = 0;
+  sum_n_event = 0;
+}
+
+#include "uart.h"
+#include "messages.h"
+#include "downlink.h"
+
+void periodic_report_sysmon(void) {
+  /** Report system status at low frequency */
+  if (n_periodic > 0) {
+    periodic_time = Max(sum_time_periodic / n_periodic, 1);
+    periodic_cycle = sum_cycle_periodic / n_periodic;
+    cpu_load = 100 * periodic_cycle / periodic_time;
+    event_number = sum_n_event / n_periodic;
+
+    
DOWNLINK_SEND_SYS_MON(DefaultChannel,&periodic_time,&periodic_cycle,&periodic_cycle_min,&periodic_cycle_max,&event_number,&cpu_load);
+  }
+
+  n_periodic = 0;
+  sum_time_periodic = 0;
+  sum_cycle_periodic = 0;
+  sum_n_event = 0;
+  periodic_cycle_min = 0xFFFF;
+  periodic_cycle_max = 0;
+}
+
+void periodic_sysmon(void) {
+  /** Estimate periodic task cycle time */
+  SysTimeTimerStop(time_periodic);
+  periodic_time = USEC_OF_SYS_TICS(time_periodic);
+  periodic_cycle = periodic_time - sum_time_event /* - sum_time_event/n_event 
*/;
+  if (periodic_cycle < periodic_cycle_min) periodic_cycle_min = periodic_cycle;
+  if (periodic_cycle > periodic_cycle_max) periodic_cycle_max = periodic_cycle;
+  sum_time_periodic += periodic_time;
+  sum_cycle_periodic += periodic_cycle;
+  n_periodic++;
+  sum_n_event += n_event;
+  n_event = 0;
+  sum_time_event = 0;
+  SysTimeTimerStart(time_periodic);
+}
+
+void event_sysmon(void) {
+  /** Store event calls total time and number of calls between two periodic 
calls */
+  if (n_event > 0) {
+    sum_time_event += USEC_OF_SYS_TICS(SysTimeTimer(time_event));
+  }
+  SysTimeTimerStart(time_event);
+  n_event++;
+}
+

Added: paparazzi3/trunk/sw/airborne/modules/core/sys_mon.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/core/sys_mon.h                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/core/sys_mon.h 2010-08-04 16:23:56 UTC 
(rev 5214)
@@ -0,0 +1,57 @@
+/*
+ * $Id:  $
+ *  
+ * Copyright (C) 2010  Gautier Hattenberger
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING.  If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA. 
+ *
+ */
+
+/** \file sys_mon.h
+ * 
+ * System monitoring
+ * return cpu load, average exec time, ...
+ */
+
+#ifndef SYS_MON_H
+#define SYS_MON_H
+
+#include "std.h"
+
+extern uint8_t cpu_load;
+extern uint16_t periodic_time, periodic_cycle, periodic_cycle_min, 
periodic_cycle_max;
+extern uint16_t event_time, event_number;
+
+/** Init system monitoring
+ */
+void init_sysmon(void);
+
+/** Report system status
+ */
+void periodic_report_sysmon(void);
+
+/** Analyse periodic calls
+ *  Should be run at the highest frequency
+ */
+void periodic_sysmon(void);
+
+/** Analyse event calls
+ */
+void event_sysmon(void);
+
+#endif




reply via email to

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