mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-10 18:24:11 +01:00
AHRS: Store running time to make detect resets easier. Update OP and AHRS in
parallel for this update. Also removed comment for rawhid git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2012 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
f1ba558fa1
commit
2019edd612
@ -206,6 +206,9 @@ int main()
|
|||||||
gps_data.quality = -1;
|
gps_data.quality = -1;
|
||||||
uint32_t last_gps_time = 0;
|
uint32_t last_gps_time = 0;
|
||||||
uint32_t last_indoor_time = 0;
|
uint32_t last_indoor_time = 0;
|
||||||
|
uint32_t up_time_real = 0;
|
||||||
|
uint32_t up_time = 0;
|
||||||
|
uint32_t last_up_time = 0;
|
||||||
|
|
||||||
ahrs_algorithm = AHRSSETTINGS_ALGORITHM_SIMPLE;
|
ahrs_algorithm = AHRSSETTINGS_ALGORITHM_SIMPLE;
|
||||||
|
|
||||||
@ -311,9 +314,16 @@ for all data to be up to date before doing anything*/
|
|||||||
AhrsStatusGet(&status);
|
AhrsStatusGet(&status);
|
||||||
status.CPULoad = ((float)running_counts /
|
status.CPULoad = ((float)running_counts /
|
||||||
(float)(idle_counts + running_counts)) * 100;
|
(float)(idle_counts + running_counts)) * 100;
|
||||||
status.IdleTimePerCyle = idle_counts / (TIMER_RATE / 10000);
|
status.IdleTimePerCyle = idle_counts / (timer_rate() / 10000);
|
||||||
status.RunningTimePerCyle = running_counts / (TIMER_RATE / 10000);
|
status.RunningTimePerCyle = running_counts / (timer_rate() / 10000);
|
||||||
status.DroppedUpdates = ekf_too_slow;
|
status.DroppedUpdates = ekf_too_slow;
|
||||||
|
up_time = timer_count();
|
||||||
|
if(up_time >= last_up_time) // normal condition
|
||||||
|
up_time_real += ((up_time - last_up_time) * 1000) / timer_rate();
|
||||||
|
else
|
||||||
|
up_time_real += ((0xFFFF - last_up_time + up_time) * 1000) / timer_rate();
|
||||||
|
last_up_time = up_time;
|
||||||
|
status.RunningTime = up_time_real;
|
||||||
AhrsStatusSet(&status);
|
AhrsStatusSet(&status);
|
||||||
|
|
||||||
// Alive signal
|
// Alive signal
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#define AHRSSTATUS_H
|
#define AHRSSTATUS_H
|
||||||
|
|
||||||
// Object constants
|
// Object constants
|
||||||
#define AHRSSTATUS_OBJID 3773703778U
|
#define AHRSSTATUS_OBJID 933623714U
|
||||||
#define AHRSSTATUS_NAME "AhrsStatus"
|
#define AHRSSTATUS_NAME "AhrsStatus"
|
||||||
#define AHRSSTATUS_METANAME "AhrsStatusMeta"
|
#define AHRSSTATUS_METANAME "AhrsStatusMeta"
|
||||||
#define AHRSSTATUS_ISSINGLEINST 1
|
#define AHRSSTATUS_ISSINGLEINST 1
|
||||||
@ -73,6 +73,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t SerialNumber[8];
|
uint8_t SerialNumber[8];
|
||||||
uint8_t CPULoad;
|
uint8_t CPULoad;
|
||||||
|
uint32_t RunningTime;
|
||||||
uint8_t IdleTimePerCyle;
|
uint8_t IdleTimePerCyle;
|
||||||
uint8_t RunningTimePerCyle;
|
uint8_t RunningTimePerCyle;
|
||||||
uint8_t DroppedUpdates;
|
uint8_t DroppedUpdates;
|
||||||
@ -92,6 +93,7 @@ typedef struct {
|
|||||||
/* Number of elements for field SerialNumber */
|
/* Number of elements for field SerialNumber */
|
||||||
#define AHRSSTATUS_SERIALNUMBER_NUMELEM 8
|
#define AHRSSTATUS_SERIALNUMBER_NUMELEM 8
|
||||||
// Field CPULoad information
|
// Field CPULoad information
|
||||||
|
// Field RunningTime information
|
||||||
// Field IdleTimePerCyle information
|
// Field IdleTimePerCyle information
|
||||||
// Field RunningTimePerCyle information
|
// Field RunningTimePerCyle information
|
||||||
// Field DroppedUpdates information
|
// Field DroppedUpdates information
|
||||||
|
@ -55,6 +55,9 @@ AhrsStatus::AhrsStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
|||||||
QStringList CPULoadElemNames;
|
QStringList CPULoadElemNames;
|
||||||
CPULoadElemNames.append("0");
|
CPULoadElemNames.append("0");
|
||||||
fields.append( new UAVObjectField(QString("CPULoad"), QString("count"), UAVObjectField::UINT8, CPULoadElemNames, QStringList()) );
|
fields.append( new UAVObjectField(QString("CPULoad"), QString("count"), UAVObjectField::UINT8, CPULoadElemNames, QStringList()) );
|
||||||
|
QStringList RunningTimeElemNames;
|
||||||
|
RunningTimeElemNames.append("0");
|
||||||
|
fields.append( new UAVObjectField(QString("RunningTime"), QString("ms"), UAVObjectField::UINT32, RunningTimeElemNames, QStringList()) );
|
||||||
QStringList IdleTimePerCyleElemNames;
|
QStringList IdleTimePerCyleElemNames;
|
||||||
IdleTimePerCyleElemNames.append("0");
|
IdleTimePerCyleElemNames.append("0");
|
||||||
fields.append( new UAVObjectField(QString("IdleTimePerCyle"), QString("10x ms"), UAVObjectField::UINT8, IdleTimePerCyleElemNames, QStringList()) );
|
fields.append( new UAVObjectField(QString("IdleTimePerCyle"), QString("10x ms"), UAVObjectField::UINT8, IdleTimePerCyleElemNames, QStringList()) );
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
quint8 SerialNumber[8];
|
quint8 SerialNumber[8];
|
||||||
quint8 CPULoad;
|
quint8 CPULoad;
|
||||||
|
quint32 RunningTime;
|
||||||
quint8 IdleTimePerCyle;
|
quint8 IdleTimePerCyle;
|
||||||
quint8 RunningTimePerCyle;
|
quint8 RunningTimePerCyle;
|
||||||
quint8 DroppedUpdates;
|
quint8 DroppedUpdates;
|
||||||
@ -64,6 +65,7 @@ public:
|
|||||||
/* Number of elements for field SerialNumber */
|
/* Number of elements for field SerialNumber */
|
||||||
static const quint32 SERIALNUMBER_NUMELEM = 8;
|
static const quint32 SERIALNUMBER_NUMELEM = 8;
|
||||||
// Field CPULoad information
|
// Field CPULoad information
|
||||||
|
// Field RunningTime information
|
||||||
// Field IdleTimePerCyle information
|
// Field IdleTimePerCyle information
|
||||||
// Field RunningTimePerCyle information
|
// Field RunningTimePerCyle information
|
||||||
// Field DroppedUpdates information
|
// Field DroppedUpdates information
|
||||||
@ -80,7 +82,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static const quint32 OBJID = 3773703778U;
|
static const quint32 OBJID = 933623714U;
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
static const bool ISSINGLEINST = 1;
|
static const bool ISSINGLEINST = 1;
|
||||||
static const bool ISSETTINGS = 0;
|
static const bool ISSETTINGS = 0;
|
||||||
|
@ -64,6 +64,16 @@ _fields = [ \
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
uavobject.UAVObjectField(
|
||||||
|
'RunningTime',
|
||||||
|
'I',
|
||||||
|
1,
|
||||||
|
[
|
||||||
|
'0',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
}
|
||||||
|
),
|
||||||
uavobject.UAVObjectField(
|
uavobject.UAVObjectField(
|
||||||
'IdleTimePerCyle',
|
'IdleTimePerCyle',
|
||||||
'B',
|
'B',
|
||||||
@ -181,7 +191,7 @@ _fields = [ \
|
|||||||
|
|
||||||
class AhrsStatus(uavobject.UAVObject):
|
class AhrsStatus(uavobject.UAVObject):
|
||||||
## Object constants
|
## Object constants
|
||||||
OBJID = 3773703778
|
OBJID = 933623714
|
||||||
NAME = "AhrsStatus"
|
NAME = "AhrsStatus"
|
||||||
METANAME = "AhrsStatusMeta"
|
METANAME = "AhrsStatusMeta"
|
||||||
ISSINGLEINST = 1
|
ISSINGLEINST = 1
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<description>Status for the @ref AHRSCommsModule, including communication errors</description>
|
<description>Status for the @ref AHRSCommsModule, including communication errors</description>
|
||||||
<field name="SerialNumber" units="n/a" type="uint8" elements="8"/>
|
<field name="SerialNumber" units="n/a" type="uint8" elements="8"/>
|
||||||
<field name="CPULoad" units="count" type="uint8" elements="1"/>
|
<field name="CPULoad" units="count" type="uint8" elements="1"/>
|
||||||
|
<field name="RunningTime" units="ms" type="uint32" elements="1"/>
|
||||||
<field name="IdleTimePerCyle" units="10x ms" 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="RunningTimePerCyle" units="10x ms" type="uint8" elements="1"/>
|
||||||
<field name="DroppedUpdates" units="count" type="uint8" elements="1"/>
|
<field name="DroppedUpdates" units="count" type="uint8" elements="1"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user