Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Simulator added and vcpkg support optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1309 committed Apr 1, 2021
1 parent 9fbca7d commit 9e0e0cd
Show file tree
Hide file tree
Showing 32 changed files with 24,642 additions and 6,899 deletions.
114 changes: 60 additions & 54 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,54 +1,60 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

\.idea/

CMakeFiles/3\.10\.2/

CMakeFiles/3\.12\.1/

CMakeCache\.txt

CMakeFiles/

sick_scan_base\.cbp

cmake_install\.cmake

Makefile

sick_generic_caller
scan.jpg
scan_tmp.jpg

build/
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

\.idea/

CMakeFiles/3\.10\.2/

CMakeFiles/3\.12\.1/

CMakeCache\.txt

CMakeFiles/

sick_scan_base\.cbp

cmake_install\.cmake

Makefile

sick_generic_caller
scan.jpg
scan_tmp.jpg

build/
build_x64/

sick_scan_base_vs.code-workspace
test/emulator/scandata/20210302_lms511.pcapng.json

.vscode/
29 changes: 16 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ macro(dump_all)
endmacro()

if(WIN32)
FIND_PACKAGE (Boost REQUIRED)
FIND_PACKAGE (pthread REQUIRED)
# dump_all()
FIND_PACKAGE (Boost REQUIRED)
# FIND_PACKAGE (pthread REQUIRED) # pthread is found via boost
# dump_all()
endif()

find_package(Boost COMPONENTS system filesystem thread REQUIRED)
include_directories (${Boost_INCLUDE_DIR})

add_definitions(-DHAVE_STRUCT_TIMESPEC -DROSSIMU)
add_definitions(-DROSSIMU)
# add_definitions(-DHAVE_STRUCT_TIMESPEC -DROSSIMU)

if(WIN32)
# include_directories(roswrap/pthread_win/pthreads-w32-2-9-1-release/pthreads.2 roswrap/helper_win ./include ./include/tinyxml ./include/sick_scan ${Boost_INCLUDE_DIRS} roswrap/src/include roswrap/src/rossimu/kinetic/include roswrap/src/cfgsimu roswrap/src/toojpeg )
include_directories(roswrap/helper_win ./include ./include/tinyxml ./include/sick_scan ${Boost_INCLUDE_DIRS} roswrap/src/include roswrap/src/rossimu/kinetic/include roswrap/src/cfgsimu roswrap/src/toojpeg )
# include_directories(roswrap/pthread_win/pthreads-w32-2-9-1-release/pthreads.2 roswrap/helper_win ./include ./include/tinyxml ./include/sick_scan ${Boost_INCLUDE_DIRS} roswrap/src/include roswrap/src/rossimu/kinetic/include roswrap/src/cfgsimu roswrap/src/toojpeg )
include_directories(roswrap/helper_win ./include ./include/tinyxml ./include/sick_scan ${Boost_INCLUDE_DIRS} roswrap/src/include roswrap/src/rossimu/kinetic/include roswrap/src/cfgsimu roswrap/src/toojpeg )
else()
include_directories(./include/sick_scan ./include ./include/tinyxml ../include/sick_scan ${Boost_INCLUDE_DIRS} roswrap/src/include roswrap/src/rossimu/kinetic/include roswrap/src/cfgsimu roswrap/src/toojpeg)
include_directories(./include/sick_scan ./include ./include/tinyxml ../include/sick_scan ${Boost_INCLUDE_DIRS} roswrap/src/include roswrap/src/rossimu/kinetic/include roswrap/src/cfgsimu roswrap/src/toojpeg)
endif()


Expand All @@ -45,7 +46,6 @@ else()
file(GLOB SRC_WIN_FILES )
endif()
add_executable(sick_generic_caller

roswrap/src/cfgsimu/sick_scan/time_modi.cpp
roswrap/src/rossimu/kinetic/src/rossimu.cpp
roswrap/src/rossimu/kinetic/src/duration.cpp
Expand Down Expand Up @@ -85,13 +85,16 @@ add_executable(sick_generic_caller
driver/src/helper/angle_compensator.cpp
roswrap/src/launchparser/launchparser.cpp roswrap/src/include/launchparser/launchparser.h
${SRC_WIN_FILES}
)
)

if(WIN32)
message("### Compiled for Windows")
message(STATUS "PTHREAD: " ${PThreads_windows_LIBRARY})
target_link_libraries(sick_generic_caller ${Boost_LIBRARIES} ${PThreads_windows_LIBRARY})
message("### Compiled for Windows")
message(STATUS "PTHREAD: " ${PThreads_windows_LIBRARY})
target_link_libraries(sick_generic_caller ${Boost_LIBRARIES} ${PThreads_windows_LIBRARY})
else()
target_link_libraries(sick_generic_caller ${Boost_LIBRARIES} pthread)
target_link_libraries(sick_generic_caller ${Boost_LIBRARIES} pthread)
endif()

add_custom_target(python_test_server
SOURCES test/emulator/test_server.py
)
113 changes: 99 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,72 @@ This driver should work with all of the following products.
| | | Scan-Rate: 600 Hz | |
## Installation

To install, follow the steps below:
### Windows installation

To install sick_scan_base on Windows, follow the steps below:

1. If not yet done, install Visual Studio. Visual Studio 2019 Community or Professional Edition is recommended.

2. If not yet done, install boost and pthread using Visual Studios package manager vcpkg:
* Install vcpkg:
* Download vcpkg-master.zip from https://github.com/microsoft/vcpkg/archive/master.zip and unzip to `c:\vcpkg`. Alternatively, run "git clone https://github.com/microsoft/vcpkg"
* Install vcpkg by running the following commands:
```
cd c:/vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
```
* Install required packages:
```
vcpkg.exe install pthread:x86-windows
vcpkg.exe install pthread:x64-windows
vcpkg.exe install boost:x64-windows
```
* Include vcpkg in your path:
```
set PATH=c:\vcpkg\installed\x64-windows\bin;%PATH%
```
3. Clone repository https://github.com/SICKAG/sick_scan_base:
```
git clone https://github.com/SICKAG/sick_scan_base.git
```
1. clone repository
```console
git clone https://github.com/SICKAG/sick_scan_base.git
```
2. create Makefile by using cmake
```console
cd sick_scan_base
cmake .
```
3. compile the software
4. Build sick_generic_caller with cmake and Visual Studio 2019:
```
cd sick_scan_base
set _os=x64
set _cmake_string=Visual Studio 16 2019
set _msvc=Visual Studio 2019
set _cmake_build_dir=build
if not exist %_cmake_build_dir% mkdir %_cmake_build_dir%
pushd %_cmake_build_dir%
cmake -G "%_cmake_string%" ..
popd
```
Open file `build\sick_scan_base.sln` in Visual Studio and build all targets (shortcut F7).
```console
make
```
### Ubuntu installation
To install on Ubuntu, follow the steps below:
1. Clone repository https://github.com/SICKAG/sick_scan_base:
```console
git clone https://github.com/SICKAG/sick_scan_base.git
```

2. Build sick_generic_caller by using cmake
```console
cd sick_scan_base
mkdir -p ./build
cd ./build
cmake -G "Unix Makefiles" ..
```

3. Compile the software and build sick_generic_caller:
```console
make
```

## Running

Expand Down Expand Up @@ -96,6 +143,44 @@ This driver supports the following x86-based operating systems:
* Ubuntu 18.04 with gcc
* Windows 10 with Visual Studio Compiler (VS2017, VS2019)

## Simulation

For unittests without sensor hardware, a LMS511 device can be simulated using the python script `test/emulator/test_server.py`. This script implements a simple tcp server for test purposes. It opens a listening tcp socket, connects to tcp clients, receives cola telegrams and sends predefined responses to the client.

Please note that this is just a simple test server for basic unittests of sick_scan_base drivers. It does not emulate any real lidar sensors!

### Simulation on Windows

Run script `run_simu_lms_5xx.cmd` in folder `test/scripts` or execute the following commands:

```
REM Start test server
cd .\build
start "testserver" python ../test/emulator/test_server.py --scandata_file=../test/emulator/scandata/20210302_lms511.pcapng.scandata.txt --scandata_frequency=20.0 --tcp_port=2112
@timeout /t 1
REM Run sick_generic_caller
.\Debug\sick_generic_caller.exe ../launch/sick_lms_5xx.launch hostname:=127.0.0.1
```

Open file `image_viewer.html` in folder `demo` in your browser to view a jpg-image of the current scan.

Note, that python version 3 incl. runtime dlls must be accessable, f.e. by extending the PATH environment variable:
```
set PYTHON_DIR=%ProgramFiles(x86)%/Microsoft Visual Studio/Shared/Python37_64
set PATH=%PYTHON_DIR%;%PYTHON_DIR%/Scripts;c:\vcpkg\installed\x64-windows\bin;%PATH%
```

### Simulation on Linux

Run script `run_simu_lms_5xx.bash` in folder `test/scripts` or execute the following commands:

```
python3 ./test/emulator/test_server.py --scandata_file=./test/emulator/scandata/20210302_lms511.pcapng.scandata.txt --scandata_frequency=20.0 --tcp_port=2112 &
sleep 1
./build_x64/sick_generic_caller ./launch/sick_lms_5xx.launch hostname:=127.0.0.1 &
```

Open file `image_viewer.html` in folder `demo` in a browser (f.e. firefox) to view a jpg-image of the current scan.

## Keywords

Expand Down
30 changes: 15 additions & 15 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
set vcpkg=-DCMAKE_TOOLCHAIN_FILE=%USERPROFILE%/documents/development/vcpkg/scripts/buildsystems/vcpkg.cmake
cd
set msvc=-DMSVC=TRUE
REM set Version=-T v141
md build
cd build
REM set triplet=-DVCPKG_TARGET_TRIPLET=x86-windows-static
set triplet=-DVCPKG_TARGET_TRIPLET=x86-windows
REM https://stackoverflow.com/questions/28350214/how-to-build-x86-and-or-x64-on-windows-from-command-line-with-cmake
cmake.exe %vcpkg% %msvc% %triplet% -G "Visual Studio 16 2019" -A Win32 ..
cd ..
REM md x64
REM cd x64
REM set triplet=-DVCPKG_TARGET_TRIPLET=x64-windows-static
REM cmake.exe %vcpkg% %msvc% %triplet% -G "Visual Studio 15 2017 Win64" %Version% ..
set vcpkg=-DCMAKE_TOOLCHAIN_FILE=%USERPROFILE%/documents/development/vcpkg/scripts/buildsystems/vcpkg.cmake
cd
set msvc=-DMSVC=TRUE
REM set Version=-T v141
md build
cd build
REM set triplet=-DVCPKG_TARGET_TRIPLET=x86-windows-static
set triplet=-DVCPKG_TARGET_TRIPLET=x86-windows
REM https://stackoverflow.com/questions/28350214/how-to-build-x86-and-or-x64-on-windows-from-command-line-with-cmake
cmake.exe %vcpkg% %msvc% %triplet% -G "Visual Studio 16 2019" -A Win32 ..
cd ..
REM md x64
REM cd x64
REM set triplet=-DVCPKG_TARGET_TRIPLET=x64-windows-static
REM cmake.exe %vcpkg% %msvc% %triplet% -G "Visual Studio 15 2017 Win64" %Version% ..
REM cd ..
58 changes: 29 additions & 29 deletions demo/image_viewer.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<style>
div{
width: 801px;
height:801px;
border:solid
}

img{
width: 100%;
height: 100%;
object-fit: contain;
}
</style>
</head>
<meta http-equiv="refresh" content="1.0">
<body>
<h1>
Display Scan-Data of MRS 1104 <br>
<a href="scan.csv"> Scan Data as CSV file</a>
<br>
</h1>
<div>
<img src="scan.jpg" alt="SCAN Image">
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div{
width: 801px;
height:801px;
border:solid
}

img{
width: 100%;
height: 100%;
object-fit: contain;
}
</style>
</head>
<meta http-equiv="refresh" content="1.0">
<body>
<h1>
Display Scan-Data of MRS 1104 <br>
<a href="scan.csv"> Scan Data as CSV file</a>
<br>
</h1>
<div>
<img src="scan.jpg" alt="SCAN Image">
</div>
</body>
</html>
Loading

0 comments on commit 9e0e0cd

Please sign in to comment.