Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LidarLite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
labrobotica
drivers
LidarLite
Commits
a997b16d
Commit
a997b16d
authored
8 years ago
by
Angel Santamaria-Navarro
Browse files
Options
Downloads
Patches
Plain Diff
Driver version
parent
5dc46c3d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ReadMe.md
+3
-3
3 additions, 3 deletions
ReadMe.md
src/lidar_lite.cpp
+42
-9
42 additions, 9 deletions
src/lidar_lite.cpp
src/lidar_lite.h
+2
-0
2 additions, 0 deletions
src/lidar_lite.h
with
47 additions
and
12 deletions
ReadMe.md
+
3
−
3
View file @
a997b16d
...
@@ -16,17 +16,17 @@ For detailed specifications, pinout, and connection diagrams, please refer to th
...
@@ -16,17 +16,17 @@ For detailed specifications, pinout, and connection diagrams, please refer to th
-
[
iriutils
](
https://devel.iri.upc.edu/pub/labrobotica/drivers/iriutils/trunk
)
- IRI C++ library
-
[
iriutils
](
https://devel.iri.upc.edu/pub/labrobotica/drivers/iriutils/trunk
)
- IRI C++ library
-
Download the library:
`svn co https://devel.iri.upc.edu/pub/labrobotica/drivers/iriutils/trunk comm`
-
Download the library:
`svn co https://devel.iri.upc.edu/pub/labrobotica/drivers/iriutils/trunk comm`
-
Compile and install:
`cd iriutils/build && cmake .. && make && sudo make install`
-
Compile and install:
`cd iriutils/build && cmake
-D CMAKE_BUILD_TYPE=RELEASE
.. && make && sudo make install`
-
[
comm
](
https://devel.iri.upc.edu/pub/labrobotica/drivers/comm/trunk
)
- IRI C++ library
-
[
comm
](
https://devel.iri.upc.edu/pub/labrobotica/drivers/comm/trunk
)
- IRI C++ library
-
Download the library:
`svn co https://devel.iri.upc.edu/pub/labrobotica/drivers/comm/trunk comm`
-
Download the library:
`svn co https://devel.iri.upc.edu/pub/labrobotica/drivers/comm/trunk comm`
-
Compile and install:
`cd comm/build && cmake .. && make && sudo make install`
-
Compile and install:
`cd comm/build && cmake
-D CMAKE_BUILD_TYPE=RELEASE
.. && make && sudo make install`
-
[
usb_i2c_adapter
](
https://devel.iri.upc.edu/pub/labrobotica/drivers/usb_i2c_adapter/trunk
)
- IRI C++ library
-
[
usb_i2c_adapter
](
https://devel.iri.upc.edu/pub/labrobotica/drivers/usb_i2c_adapter/trunk
)
- IRI C++ library
-
Download the library:
`svn co https://devel.iri.upc.edu/pub/labrobotica/drivers/usb_i2c_adapter/trunk usb_i2c_adapter`
-
Download the library:
`svn co https://devel.iri.upc.edu/pub/labrobotica/drivers/usb_i2c_adapter/trunk usb_i2c_adapter`
-
Compile and install:
`cd usb_i2c_adapter/build && cmake .. && make && sudo make install`
-
Compile and install:
`cd usb_i2c_adapter/build && cmake
-D CMAKE_BUILD_TYPE=RELEASE
.. && make && sudo make install`
### Example of usage
### Example of usage
...
...
This diff is collapsed.
Click to expand it.
src/lidar_lite.cpp
+
42
−
9
View file @
a997b16d
#include
"lidar_lite.h"
#include
"lidar_lite.h"
#include
<exceptions/lidar_lite_exceptions.h>
#include
<exceptions/lidar_lite_exceptions.h>
#include
<ctime.h>
//******************************************************************************
//******************************************************************************
// PUBLIC API
// PUBLIC API
//******************************************************************************
//******************************************************************************
...
@@ -26,7 +28,10 @@ CLidarLite::CLidarLite(const std::string &serial, const int config)
...
@@ -26,7 +28,10 @@ CLidarLite::CLidarLite(const std::string &serial, const int config)
CLidarLite
::~
CLidarLite
(
void
)
CLidarLite
::~
CLidarLite
(
void
)
{
{
if
(
this
->
status_
==
RUNNING
)
if
(
this
->
status_
==
RUNNING
)
{
reset
();
close
();
close
();
}
}
}
void
CLidarLite
::
open
(
void
)
void
CLidarLite
::
open
(
void
)
...
@@ -105,8 +110,6 @@ int CLidarLite::get_range(bool biasCorrection)
...
@@ -105,8 +110,6 @@ int CLidarLite::get_range(bool biasCorrection)
if
(
this
->
status_
!=
RUNNING
)
if
(
this
->
status_
!=
RUNNING
)
throw
CLidarLiteException
(
_HERE_
,
"RANGE MEASUREMENT cannot be obtained because the device is not running."
);
throw
CLidarLiteException
(
_HERE_
,
"RANGE MEASUREMENT cannot be obtained because the device is not running."
);
int
range
=
NAN
;
// Initiate an aquisition.
// Initiate an aquisition.
if
(
biasCorrection
||
this
->
max_unbiases_meas_
>
99
)
if
(
biasCorrection
||
this
->
max_unbiases_meas_
>
99
)
{
{
...
@@ -121,13 +124,8 @@ int CLidarLite::get_range(bool biasCorrection)
...
@@ -121,13 +124,8 @@ int CLidarLite::get_range(bool biasCorrection)
++
this
->
max_unbiases_meas_
;
++
this
->
max_unbiases_meas_
;
}
}
// Read STATUS. Repeat until bit 0 (LSB) goes low.
unsigned
char
busy
;
do
busy
=
read
(
STATUS
,
1
);
while
(
busy
&
0x01
);
// Read two bytes from register 0x8f and save
// Read two bytes from register 0x8f and save
int
range
=
NAN
;
range
=
read
(
FULL_DELAY_HIGH
,
2
);
range
=
read
(
FULL_DELAY_HIGH
,
2
);
return
range
;
return
range
;
...
@@ -191,6 +189,10 @@ int CLidarLite::read(unsigned char addr, int len)
...
@@ -191,6 +189,10 @@ int CLidarLite::read(unsigned char addr, int len)
if
(
len
==
2
)
if
(
len
==
2
)
addr
=
addr_to_read_2bytes
(
addr
);
// See header file for a description of this functionality.
addr
=
addr_to_read_2bytes
(
addr
);
// See header file for a description of this functionality.
// Read STATUS. Repeat until bit 0 (LSB) goes low.
// wait_busy();
// NOTE: Commented because using this USB adapter the following write actions are slower than usual busy time.
unsigned
char
data
[
len
];
unsigned
char
data
[
len
];
try
{
try
{
this
->
adapter_
->
write
(
DEVICE_ID
,
&
addr
,
1
);
this
->
adapter_
->
write
(
DEVICE_ID
,
&
addr
,
1
);
...
@@ -209,10 +211,41 @@ int CLidarLite::read(unsigned char addr, int len)
...
@@ -209,10 +211,41 @@ int CLidarLite::read(unsigned char addr, int len)
unsigned
short
int
read_val
=
data
[
0
]
*
256
+
data
[
1
];
unsigned
short
int
read_val
=
data
[
0
]
*
256
+
data
[
1
];
val
=
(
int
)
read_val
;
val
=
(
int
)
read_val
;
}
}
return
val
;
return
val
;
}
}
void
CLidarLite
::
wait_busy
(
void
)
{
try
{
unsigned
char
addr
=
STATUS
;
this
->
adapter_
->
write
(
DEVICE_ID
,
&
addr
,
1
);
}
catch
(
CException
&
e
)
{
throw
CLidarLiteException
(
_HERE_
,
e
.
what
());
}
bool
busy
=
true
;
int
busyCounter
=
0
;
try
{
while
(
busy
)
{
unsigned
char
data
;
this
->
adapter_
->
read
(
DEVICE_ID
,
&
data
,
1
);
busy
=
data
&
0x01
;
busyCounter
++
;
// Increment busyCounter for timeout
// Handle timeout condition, exit while loop and goto bailout
if
(
busyCounter
>
99
)
break
;
}
}
catch
(
CException
&
e
)
{
throw
CLidarLiteException
(
_HERE_
,
e
.
what
());
}
}
unsigned
short
int
CLidarLite
::
addr_to_read_2bytes
(
unsigned
char
first_byte_addr
)
unsigned
short
int
CLidarLite
::
addr_to_read_2bytes
(
unsigned
char
first_byte_addr
)
{
{
unsigned
short
int
val
=
(
0x01
<<
7
)
|
first_byte_addr
;
unsigned
short
int
val
=
(
0x01
<<
7
)
|
first_byte_addr
;
...
...
This diff is collapsed.
Click to expand it.
src/lidar_lite.h
+
2
−
0
View file @
a997b16d
...
@@ -119,6 +119,8 @@ class CLidarLite
...
@@ -119,6 +119,8 @@ class CLidarLite
*/
*/
void
config_dev
(
void
);
void
config_dev
(
void
);
void
wait_busy
(
void
);
public:
public:
/**
/**
...
...
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