Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Biophysics Labs
Firmware
Commits
050f4d8f
Commit
050f4d8f
authored
Jul 31, 2020
by
Your Name
Browse files
.
parent
74b6617a
Changes
3
Hide whitespace changes
Inline
Side-by-side
lsllidar/lsllidar
View file @
050f4d8f
No preview for this file type
lsllidar/lsllidar.cc
View file @
050f4d8f
...
...
@@ -25,12 +25,15 @@ string info_name, info_type, info_sourceid;
static
int
verbose
=
0
;
int
sample_interval_ms
=
100
;
void
parse_options
(
int
argc
,
const
char
*
argv
[])
{
namespace
po
=
boost
::
program_options
;
// Declare the supported options.
po
::
options_description
desc
(
"Usage:"
);
desc
.
add_options
()(
"help,h"
,
"show this message"
)(
"sample-interval,i"
,
po
::
value
<
int
>
(),
"set the sample interval of the lidar sensor (in milliseconds)"
)(
"lsl-name"
,
po
::
value
<
string
>
(),
"set the name of the LSL stream"
)(
"lsl-type"
,
po
::
value
<
string
>
(),
"set the type of the LSL stream"
)(
"lsl-sourceid"
,
po
::
value
<
string
>
(),
...
...
@@ -50,6 +53,13 @@ void parse_options(int argc, const char *argv[]) {
verbose
=
1
;
}
if
(
vm
.
count
(
"sample-interval"
))
{
sample_interval_ms
=
vm
[
"sample-interval"
].
as
<
int
>
();
}
if
(
verbose
)
cout
<<
"sample interval is: "
<<
sample_interval_ms
<<
" ms"
<<
endl
;
if
(
vm
.
count
(
"lsl-name"
))
info_name
=
vm
[
"lsl-name"
].
as
<
string
>
();
else
...
...
@@ -150,11 +160,11 @@ int main(int argc, const char *argv[])
// make a new stream_info and open an outlet with it
stream_info
info
(
info_name
.
c_str
(),
info_type
.
c_str
(),
1
,
lsl
::
IRREGULAR_RATE
,
lsl
::
cf_
int16
,
lsl
::
IRREGULAR_RATE
,
lsl
::
cf_
double64
,
info_sourceid
.
c_str
());
outlet
=
new
stream_outlet
(
info
);
start_periodic_timer
(
1000000
,
100
000
);
start_periodic_timer
(
1000000
,
sample_interval_ms
*
1
000
);
while
(
1
)
{
...
...
@@ -165,11 +175,12 @@ int main(int argc, const char *argv[])
if
(
busyFlag
!=
0x00
)
continue
;
int16_t
distance
;
double
distance
;
myLidarLite
.
takeRange
();
distance
=
myLidarLite
.
readDistance
();
distance
=
double
(
myLidarLite
.
readDistance
()
)
/
100
;
outlet
->
push_sample
(
&
distance
);
printf
(
"%4d
\n
"
,
distance
);
if
(
verbose
)
printf
(
"%.2f
\n
"
,
distance
);
}
}
lsllidar/lsllidar.o
View file @
050f4d8f
No preview for this file type
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment