1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

AHRS: Update UAVObject with information about AHRS rate

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1650 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-09-16 01:54:21 +00:00 committed by peabody124
parent 04fea701d4
commit 19e80da928
10 changed files with 47 additions and 4 deletions

View File

@ -782,6 +782,8 @@ void process_spi_request(void)
// compute the idle fraction
user_tx_v1.payload.user.v.rsp.update.load = ((float) running_counts / (float) (idle_counts+running_counts)) * 100;
user_tx_v1.payload.user.v.rsp.update.idle_time = idle_counts / (TIMER_RATE / 10000);
user_tx_v1.payload.user.v.rsp.update.run_time = running_counts / (TIMER_RATE / 10000);
lfsm_user_set_tx_v1 (&user_tx_v1);
break;

View File

@ -33,7 +33,6 @@
#include "ahrs_timer.h"
#define TIMER_RATE (8e6 / 128)
void timer_start()
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,ENABLE);

View File

@ -36,6 +36,8 @@
#include <pios.h>
#define TIMER_RATE (8e6 / 128)
void timer_start();
uint32_t timer_count();
uint32_t timer_rate();

View File

@ -480,6 +480,8 @@ static void process_update(struct opahrs_msg_v1_rsp_update * update)
AhrsStatusData status;
AhrsStatusGet(&status);
status.CPULoad = update->load;
status.IdleTimePerCyle = update->idle_time;
status.RunningTimePerCyle = update->run_time;
AhrsStatusSet(&status);
}

View File

@ -41,7 +41,7 @@
#define AHRSSTATUS_H
// Object constants
#define AHRSSTATUS_OBJID 3393301276U
#define AHRSSTATUS_OBJID 1854089084U
#define AHRSSTATUS_NAME "AhrsStatus"
#define AHRSSTATUS_METANAME "AhrsStatusMeta"
#define AHRSSTATUS_ISSINGLEINST 1
@ -73,6 +73,8 @@
typedef struct {
uint8_t SerialNumber[25];
uint8_t CPULoad;
uint8_t IdleTimePerCyle;
uint8_t RunningTimePerCyle;
uint8_t CommErrors[5];
uint8_t AlgorithmSet;
uint8_t CalibrationSet;
@ -85,6 +87,8 @@ typedef struct {
/* Number of elements for field SerialNumber */
#define AHRSSTATUS_SERIALNUMBER_NUMELEM 25
// Field CPULoad information
// Field IdleTimePerCyle information
// Field RunningTimePerCyle information
// Field CommErrors information
/* Array element names for field CommErrors */
typedef enum { AHRSSTATUS_COMMERRORS_ALGORITHM=0, AHRSSTATUS_COMMERRORS_UPDATE=1, AHRSSTATUS_COMMERRORS_ATTITUDERAW=2, AHRSSTATUS_COMMERRORS_HOMELOCATION=3, AHRSSTATUS_COMMERRORS_CALIBRATION=4 } AhrsStatusCommErrorsElem;

View File

@ -304,6 +304,8 @@ struct opahrs_msg_v1_rsp_update {
float NED[3];
float Vel[3];
uint8_t load;
uint8_t idle_time;
uint8_t run_time;
} __attribute__((__packed__));
struct opahrs_msg_v1_rsp_calibration {

View File

@ -72,6 +72,12 @@ AhrsStatus::AhrsStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
QStringList CPULoadElemNames;
CPULoadElemNames.append("0");
fields.append( new UAVObjectField(QString("CPULoad"), QString("count"), UAVObjectField::UINT8, CPULoadElemNames, QStringList()) );
QStringList IdleTimePerCyleElemNames;
IdleTimePerCyleElemNames.append("0");
fields.append( new UAVObjectField(QString("IdleTimePerCyle"), QString("10x ms"), UAVObjectField::UINT8, IdleTimePerCyleElemNames, QStringList()) );
QStringList RunningTimePerCyleElemNames;
RunningTimePerCyleElemNames.append("0");
fields.append( new UAVObjectField(QString("RunningTimePerCyle"), QString("10x ms"), UAVObjectField::UINT8, RunningTimePerCyleElemNames, QStringList()) );
QStringList CommErrorsElemNames;
CommErrorsElemNames.append("Algorithm");
CommErrorsElemNames.append("Update");

View File

@ -45,6 +45,8 @@ public:
typedef struct {
quint8 SerialNumber[25];
quint8 CPULoad;
quint8 IdleTimePerCyle;
quint8 RunningTimePerCyle;
quint8 CommErrors[5];
quint8 AlgorithmSet;
quint8 CalibrationSet;
@ -57,6 +59,8 @@ public:
/* Number of elements for field SerialNumber */
static const quint32 SERIALNUMBER_NUMELEM = 25;
// Field CPULoad information
// Field IdleTimePerCyle information
// Field RunningTimePerCyle information
// Field CommErrors information
/* Array element names for field CommErrors */
typedef enum { COMMERRORS_ALGORITHM=0, COMMERRORS_UPDATE=1, COMMERRORS_ATTITUDERAW=2, COMMERRORS_HOMELOCATION=3, COMMERRORS_CALIBRATION=4 } CommErrorsElem;
@ -74,7 +78,7 @@ public:
// Constants
static const quint32 OBJID = 3393301276U;
static const quint32 OBJID = 1854089084U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;

View File

@ -81,6 +81,26 @@ _fields = [ \
{
}
),
uavobject.UAVObjectField(
'IdleTimePerCyle',
'B',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'RunningTimePerCyle',
'B',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'CommErrors',
'B',
@ -136,7 +156,7 @@ _fields = [ \
class AhrsStatus(uavobject.UAVObject):
## Object constants
OBJID = 3393301276
OBJID = 1854089084
NAME = "AhrsStatus"
METANAME = "AhrsStatusMeta"
ISSINGLEINST = 1

View File

@ -3,6 +3,8 @@
<description>Status for the @ref AHRSCommsModule, including communication errors</description>
<field name="SerialNumber" units="n/a" type="uint8" elements="25"/>
<field name="CPULoad" units="count" type="uint8" elements="1"/>
<field name="IdleTimePerCyle" units="10x ms" type="uint8" elements="1"/>
<field name="RunningTimePerCyle" units="10x ms" type="uint8" elements="1"/>
<field name="CommErrors" units="count" type="uint8" elementnames="Algorithm,Update,AttitudeRaw,HomeLocation,Calibration"/>
<field name="AlgorithmSet" units="" type="enum" elements="1" options="FALSE,TRUE"/>
<field name="CalibrationSet" units="" type="enum" elements="1" options="FALSE,TRUE"/>