Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOAAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Streitenberger
SOAAP
Commits
05cd96d2
Commit
05cd96d2
authored
2 years ago
by
RobertPatzke
Browse files
Options
Downloads
Patches
Plain Diff
Update 20221107-1
parent
800a1868
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/ProcMeas/ProcMeas.cpp
+97
-0
97 additions, 0 deletions
libraries/ProcMeas/ProcMeas.cpp
libraries/ProcMeas/ProcMeas.h
+106
-0
106 additions, 0 deletions
libraries/ProcMeas/ProcMeas.h
with
203 additions
and
0 deletions
libraries/ProcMeas/ProcMeas.cpp
0 → 100644
+
97
−
0
View file @
05cd96d2
//-----------------------------------------------------------------------------
// Thema: Social Manufacturing Network / Process Measurements
// Datei: ProcMeas.cpp
// Editor: Robert Patzke
// URI/URL: www.mfp-portal.de
//-----------------------------------------------------------------------------
// Lizenz: CC-BY-SA (siehe Wikipedia: Creative Commons)
//
#include
"ProcMeas.h"
// ---------------------------------------------------------------------------
// Konstruktoren und Initialisierungen
// ---------------------------------------------------------------------------
//
ProcMeas
::
ProcMeas
(
IntrfMeas
*
measPtr
)
{
pMeas
=
measPtr
;
gravAnglesAvail
=
false
;
pmState
=
pmInit
;
gravSigns
=
0
;
#ifdef ProcMeasDebug
memset
(
&
statistics
,
0
,
sizeof
(
Statistics
));
#endif
};
// ---------------------------------------------------------------------------
// Anwenderfunktionen
// ---------------------------------------------------------------------------
//
void
ProcMeas
::
run
()
{
if
(
pMeas
==
NULL
)
return
;
switch
(
pmState
)
{
case
pmInit
:
#ifdef ProcMeasDebug
statistics
.
pmInitCnt
++
;
#endif
pmState
=
pmWait
;
break
;
case
pmWait
:
#ifdef ProcMeasDebug
statistics
.
pmWaitCnt
++
;
#endif
if
(
pMeas
->
available
(
1
,
1
))
{
pMeas
->
getValues
(
1
,
1
,
&
gravAngles
);
gravSigns
=
pMeas
->
getSigns
(
1
,
1
);
pmState
=
pmCalc
;
}
break
;
case
pmCalc
:
#ifdef ProcMeasDebug
statistics
.
pmCalcCnt
++
;
#endif
posture
.
pitch
=
euler
.
getPitchFromGravity
(
gravAngles
.
x
,
gravAngles
.
y
,
gravAngles
.
z
)
*
RAD_TO_DEG
;
posture
.
roll
=
euler
.
getRollFromGravity
(
gravAngles
.
y
,
gravAngles
.
z
)
*
RAD_TO_DEG
;
posture
.
yaw
=
0.0
;
pMeas
->
sync
(
1
,
1
);
gravAnglesAvail
=
true
;
pmState
=
pmWait
;
break
;
}
}
bool
ProcMeas
::
availAngles
(
bool
reset
)
{
if
(
!
gravAnglesAvail
)
return
(
false
);
if
(
reset
)
gravAnglesAvail
=
false
;
return
(
true
);
}
float
ProcMeas
::
getRollValue
()
{
return
(
posture
.
roll
);
}
float
ProcMeas
::
getPitchValue
()
{
return
(
posture
.
pitch
);
}
float
ProcMeas
::
getYawValue
()
{
return
(
posture
.
yaw
);
}
byte
ProcMeas
::
getGravSigns
()
{
return
(
gravSigns
);
}
This diff is collapsed.
Click to expand it.
libraries/ProcMeas/ProcMeas.h
0 → 100644
+
106
−
0
View file @
05cd96d2
//-----------------------------------------------------------------------------
// Thema: Social Manufacturing Network / Process Measurements
// Datei: ProcMeas.h
// Editor: Robert Patzke
// URI/URL: www.mfp-portal.de
//-----------------------------------------------------------------------------
// Lizenz: CC-BY-SA (siehe Wikipedia: Creative Commons)
//
#ifndef _ProcMeas_h
#define _ProcMeas_h
//-----------------------------------------------------------------------------
#include
<stddef.h>
#include
<string.h>
#include
"arduinoDefs.h"
#include
"IntrfMeas.h"
#include
"EulerAngles.h"
//#define ProcMeasDebug
typedef
enum
_PmState
{
pmInit
,
pmWait
,
pmCalc
}
PmState
;
typedef
struct
_Posture
{
float
roll
;
float
pitch
;
float
yaw
;
}
Posture
,
*
PosturePtr
;
// ---------------------------------------------------------------------------
// class ProcMeas
// ---------------------------------------------------------------------------
//
class
ProcMeas
{
// -------------------------------------------------------------------------
// Klassenspezifische Datentypen
// -------------------------------------------------------------------------
//
#ifdef ProcMeasDebug
typedef
struct
_Statistics
{
dword
pmInitCnt
;
dword
pmWaitCnt
;
dword
pmCalcCnt
;
}
Statistics
,
*
StatisticsPtr
;
#endif
private
:
// -------------------------------------------------------------------------
// Lokale Variablen
// -------------------------------------------------------------------------
//
bool
gravAnglesAvail
;
IntrfMeas
*
pMeas
;
TriFloat
gravAngles
;
byte
gravSigns
;
PmState
pmState
;
EulerAngles
euler
;
Posture
posture
;
private
:
// -------------------------------------------------------------------------
// Lokale Funktionen
// -------------------------------------------------------------------------
//
public
:
// -------------------------------------------------------------------------
// Konstruktoren und Initialisierungen
// -------------------------------------------------------------------------
//
ProcMeas
(
IntrfMeas
*
measPtr
);
// -------------------------------------------------------------------------
// Anwenderfunktionen
// -------------------------------------------------------------------------
//
void
run
();
bool
availAngles
(
bool
reset
);
float
getRollValue
();
float
getPitchValue
();
float
getYawValue
();
byte
getGravSigns
();
// -------------------------------------------------------------------------
// Debug-Funtionen
// -------------------------------------------------------------------------
//
#ifdef ProcMeasDebug
Statistics
statistics
;
#endif
};
//-----------------------------------------------------------------------------
#endif // _ProcMeas_h
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment