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
0348180f
Commit
0348180f
authored
7 months ago
by
Philemon Prevot
Browse files
Options
Downloads
Patches
Plain Diff
Add sensors set-up trames encoding
parent
355429b0
No related branches found
No related tags found
1 merge request
!2
HighBlueParser dev branch merged to empty main branch
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/recorder.cpp
+79
-3
79 additions, 3 deletions
src/recorder.cpp
src/recorder.h
+9
-1
9 additions, 1 deletion
src/recorder.h
with
88 additions
and
4 deletions
src/recorder.cpp
+
79
−
3
View file @
0348180f
...
...
@@ -114,8 +114,16 @@ void JasonRecorder::send_message(std::uint16_t cmd, std::uint8_t *payload, size_
};
}
void
JasonRecorder
::
start_recording
(
std
::
uint8_t
num_channels
,
size_t
sample_rate
,
std
::
uint8_t
depth
,
std
::
uint8_t
num_filter
)
{
std
::
vector
<
std
::
uint8_t
>
payload1
=
{
void
JasonRecorder
::
getBytesFromFloat
(
std
::
array
<
unsigned
char
,
4
>
&
p
,
float
f
)
{
unsigned
char
*
f_ptr
=
reinterpret_cast
<
unsigned
char
*>
(
&
f
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
p
[
i
]
=
f_ptr
[
i
];
}
}
void
JasonRecorder
::
start_recording
(
int
qhb_version
,
std
::
uint8_t
num_channels
,
size_t
sample_rate
,
std
::
uint8_t
depth
,
std
::
uint8_t
num_filter
,
size_t
accelSamplingRate
,
size_t
gyroSamplingRate
,
size_t
magSamplingRate
,
size_t
accelRangeScale
,
size_t
gyroRangeScale
,
size_t
magRangeScale
)
{
if
(
qhb_version
==
2
)
{
std
::
vector
<
std
::
uint8_t
>
payload1
=
{
START
,
(
std
::
uint8_t
)
((
sample_rate
>>
24
)
&
0xFF
),
(
std
::
uint8_t
)
((
sample_rate
>>
16
)
&
0xFF
),
...
...
@@ -124,7 +132,75 @@ void JasonRecorder::start_recording(std::uint8_t num_channels,size_t sample_rat
num_channels
,
(
std
::
uint8_t
)
(
8
*
depth
),
num_filter
};
send_message
(
START_ID
,
payload1
);
send_message
(
START_ID
,
payload1
);
}
else
if
(
qhb_version
==
3
)
{
std
::
array
<
unsigned
char
,
4
>
accelSamplingRateBytes
=
{
0
};
std
::
array
<
unsigned
char
,
4
>
accelRangeScaleBytes
=
{
0
};
getBytesFromFloat
(
accelSamplingRateBytes
,
accelSamplingRate
);
getBytesFromFloat
(
accelRangeScaleBytes
,
accelRangeScale
);
std
::
vector
<
std
::
uint8_t
>
payload2
=
{
(
std
::
uint8_t
)
(
0x01
),
(
std
::
uint8_t
)
(
0x00
),
(
std
::
uint8_t
)
(
accelRangeScaleBytes
[
0
]),
(
std
::
uint8_t
)
(
accelRangeScaleBytes
[
1
]),
(
std
::
uint8_t
)
(
accelRangeScaleBytes
[
2
]),
(
std
::
uint8_t
)
(
accelRangeScaleBytes
[
3
]),
(
std
::
uint8_t
)
(
accelSamplingRateBytes
[
0
]),
(
std
::
uint8_t
)
(
accelSamplingRateBytes
[
1
]),
(
std
::
uint8_t
)
(
accelSamplingRateBytes
[
2
]),
(
std
::
uint8_t
)
(
accelSamplingRateBytes
[
3
])
};
send_message
(
SET_SENSOR
,
payload2
);
std
::
array
<
unsigned
char
,
4
>
gyroSamplingRateBytes
=
{
0
};
std
::
array
<
unsigned
char
,
4
>
gyroRangeScaleBytes
=
{
0
};
getBytesFromFloat
(
gyroSamplingRateBytes
,
gyroSamplingRate
);
getBytesFromFloat
(
gyroRangeScaleBytes
,
gyroRangeScale
);
std
::
vector
<
std
::
uint8_t
>
payload3
=
{
(
std
::
uint8_t
)
(
0x02
),
(
std
::
uint8_t
)
(
0x00
),
(
std
::
uint8_t
)
(
gyroRangeScaleBytes
[
0
]),
(
std
::
uint8_t
)
(
gyroRangeScaleBytes
[
1
]),
(
std
::
uint8_t
)
(
gyroRangeScaleBytes
[
2
]),
(
std
::
uint8_t
)
(
gyroRangeScaleBytes
[
3
]),
(
std
::
uint8_t
)
(
gyroSamplingRateBytes
[
0
]),
(
std
::
uint8_t
)
(
gyroSamplingRateBytes
[
1
]),
(
std
::
uint8_t
)
(
gyroSamplingRateBytes
[
2
]),
(
std
::
uint8_t
)
(
gyroSamplingRateBytes
[
3
])
};
send_message
(
SET_SENSOR
,
payload3
);
std
::
array
<
unsigned
char
,
4
>
magSamplingRateBytes
=
{
0
};
std
::
array
<
unsigned
char
,
4
>
magRangeScaleBytes
=
{
0
};
getBytesFromFloat
(
magSamplingRateBytes
,
magSamplingRate
);
getBytesFromFloat
(
magRangeScaleBytes
,
magRangeScale
);
std
::
vector
<
uint8_t
>
payload4
{
(
std
::
uint8_t
)
(
0x03
),
(
std
::
uint8_t
)
(
0x00
),
(
std
::
uint8_t
)
(
magRangeScaleBytes
[
0
]),
(
std
::
uint8_t
)
(
magRangeScaleBytes
[
1
]),
(
std
::
uint8_t
)
(
magRangeScaleBytes
[
2
]),
(
std
::
uint8_t
)
(
magRangeScaleBytes
[
3
]),
(
std
::
uint8_t
)
(
magSamplingRateBytes
[
0
]),
(
std
::
uint8_t
)
(
magSamplingRateBytes
[
1
]),
(
std
::
uint8_t
)
(
magSamplingRateBytes
[
2
]),
(
std
::
uint8_t
)
(
magSamplingRateBytes
[
3
])
};
send_message
(
SET_SENSOR
,
payload4
);
std
::
vector
<
std
::
uint8_t
>
payload1
=
{
START
,
(
std
::
uint8_t
)
((
sample_rate
>>
24
)
&
0xFF
),
(
std
::
uint8_t
)
((
sample_rate
>>
16
)
&
0xFF
),
(
std
::
uint8_t
)
((
sample_rate
>>
8
)
&
0xFF
),
(
std
::
uint8_t
)
(
sample_rate
&
0xFF
),
num_channels
,
(
std
::
uint8_t
)
(
8
*
depth
),
num_filter
};
send_message
(
START_ID
,
payload1
);
}
this
->
num_channels
=
num_channels
;
this
->
sample_rate
=
sample_rate
;
this
->
depth
=
depth
;
...
...
This diff is collapsed.
Click to expand it.
src/recorder.h
+
9
−
1
View file @
0348180f
...
...
@@ -11,6 +11,7 @@
#include
<libusb.h>
#include
<cstdint>
#include
<vector>
#include
<array>
#define MAX_MSG_LENGTH 65536
...
...
@@ -27,6 +28,7 @@ class JasonRecorder {
// device control messages
const
std
::
uint8_t
FRAME_START
=
0xFE
;
const
std
::
uint16_t
START_ID
=
0x0C01
;
const
std
::
uint16_t
SET_SENSOR
=
0x0C09
;
const
std
::
uint16_t
SET_CLOCK_ID
=
0x0C06
;
const
std
::
uint16_t
DATA_ID
=
0x0B01
;
const
std
::
uint16_t
STATUS_ID
=
0x0B02
;
...
...
@@ -53,6 +55,12 @@ private:
* \param[in] length The size of the payload data in bytes.
*/
void
send_message
(
std
::
uint16_t
cmd
,
std
::
uint8_t
*
payload
,
size_t
length
);
/** Transform a float32 into an array of bytes.
* \param[in] p A pointer to the array where the bytes of the float will be stored.
* \param[in] index The starting position in the array `p` where the first byte will be stored.
* \param[in] f The float value from which the bytes will be extracted.
*/
void
getBytesFromFloat
(
std
::
array
<
unsigned
char
,
4
>
&
p
,
float
f
);
// device messages sent back
/** Reads a message from the device. Waits for a message if necessary.
...
...
@@ -90,7 +98,7 @@ public:
* \param[in] depth The number of bytes of each sample.
* \param[in] num_filter The filter number (between 0 and 2).
*/
void
start_recording
(
std
::
uint8_t
num_channels
,
size_t
sample_rate
,
std
::
uint8_t
depth
,
std
::
uint8_t
num_filter
);
void
start_recording
(
int
qhb_version
,
std
::
uint8_t
num_channels
,
size_t
sample_rate
,
std
::
uint8_t
depth
,
std
::
uint8_t
num_filter
,
size_t
accelSamplingRate
,
size_t
gyroSamplingRate
,
size_t
magSamplingRate
,
size_t
accelRangeScale
,
size_t
gyroRangeScale
,
size_t
magRangeScale
);
/** Stops recording from the device chosen with set_device(). */
void
stop_recording
();
/** Fetches a messages from the device chosen with set_device().
...
...
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