Commit 050f4d8f authored by Your Name's avatar Your Name
Browse files

.

parent 74b6617a
No preview for this file type
......@@ -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,100000);
start_periodic_timer(1000000,sample_interval_ms*1000);
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);
}
}
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment