Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HighBlueParsers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Best
HighBlueParsers
Commits
c54e21e6
Commit
c54e21e6
authored
9 months ago
by
Philémon Prévot
Browse files
Options
Downloads
Patches
Plain Diff
Debug for compilation check part 1
parent
9ca719ce
Branches
Branches containing commit
No related tags found
1 merge request
!2
HighBlueParser dev branch merged to empty main branch
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/filewriter.cpp
+40
-46
40 additions, 46 deletions
src/filewriter.cpp
src/filewriter.h
+8
-9
8 additions, 9 deletions
src/filewriter.h
with
48 additions
and
55 deletions
src/filewriter.cpp
+
40
−
46
View file @
c54e21e6
...
...
@@ -7,7 +7,6 @@
#include
"filewriter.h"
#include
"macros.h"
#include
"decoder.h"
#include
<stdexcept>
#include
<vector>
#include
<iostream>
...
...
@@ -137,12 +136,6 @@ IMUFileWriter::IMUFileWriter(std::string &filename_template, size_t num_channels
outfile
<<
header
;
}
IMUFileWriter
::~
IMUFileWriter
()
{
if
(
msgDecodedPayload
)
{
free
(
msgDecodedPayload
);
}
}
inline
float
le16tof
(
uint8_t
*
array
){
return
static_cast
<
float
>
(
static_cast
<
int16_t
>
(
__builtin_bswap16
(
*
reinterpret_cast
<
uint16_t
*>
(
array
))));
}
...
...
@@ -242,7 +235,7 @@ void IMUFileWriter::DecodeMessage(unsigned char c) {
void
IMUFileWriter
::
ProcessDecodedMessage
(
int
msgFunction
,
int
msgPayloadLength
,
const
unsigned
char
*
msgPayload
)
{
unsigned
int
timeStamp
=
0
;
switch
(
static_cast
<
short
>
(
command
))
{
switch
(
static_cast
<
short
>
(
msgFunction
))
{
case
static_cast
<
short
>
(
HS_DATA_PACKET_FULL_TIMESTAMP
):
{
/*
IMUFileWriter::SensorType sensorType = static_cast<SensorType>(msgPayload[0]);
...
...
@@ -309,11 +302,12 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
unsigned
char
resolutionBits
=
msgPayload
[
7
];
float
samplingFrequency
=
GetFloatSafe
(
msgPayload
,
8
);
unsigned
short
nbSamples
=
msgPayload
[
12
];
unsigned
char
dataSize
=
(
resolutionBits
/
8
);
int
lengthPerSample
=
nbChannels
*
resolutionBits
/
8
+
4
;
double
dataMaxValue
=
std
::
pow
(
2
,
resolutionBits
)
/
2.0
;
for
(
int
i
=
0
;
i
<
nbSamples
&&
size
>=
static_cast
<
size_t
>
(
lengthPerSample
*
i
+
13
);
i
++
)
{
for
(
int
i
=
0
;
i
<
nbSamples
&&
msgPayloadLength
>=
static_cast
<
size_t
>
(
lengthPerSample
*
i
+
13
);
i
++
)
{
uint32_t
timeStamp
=
BUILD_UINT32
(
msgPayload
[
13
+
i
*
lengthPerSample
+
3
],
msgPayload
[
13
+
i
*
lengthPerSample
+
2
],
msgPayload
[
13
+
i
*
lengthPerSample
+
1
],
msgPayload
[
13
+
i
*
lengthPerSample
]);
switch
(
sensorType
)
{
case
IMUFileWriter
::
SensorType
::
Accel
:
...
...
@@ -323,8 +317,8 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
lastAccelTimeStamp
=
timeStamp
;
outfile
<<
"ACCEL, "
<<
timeStamp
/
1000.0
;
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
i
*
lengthPerSample
],
msgPayload
[
17
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
2
*
s
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
2
*
s
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
2
*
dataS
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
2
*
dataS
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
std
::
endl
;
}
else
{
...
...
@@ -338,8 +332,8 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
lastGyroTimeStamp
=
timeStamp
;
outfile
<<
"GYRO, "
<<
timeStamp
;
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
i
*
lengthPerSample
],
msgPayload
[
17
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
2
*
s
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
2
*
s
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
2
*
dataS
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
2
*
dataS
ize
+
i
*
lengthPerSample
+
1
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
std
::
endl
;
}
else
{
...
...
@@ -353,8 +347,8 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
lastMagTimeStamp
=
timeStamp
;
outfile
<<
"MAG, "
<<
timeStamp
;
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
i
*
lengthPerSample
+
1
],
msgPayload
[
17
+
i
*
lengthPerSample
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
+
1
],
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
2
*
s
ize
+
i
*
lengthPerSample
+
1
],
msgPayload
[
17
+
2
*
s
ize
+
i
*
lengthPerSample
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
+
1
],
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
", "
<<
BUILD_INT16
(
msgPayload
[
17
+
2
*
dataS
ize
+
i
*
lengthPerSample
+
1
],
msgPayload
[
17
+
2
*
dataS
ize
+
i
*
lengthPerSample
])
*
(
rangeScale
/
dataMaxValue
);
outfile
<<
std
::
endl
;
}
else
{
...
...
@@ -394,7 +388,7 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
lastLightTimeStamp
=
timeStamp
;
outfile
<<
"LIGHT, "
<<
timeStamp
;
outfile
<<
", "
<<
BUILD_UINT16
(
msgPayload
[
17
+
i
*
lengthPerSample
],
msgPayload
[
17
+
i
*
lengthPerSample
+
1
]);
outfile
<<
", "
<<
BUILD_UINT16
(
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
s
ize
+
i
*
lengthPerSample
+
1
]);
outfile
<<
", "
<<
BUILD_UINT16
(
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
],
msgPayload
[
17
+
dataS
ize
+
i
*
lengthPerSample
+
1
]);
outfile
<<
std
::
endl
;
}
else
{
...
...
@@ -412,32 +406,32 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
break
;
case
static_cast
<
short
>
(
GPS_DATA_PACKET
):
{
IMUFileWriter
::
GPSDatas
gpsDatas
;
unsigned
short
ms
=
BUILD_UINT16
(
p
ayload
[
3
],
p
ayload
[
4
]);
unsigned
short
ms
=
BUILD_UINT16
(
msgP
ayload
[
3
],
msgP
ayload
[
4
]);
if
(
ms
>
999
)
{
ms
=
0
;
}
gps
.
Datas
.
dateOfFix
.
year
=
p
ayload
[
7
];
gpsDatas
.
dateOfFix
.
month
=
p
ayload
[
6
];
gpsDatas
.
dateOfFix
.
day
=
p
ayload
[
5
];
gpsDatas
.
dateOfFix
.
hour
=
p
ayload
[
0
];
gpsDatas
.
dateOfFix
.
minute
=
p
ayload
[
1
];
gpsDatas
.
dateOfFix
.
second
=
p
ayload
[
2
];
gpsDatas
.
fix
=
p
ayload
[
8
]
!=
0
;
gpsDatas
.
fixQuality
=
p
ayload
[
9
];
gpsDatas
.
latitude
=
GetFloatSafe
(
p
ayload
.
data
()
,
10
);
gpsDatas
.
latitudeDirection
=
static_cast
<
char
>
(
p
ayload
[
14
]);
gpsDatas
.
longitude
=
GetFloatSafe
(
p
ayload
.
data
()
,
15
);
gpsDatas
.
longitudeDirection
=
static_cast
<
char
>
(
p
ayload
[
19
]);
gpsDatas
.
speed
=
GetFloatSafe
(
p
ayload
.
data
()
,
20
);
gpsDatas
.
angle
=
GetFloatSafe
(
p
ayload
.
data
()
,
24
);
gpsDatas
.
altitude
=
GetFloatSafe
(
p
ayload
.
data
()
,
28
);
gpsDatas
.
satellites
=
p
ayload
[
32
];
gpsDatas
.
antenna
=
p
ayload
[
33
];
gpsDatas
.
dateOfFix
.
year
=
msgP
ayload
[
7
];
gpsDatas
.
dateOfFix
.
month
=
msgP
ayload
[
6
];
gpsDatas
.
dateOfFix
.
day
=
msgP
ayload
[
5
];
gpsDatas
.
dateOfFix
.
hour
=
msgP
ayload
[
0
];
gpsDatas
.
dateOfFix
.
minute
=
msgP
ayload
[
1
];
gpsDatas
.
dateOfFix
.
second
=
msgP
ayload
[
2
];
gpsDatas
.
fix
=
msgP
ayload
[
8
]
!=
0
;
gpsDatas
.
fixQuality
=
msgP
ayload
[
9
];
gpsDatas
.
latitude
=
GetFloatSafe
(
msgP
ayload
,
10
);
gpsDatas
.
latitudeDirection
=
static_cast
<
char
>
(
msgP
ayload
[
14
]);
gpsDatas
.
longitude
=
GetFloatSafe
(
msgP
ayload
,
15
);
gpsDatas
.
longitudeDirection
=
static_cast
<
char
>
(
msgP
ayload
[
19
]);
gpsDatas
.
speed
=
GetFloatSafe
(
msgP
ayload
,
20
);
gpsDatas
.
angle
=
GetFloatSafe
(
msgP
ayload
,
24
);
gpsDatas
.
altitude
=
GetFloatSafe
(
msgP
ayload
,
28
);
gpsDatas
.
satellites
=
msgP
ayload
[
32
];
gpsDatas
.
antenna
=
msgP
ayload
[
33
];
if
(
lastGPSDate
.
year
!=
gpsDatas
.
dateOfFix
.
year
||
lastGPSDate
.
month
!=
gpsDatas
.
dateOfFix
.
month
||
lastGPSDate
.
day
!=
gpsDatas
.
dateOfFix
.
day
||
lastGPSDate
.
hour
!=
gpsDatas
.
dateOfFix
.
hour
||
lastGPSDate
.
minute
!=
gpsDatas
.
dateOfFix
.
minute
||
lastGPSDate
.
second
!=
gpsDatas
.
dateOfFix
.
second
)
:
{
lastGPSDate
.
hour
!=
gpsDatas
.
dateOfFix
.
hour
||
lastGPSDate
.
minute
!=
gpsDatas
.
dateOfFix
.
minute
||
lastGPSDate
.
second
!=
gpsDatas
.
dateOfFix
.
second
)
{
lastGPSDate
=
gpsDatas
.
dateOfFix
;
outfile
<<
"GPS, "
<<
gpsDatas
.
dateOfFix
.
year
;
outfile
<<
"/"
<<
gpsDatas
.
dateOfFix
.
month
;
...
...
@@ -460,12 +454,12 @@ void IMUFileWriter::ProcessDecodedMessage(int msgFunction, int msgPayloadLength,
}
break
;
case
static_cast
<
short
>
(
GPS_PPS_PACKET
):
{
uint64_t
PPSTimeStamp
=
BUILD_UINT64
(
p
ayload
[
7
],
p
ayload
[
6
],
p
ayload
[
5
],
p
ayload
[
4
],
p
ayload
[
3
],
p
ayload
[
2
],
p
ayload
[
1
],
p
ayload
[
0
]);
uint64_t
PPSTimeStamp
=
BUILD_UINT64
(
msgP
ayload
[
7
],
msgP
ayload
[
6
],
msgP
ayload
[
5
],
msgP
ayload
[
4
],
msgP
ayload
[
3
],
msgP
ayload
[
2
],
msgP
ayload
[
1
],
msgP
ayload
[
0
]);
PPSTimeStamp
*=
10
;
// Convert to nanoseconds (assuming internal clock frequency is 100MHz)
if
(
PPSTimeStamp
>
lastPPSTimeStampNS
)
:
{
if
(
PPSTimeStamp
>
lastPPSTimeStampNS
)
{
lastPPSTimeStampNS
=
PPSTimeStamp
;
outfile
<<
"PPS: "
<<
PPSTimeStamp
;
outfile
<<
std
::
endl
;
...
...
@@ -480,12 +474,12 @@ void IMUFileWriter::write(uint8_t *sample, size_t size, uint8_t *imu_data) {
uint8_t
*
imu_data_cur
(
imu_data
);
while
(
imu_data_cur
+
frame_size
+
5
<
imu_data
+
additional_data_size
){
softwareMajorRev
=
sample
[
5
];
softwareMinorRev
=
sample
[
6
];
uint8_t
softwareMajorRev
=
sample
[
5
];
uint8_t
softwareMinorRev
=
sample
[
6
];
if
(
softwareMajorRev
>=
2
)
{
//On recupere l'instant de fin du paquet courant
timeStamp100MHzCurrentPacket
=
BUILD_UINT64
(
sample
[
14
],
uint64_t
timeStamp100MHzCurrentPacket
=
BUILD_UINT64
(
sample
[
14
],
sample
[
13
],
sample
[
12
],
sample
[
11
],
...
...
@@ -494,9 +488,9 @@ void IMUFileWriter::write(uint8_t *sample, size_t size, uint8_t *imu_data) {
sample
[
8
],
sample
[
7
]);
timeStamp100MHzCurrentPacket
*=
10
;
//To put the ts in ns
enteteSize
=
16
;
uint8_t
enteteSize
=
16
;
for
(
int
i
=
enteteSize
;
i
<
hdr
.
sizeOfAdditionnalDataBuffer
-
enteteSize
;
i
++
)
for
(
int
i
=
enteteSize
;
i
<
size
-
enteteSize
;
i
++
)
{
DecodeMessage
(
sample
[
i
]);
}
...
...
This diff is collapsed.
Click to expand it.
src/filewriter.h
+
8
−
9
View file @
c54e21e6
...
...
@@ -197,13 +197,13 @@ private:
double
lastPPSTimeStampNS
;
enum
class
StateReception
{
Waiting
;
FunctionMSB
;
FunctionLSB
;
PayloadLengthMSB
;
PayloadLengthLSB
;
Payload
;
CheckSum
;
Waiting
,
FunctionMSB
,
FunctionLSB
,
PayloadLengthMSB
,
PayloadLengthLSB
,
Payload
,
CheckSum
};
StateReception
rcvState
;
...
...
@@ -233,14 +233,13 @@ public:
* that will be written to a file before starting the next one.
*/
unsigned
char
CalculateChecksum
(
int
msgFunction
,
int
msgPayloadLength
,
unsigned
char
msgPayload
[]);
int
msgPayloadLength
,
const
unsigned
char
msgPayload
[]);
void
DecodeMessage
(
unsigned
char
c
);
IMUFileWriter
(
std
::
string
&
filename_template
,
size_t
num_channels
,
size_t
sample_rate
,
size_t
depth
,
size_t
timestamp
);
~
IMUFileWriter
();
void
write
(
uint8_t
*
samples
,
size_t
num_samples
,
uint8_t
*
imu_data
)
override
;
size_t
get_last_timestamp
();
float
GetFloatSafe
(
const
unsigned
char
*
p
,
int
index
);
};
/** Class for writing sample data to a sequence of PCM WAVE files, split up to
...
...
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