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

Commit 40d3205

Browse files
committed
Release 1.8.0 with support for field montoring TiM7xxS
1 parent 8d97d8e commit 40d3205

File tree

147 files changed

+210677
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+210677
-20
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ tools/sick_generic_device_finder/venv
8383

8484
tools/sick_generic_device_finder/.idea
8585

86-
8786
doc/angle_compensation/ampl_phase_offset\.png
87+
88+
test/emulator/scandata/20210126-tim781s-test-fieldsets.pcapng.json

CMakeLists.txt

Lines changed: 150 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
####################################################
66
cmake_minimum_required(VERSION 2.8.3)
77

8+
# build options: set OFF for relese version, ON for development and test
9+
option(ENABLE_EMULATOR "Build emulator for offline and unittests" OFF) # OFF (release) or ON (development)
10+
option(BUILD_DEBUG_TARGET "Build debug target" OFF) # OFF (release) or ON (development)
811

912
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
1013
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
@@ -30,10 +33,12 @@ macro(use_cxx11)
3033
endif ()
3134
endmacro(use_cxx11)
3235

33-
#set(CMAKE_BUILD_TYPE Debug) #uncomment to activate debug mode for lib_sick as well
34-
#set(CMAKE_ENABLE_EXPORTS 1) #uncomment to activate debug mode for lib_sick as well
35-
# https://cmake.org/cmake/help/v3.5/prop_tgt/ENABLE_EXPORTS.html
36-
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++03")
36+
if(BUILD_DEBUG_TARGET)
37+
set(CMAKE_BUILD_TYPE Debug) #uncomment to activate debug mode for lib_sick as well
38+
set(CMAKE_ENABLE_EXPORTS 1) #uncomment to activate debug mode for lib_sick as well
39+
# https://cmake.org/cmake/help/v3.5/prop_tgt/ENABLE_EXPORTS.html
40+
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++03")
41+
endif(BUILD_DEBUG_TARGET)
3742

3843
# Switch on, if you use c11-specific commands
3944
use_cxx11()
@@ -60,6 +65,9 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-overflow")
6065

6166
find_package(Boost REQUIRED COMPONENTS system serialization)
6267

68+
if(ENABLE_EMULATOR)
69+
find_package(jsoncpp REQUIRED) # install libjsoncpp by running "sudo apt-get install libjsoncpp-dev"
70+
endif(ENABLE_EMULATOR)
6371

6472
find_package(catkin REQUIRED COMPONENTS
6573
roscpp
@@ -86,8 +94,9 @@ generate_dynamic_reconfigure_options(
8694
cfg/tf_dyn.cfg
8795
)
8896

97+
# driver messages
8998
add_message_files(
90-
99+
DIRECTORY msg
91100
FILES
92101
SickImu.msg
93102
RadarObject.msg
@@ -98,8 +107,92 @@ add_message_files(
98107
RadarPreHeader.msg
99108
RadarScan.msg
100109
Encoder.msg
110+
LFErecFieldMsg.msg
111+
LFErecMsg.msg
112+
LIDoutputstateMsg.msg
113+
)
114+
115+
# driver services
116+
add_service_files(
117+
DIRECTORY srv
118+
FILES
119+
ColaMsgSrv.srv
120+
ECRChangeArrSrv.srv
121+
LIDoutputstateSrv.srv
101122
)
102123

124+
if(ENABLE_EMULATOR)
125+
# emulator messages
126+
add_message_files(
127+
DIRECTORY test/emulator/msg
128+
FILES
129+
SickLocColaTelegramMsg.msg
130+
SickLocDiagnosticMsg.msg
131+
SickLocResultPortCrcMsg.msg
132+
SickLocResultPortHeaderMsg.msg
133+
SickLocResultPortPayloadMsg.msg
134+
SickLocResultPortTelegramMsg.msg
135+
SickLocResultPortTestcaseMsg.msg
136+
)
137+
138+
# emulator services
139+
add_service_files(
140+
DIRECTORY test/emulator/srv
141+
FILES
142+
SickLocColaTelegramSrv.srv
143+
SickLocRequestTimestampSrv.srv
144+
SickLocSetResultModeSrv.srv
145+
SickLocSetResultPoseIntervalSrv.srv
146+
SickLocIsSystemReadySrv.srv
147+
SickLocSetPoseSrv.srv
148+
SickLocSetResultPortSrv.srv
149+
SickLocStartLocalizingSrv.srv
150+
SickLocStopSrv.srv
151+
SickLocRequestResultDataSrv.srv
152+
SickLocSetResultEndiannessSrv.srv
153+
SickLocSetResultPoseEnabledSrv.srv
154+
SickLocStateSrv.srv
155+
SickLocTimeSyncSrv.srv
156+
SickDevGetLidarConfigSrv.srv
157+
SickDevGetLidarIdentSrv.srv
158+
SickDevGetLidarStateSrv.srv
159+
SickDevSetLidarConfigSrv.srv
160+
SickGetSoftwareVersionSrv.srv
161+
SickLocAutoStartActiveSrv.srv
162+
SickLocAutoStartSavePoseIntervalSrv.srv
163+
SickLocAutoStartSavePoseSrv.srv
164+
SickLocForceUpdateSrv.srv
165+
SickLocInitializePoseSrv.srv
166+
SickLocInitialPoseSrv.srv
167+
SickLocMapSrv.srv
168+
SickLocMapStateSrv.srv
169+
SickLocOdometryActiveSrv.srv
170+
SickLocOdometryPortSrv.srv
171+
SickLocOdometryRestrictYMotionSrv.srv
172+
SickLocReflectorsForSupportActiveSrv.srv
173+
SickLocResultEndiannessSrv.srv
174+
SickLocResultModeSrv.srv
175+
SickLocResultPortSrv.srv
176+
SickLocResultPoseIntervalSrv.srv
177+
SickLocResultStateSrv.srv
178+
SickLocRingBufferRecordingActiveSrv.srv
179+
SickLocSaveRingBufferRecordingSrv.srv
180+
SickLocSetAutoStartActiveSrv.srv
181+
SickLocSetAutoStartSavePoseIntervalSrv.srv
182+
SickLocSetMapSrv.srv
183+
SickLocSetOdometryActiveSrv.srv
184+
SickLocSetOdometryPortSrv.srv
185+
SickLocSetOdometryRestrictYMotionSrv.srv
186+
SickLocSetReflectorsForSupportActiveSrv.srv
187+
SickLocSetRingBufferRecordingActiveSrv.srv
188+
SickLocStartDemoMappingSrv.srv
189+
SickReportUserMessageSrv.srv
190+
SickSavePermanentSrv.srv
191+
SickDevSetIMUActiveSrv.srv
192+
SickDevIMUActiveSrv.srv
193+
)
194+
endif(ENABLE_EMULATOR)
195+
103196
generate_messages(
104197
DEPENDENCIES
105198
std_msgs
@@ -139,6 +232,10 @@ add_library(sick_scan_lib
139232
include/sick_scan/softwarePLL.h
140233
driver/src/softwarePLL.cpp
141234
driver/src/helper/angle_compensator.cpp
235+
driver/src/sick_generic_field_mon.cpp
236+
driver/src/sick_scan_marker.cpp
237+
driver/src/sick_scan_messages.cpp
238+
driver/src/sick_scan_services.cpp
142239
)
143240

144241
add_dependencies(sick_scan_lib ${PROJECT_NAME}_gencfg ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS})
@@ -201,7 +298,6 @@ install(
201298
sick_scan_test
202299
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
203300

204-
205301
install(FILES include/${PROJECT_NAME}/abstract_parser.h
206302
include/${PROJECT_NAME}/sick_scan_common.h
207303
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
@@ -219,3 +315,51 @@ install(DIRECTORY meshes/
219315

220316
install(DIRECTORY urdf/
221317
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/urdf)
318+
319+
if(ENABLE_EMULATOR)
320+
#
321+
# emulator
322+
#
323+
# message("ENABLE_EMULATOR: build with emulator...")
324+
325+
add_executable(sick_scan_emulator
326+
test/emulator/src/test_server.cpp
327+
test/emulator/src/test_server_thread.cpp
328+
test/emulator/src/client_socket.cpp
329+
test/emulator/src/cola_converter.cpp
330+
test/emulator/src/cola_encoder.cpp
331+
test/emulator/src/cola_parser.cpp
332+
test/emulator/src/cola_transmitter.cpp
333+
test/emulator/src/crc/crc16ccitt_false.cpp
334+
test/emulator/src/pcapng_json_parser.cpp
335+
test/emulator/src/random_generator.cpp
336+
test/emulator/src/result_port_parser.cpp
337+
test/emulator/src/ros_wrapper.cpp
338+
test/emulator/src/SoftwarePLL.cpp
339+
test/emulator/src/testcase_generator.cpp
340+
test/emulator/src/utils.cpp
341+
)
342+
343+
target_link_libraries(sick_scan_emulator
344+
${catkin_LIBRARIES}
345+
${roslib_LIBRARIES}
346+
jsoncpp_lib # ${jsoncpp_LIBRARIES}
347+
sick_scan_lib)
348+
349+
target_compile_definitions(sick_scan_emulator PUBLIC __ROS_VERSION=1)
350+
351+
target_include_directories(sick_scan_emulator PUBLIC test/emulator/include)
352+
353+
install(TARGETS sick_scan_emulator
354+
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
355+
356+
install(DIRECTORY test/emulator/launch/
357+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
358+
359+
install(DIRECTORY test/emulator/yaml/
360+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/yaml)
361+
362+
install(DIRECTORY test/emulator/scandata/
363+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scandata)
364+
365+
endif(ENABLE_EMULATOR)

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ ROS Device Driver for SICK lidar and radar sensors - supported scanner types:
4545
| | | Scan-Rate: 15 Hz | |
4646
| TiM571 | [1079742](https://www.sick.com/de/en/detection-and-ranging-solutions/2d-lidar-sensors/tim5xx/tim571-2050101/p/p412444) | 1 layer max. range: 25 m, ang. resol. 0.33 [deg]|[stable]|
4747
| | | Scan-Rate: 15 Hz | |
48-
| TiM781 | [1096807](https://www.sick.com/de/de/mess-und-detektionsloesungen/2d-lidar-sensoren/tim7xx/tim781-2174101/p/p594148) | 1 layer max. range: 25 m, ang. resol. 0.33 [deg]|[stable]|
48+
| TiM771S | [1105052](https://www.sick.com/de/de/mess-und-detektionsloesungen/2d-lidar-sensoren/tim7xx/tim771s-2174104/p/p660929) | 1 layer max. range: 25 m, ang. resol. 0.33 [deg]|[stable]|
4949
| | | Scan-Rate: 15 Hz | |
50-
| TiM781S | [1096363](https://www.sick.com/de/de/mess-und-detektionsloesungen/2d-lidar-sensoren/tim7xx/tim781s-2174104/p/p594149) | 1 layer max. range: 25 m, ang. resol. 0.33 [deg]|[stable]|
50+
| TiM781 | [1096807](https://www.sick.com/de/de/mess-und-detektionsloesungen/2d-lidar-sensoren/tim7xx/tim781-2174101/p/p594148) | 1 layer max. range: 25 m, ang. resol. 0.33 [deg]|[stable]|
51+
| | | Scan-Rate: 15 Hz | |
52+
| TiM781S | [1096363](https://www.sick.com/de/de/mess-und-detektionsloesungen/2d-lidar-sensoren/tim7xx/tim781s-2174104/p/p594149) | 1 layer max. range: 25 m, ang. resol. 0.33 [deg]|[stable]|
5153
| | | Scan-Rate: 15 Hz | |
5254
| LMS511-10100 PRO | [e.g. 1046135](https://www.sick.com/de/en/detection-and-ranging-solutions/2d-lidar-sensors/lms5xx/c/g179651) | 1 layer max. range: 80 m, ang. resol. 0.167 [deg]|[stable]|
5355
| | | Scan-Rate: 100 Hz | |
@@ -200,14 +202,18 @@ The use of the parameters can be looked up in the launch files. This is also rec
200202
- `frame_id`
201203
Frame id used for the published data
202204

205+
203206
### Further useful parameters and features
207+
204208
- `timelimit`
205209
Timelimit in [sec] for max. wait time of incoming sensor reply
206210

207211
- `sw_pll_only_publish`
208212
If true, the internal Software PLL is fored to sync the scan generation time stamp to a system timestamp
209213

210-
- Angle compensation: For highest angle accuracy the NAV-Lidar series supports an [angle compensation mechanism](./doc/angular_compensation.md).
214+
- Angle compensation: For highest angle accuracy the NAV-Lidar series supports an [angle compensation mechanism](./doc/angular_compensation.md).
215+
216+
- The **TiM7xxS** family has [extended settings for field monitoring](./doc/tim7xxs_extensions.md).
211217

212218
## Sopas Mode
213219
This driver supports both COLA-B (binary) and COLA-A (ASCII) communication with the laser scanner. Binary mode is activated by default. Since this mode generates less network traffic.

cfg/SickScan.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ gen.add("scan_freq", double_t, 0, "Scan frequency set to 0 to use scanner defaul
7474
gen.add("encoder_mode", int_t, 0, "-1:No Encoder, 0:Off, 1:Single increment, 2:Direction Phase, 3:Direction Level",-1 ,-1,3)
7575
# gen.add("mean_filter", int_t, 0, "Number of averages for mean filter 0 means filter is disabled", 0, 0, 100)
7676
# gen.add("mirror_scan",bool_t, 0, "Scan direction's changed. E.g. for overhead mounting or NAV 310 ( in contrast to other sick scanners NAV 310 is clockwise rotating ).",False)
77+
gen.add("use_safty_fields", bool_t, 0, "Whether or not to use safty fields. Only tim 7xx5 supported at the moment", True)
7778
exit(gen.generate(PACKAGE, "sick_scan", "SickScan"))

doc/tim7xxs_extensions.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Extensions for TiM7xxS
2+
3+
The TiM7xxS family has the following extended settings for field monitoring:
4+
5+
## Field monitoring messages
6+
7+
TiM7xxS scanner support field monitoring. Fields can be configured by Sopas ET. Once they are configured, sick_scan publishes ros messages containing the monitoring information from the lidar.
8+
9+
By default, field monitoring is enabled in the launch file [sick_tim_7xxS.launch](../launch/sick_tim_7xxS.launch) by following settings:
10+
```
11+
<param name="activate_lferec" type="bool" value="True"/> <!-- activate field monitoring by lferec messages -->
12+
<param name="activate_lidoutputstate" type="bool" value="True"/> <!-- activate field monitoring by lidoutputstate messages -->
13+
<param name="activate_lidinputstate" type="bool" value="True"/> <!-- activate field monitoring by lidinputstate messages -->
14+
```
15+
16+
The driver queries the field configuration from the lidar and activates field monitoring by sending cola commands `"sEN LFErec 1"` and `"sEN LIDoutputstate 1"` at startup. Field monitoring is deactivated when driver exits. During runtime, it's possible to query, activate or deactivate monitoring using ros service ColaMsg with the following command (see section [Cola commands](#cola-commands)):
17+
```
18+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sEN LFErec 1'}" # activate LFErec messages
19+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sEN LFErec 0'}" # deactivate LFErec messages
20+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sRN LFErec'}" # query activation status of LFErec messages
21+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sEN LIDoutputstate 1'}" # activate LIDoutputstate messages
22+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sEN LIDoutputstate 0'}" # deactivate LIDoutputstate messages
23+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sRN LIDoutputstate'}" # query activation status of LIDoutputstate messages
24+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sEN LIDinputstate 1'}" # activate LIDinputstate messages
25+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sEN LIDinputstate 0'}" # deactivate LIDinputstate messages
26+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sRN LIDinputstate'}" # query activation status of LIDinputstate messages
27+
```
28+
29+
LFErec and LIDoutputstate messages are defined in [LFErecMsg.msg](../msg/LFErecMsg.msg) and [LFErecFieldMsg.msg](../msg/LFErecFieldMsg.msg) resp. [LIDoutputstateMsg.msg](../msg/LIDoutputstateMsg.msg) and published on topics `"/sick_tim_7xxS/lferec"` resp. `"/sick_tim_7xxS/lidoutputstate"`.
30+
To view the field monitoring messages, run
31+
```
32+
rostopic echo "/sick_tim_7xxS/lferec"
33+
rostopic echo "/sick_tim_7xxS/lidoutputstate"
34+
```
35+
or use rviz to visualize monitored fields and their status (see section [Visualization with rviz](#visualization-with-rviz))
36+
37+
The most important values of the field monitoring messages are
38+
39+
- `field_index` (uint8) and `field_result_mrs` (uint8) for each field of a LFErec message with result status<br/><ul>
40+
<li>0: invalid / incorrect,</li>
41+
<li>1: free / clear, or</li>
42+
<li>2: infringed.</li>
43+
</ul>
44+
45+
- `output_state` (uint8) for each LIDoutputstate message with status 0 (not active), 1 (active) or 2 (not used).
46+
47+
Note: Field monitoring currently supports binary cola messages only, which is the default. If cola ascii is activated, please switch back to cola binary for field monitoring.
48+
49+
## Visualization with rviz
50+
51+
The point cloud, the monitored fields and their status can be visualized using rviz. Use the [rviz configuration file](../test/emulator/config/rviz_emulator_cfg.rviz)
52+
and run
53+
```
54+
rosrun rviz rviz -d ./src/sick_scan/test/emulator/config/rviz_emulator_cfg.rviz
55+
```
56+
57+
Otherwise you can just add visualizations of type `/cloud/PointCloud2` and `/sick_tim_7xxS/marker`:
58+
59+
![tim7xxs_screenshot01.png](tim7xxs_screenshot01.png)
60+
61+
The following screenshot shows an example with 2 fields (the 3. field is not configured), the first field with status "Clear", the second with status "Infringed":
62+
63+
![tim7xxs_screenshot02.png](tim7xxs_screenshot02.png)
64+
65+
Note: Some combinations of rviz, OpenGL 3, VMware and graphic card drivers may cause visualization issues. In case of missing markers, try rviz with Open GL 2 using the command
66+
```
67+
rosrun rviz rviz -d ./src/sick_scan/test/emulator/config/rviz_emulator_cfg.rviz --opengl 210
68+
```
69+
70+
## Cola commands
71+
72+
Cola commands can be sent for diagnosis and development using the ros service ColaMsg. This service is implemented in sick_scan and started by
73+
```
74+
<param name="start_services" type="bool" value="True"/>
75+
```
76+
in the launch file [sick_tim_7xxS.launch](../launch/sick_tim_7xxS.launch). The ros service sends the given cola command to the lidar and returns its response.
77+
78+
Example for cola command `"sRN SCdevicestate"` and response `"sRA SCdevicestate \\x00"` with error status 0 (no error):
79+
```
80+
rosservice call /sick_tim_7xx/ColaMsg "{request: 'sRN SCdevicestate'}"
81+
response: "sRA SCdevicestate \\x00"
82+
```
83+
84+
## Tools, emulation and unittests
85+
86+
Package sick_scan implements some tools to support unittests, development and emulation of Tim781S devices:
87+
88+
- sick_scan_emulator to emulate lidar devices and enable unittests (currently for Tim781S only)
89+
90+
- pcap_json_converter to convert pcapng-files to json.
91+
92+
### TiM781S emulation
93+
94+
sick_scan_emulator implements a simple test server for cola commands. It rececives Cola-commands, returns Tim781S-like responses and sends Scandata from a json-file. Run
95+
```
96+
roslaunch sick_scan emulator.launch
97+
```
98+
to emulate a local Tim781S device. Then start and connect the sick_scan driver by
99+
```
100+
roslaunch sick_scan sick_tim_7xxS.launch hostname:=127.0.0.1
101+
```
102+
103+
Note that sick_scan_emulator just implements a simple server for offline tests. It does not emulate a lidar device completely and should only be used for development and testing.
104+
105+
Scandata messages are parsed from json-file(s). These json-files are configured in the launch file [emulator.launch](../test/emulator/launch/emulator.launch) and converted form wireshark-records (pcapng-files) using pcap_json_converter.py (see section Pcapng converter tool](#pcapng-converter-tool)).
106+
107+
### Unittests
108+
109+
Folder `test/emulator/scandata` contains scandata examples for unittests. To run an offline unittest for TiM781S enter the following commands:
110+
```
111+
cd test/scripts
112+
./run_simu_tim781s.bash
113+
```
114+
or start emulator, driver and rviz by running
115+
```
116+
source ./install/setup.bash
117+
# Start sick_scan emulator
118+
roslaunch sick_scan emulator.launch &
119+
sleep 1
120+
# Start rviz
121+
rosrun rviz rviz -d ./src/sick_scan/test/emulator/config/rviz_emulator_cfg.rviz --opengl 210 &
122+
sleep 1
123+
# Start sick_scan driver for TiM871S
124+
roslaunch sick_scan sick_tim_7xxS.launch hostname:=127.0.0.1
125+
```
126+
127+
### Pcapng converter tool
128+
129+
The pcapng converter tool [pcap_json_converter.py](../test/pcap_json_converter/pcap_json_converter.py) converts pcapng-files to json-files. Run the following steps to create a json-file with scandata for the emulator:
130+
131+
1. Start wireshark and filter the tcp traffic on port 2112 with the filter expression `tcp and tcp.port==2112`.
132+
2. Start TiM781S and run the sick_scan driver.
133+
3. Capture the network traffic for some time.
134+
4. Stop capturing and save the network traffic in a pcapng-file.
135+
5. Convert the pcapng-file to json by `python pcap_json_converter.py --pcap_filename=<filepath>.pcapng`. Result is a jsonfile `<filepath>.pcapng.json`
136+
6. Set the resulting json-file in the emulator configuration [emulator.launch](../test/emulator/launch/emulator.launch) by `<arg name="scandatafiles" default="<filepath>.pcapng.json"/>`

doc/tim7xxs_screenshot01.png

191 KB
Loading

doc/tim7xxs_screenshot02.png

740 KB
Loading

0 commit comments

Comments
 (0)