SICKAG / sick_safetyscanners2

ROS2 driver for SICK safety laser scanners
https://www.sick.com/de/en/opto-electronic-protective-devices/safety-laser-scanners/c/g187225
Apache License 2.0
28 stars 30 forks source link

Race condition during devices configuration #18

Closed MarcoMatteoBassa closed 2 years ago

MarcoMatteoBassa commented 2 years ago

Hi guys, thank you for the great work on the ros2 interface. Unfortunately here at Idealworks we are struggling to reliably activate the udp transmission from the devices: the scanners sometimes manage to start the streaming and sometimes don't. In the beginning we tought it depended on the timing between the configuration and the activation calls, since leaving more time in between seemed to solve the issue, but with further testing we could reproduce the issue even with a "slow" initialization. From the ros-log point of view there is no visible error, the tcp part of the communication seems to work fine, here an example of log:

[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.550510809] [robot_interface.micro_scan_rear]: Initializing SickSafetyscannersLifeCycle 
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.551965666] [robot_interface.micro_scan_rear]: frame_id: scan_rear
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552033700] [robot_interface.micro_scan_rear]: sensor_ip: 192.168.1.4
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552079461] [robot_interface.micro_scan_rear]: interface_ip: 0.0.0.0
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552113542] [robot_interface.micro_scan_rear]: host_ip: 192.168.1.10
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552146439] [robot_interface.micro_scan_rear]: host_udp_port: 6062
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552181000] [robot_interface.micro_scan_rear]: channel: 0
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552213545] [robot_interface.micro_scan_rear]: channel_enabled: true
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552246378] [robot_interface.micro_scan_rear]: skip: 0
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552278091] [robot_interface.micro_scan_rear]: angle_start: -0.523599
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552325036] [robot_interface.micro_scan_rear]: angle_end: 3.752460
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.552361357] [robot_interface.micro_scan_rear]: time_offset: 0.000000
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.555316032] [robot_interface.micro_scan_rear]: general_system_state: true
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.555419971] [robot_interface.micro_scan_rear]: derived_settings: true
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.555507365] [robot_interface.micro_scan_rear]: measurement_data: true
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.556242714] [robot_interface.micro_scan_rear]: intrusion_data: true
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.556307516] [robot_interface.micro_scan_rear]: application_io_data: true
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.556347133] [robot_interface.micro_scan_rear]: use_persistent_config: false
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.556381310] [robot_interface.micro_scan_rear]: min_intensities: 0.000000
[lifecycle_manager-14] [INFO] [1652691167.556707463] [robot_interface.lifecycle_manager]: Autostarting
[lifecycle_manager-14] [INFO] [1652691167.556804202] [robot_interface.lifecycle_manager]: Starting all nodes
[lifecycle_manager-14] [INFO] [1652691167.556884684] [robot_interface.lifecycle_manager]: Configuring micro_scan_rear
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.624727358] [robot_interface.micro_scan_rear]: on_configure()...
[sick_safetyscanners2_lifecycle_node-13] [INFO]: Command Method Acknowledged.
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.745830439] [robot_interface.micro_scan_rear]: Communication to Sensor set up
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.745949515] [robot_interface.micro_scan_rear]: Reading Type code settings
[sick_safetyscanners2_lifecycle_node-13] [INFO]: Command Variable Acknowledged.
[sick_safetyscanners2_lifecycle_node-13] [INFO]: Type Code: MICS3-CBAZ55ZA1
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.872954042] [robot_interface.micro_scan_rear]: Node Configured
[lifecycle_manager-14] [INFO] [1652691167.874495205] [robot_interface.lifecycle_manager]: Activating micro_scan_rear
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.875722120] [robot_interface.micro_scan_rear]: on_activate()...
[sick_safetyscanners2_lifecycle_node-13] [INFO]: Command Method Acknowledged.
[sick_safetyscanners2_lifecycle_node-13] [INFO] [1652691167.992948485] [robot_interface.micro_scan_rear]: Node activated, device is running...
[lifecycle_manager-14] [INFO] [1652691167.994265546] [robot_interface.lifecycle_manager]: All nodes are active

I'll also attach a tcp dump of a failing initialization. (config + activation)

tcp_dump_failure.txt

Once a device started streaming, it apparently keeps working (on the same udp port) until powercycled. The devices are working properly using a different driver. Do you have any idea of what a possible issue could be?

Thank you for your support

lenpuc commented 2 years ago

Hi, since i did not directly implement the lifecycle nodes, I am not too sure what exactly is causing your issue, maybe @guilyx has some more insights or maybe experienced the issue himself so far.

What do you mean by stating its working properly using a different driver?

guilyx commented 2 years ago

Hey there,

We haven't had issues ever since we closed the last PR, we're using lifecycle nodes, I haven't experienced this (and the scanner node is launched and killed hundred times a day here)

MarcoMatteoBassa commented 2 years ago

@puck-fzi @guilyx Thanks for your reply. We found that our previous version of the driver was using a different reference for the min max-angles: this resulted in a too big "angle end" that I guess made the scanner reject new reconfigurations.