SICKAG / sick_safetyscanners_base

CPP (C++) 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
13 stars 32 forks source link

SICK nanoscan3 running error only using C++ (good working in ROS2 environment but do not working only C++) #34

Closed leejae0720 closed 1 week ago

leejae0720 commented 1 week ago

Hello.

I am reaching out because I'm experiencing issues with connection while using this library.

Sensor IP: 192.168.140.22, Port: 2122 Host IP: 192.168.140.13, Port: 0 or 6060 I have been using it with the above settings, and when I test with the ping command, everything seems to be connected correctly. I set the host port to 6060 using the SICK-provided tool, as I assume I need to configure the "send mode" setting on the SICK LiDAR sensor (I understand that setting it to 0 allows it to automatically find the port).

However, when I try to receive data asynchronously as shown in the example, no data comes in. If you have any insights on this issue, I would appreciate your help. The steps I’ve taken are as follows. I wrote the main code and built it with CMake, which seems to be working fine, as the build completes successfully, and the executable file is generated.

When I change the IP, the program crashes, so I believe the IP settings are correct. I am using Ubuntu 22.04, and LiDAR data is received correctly on ROS2 Humble, but I am attempting to receive data using only C++. (Reference: https://github.com/SICKAG/sick_safetyscanners2)

please someone help me...

step 1, Installing the library on a linux PC(ubuntu22.04 & C++ environment.) Followed the Installation step of https://github.com/SICKAG/sick_safetyscanners_base *libsick_safetyscanners_base.so was created.

step 2, make CMakeLists.txt file and Building CMake include sick_safetyscanners_base library and build complete

3.Result of running ./nanoscan3_driver_node (it is running program name made by CMake) ; [INFO]: Command Method Acknowledged. terminate called after throwing an instance of 'sick::timeout_error' what(): Timeout exceeded while waiting for sensor data [timeout: 5seconds] ......

Here is my main.pp code it is almost same example code

// Sensor IP and Port
std::string sensor_ip_str = 192.168.140.22
sick::types::ip_address_t sensor_ip = boost::asio::ip::address_v4::from_string(sensor_ip_str);
sick::types::port_t tcp_port {2122};

// Prepare the CommSettings for Sensor streaming data
sick::datastructure::CommSettings comm_settings;
std::string host_ip_str = "192.168.140.15"
comm_settings.host_ip = boost::asio::ip::address_v4::from_string(host_ip_str);
comm_settings.host_udp_port = 6060;

// Define a sensor data callback
sick::types::ScanDataCb cb = [](const sick::datastructure::Data &data) {
    std::cout << "Number of beams: " << data.getMeasurementDataPtr()->getNumberOfBeams() << std::endl;
};

// Create a sensor instance
auto safety_scanner = std::make_unique<sick::AsyncSickSafetyScanner>(sensor_ip, tcp_port, comm_settings, cb);

// Special case if a multicast IP is seltected as host_ip
// std::string host_ip_str = "235.235.235.2"
// comm_settings.host_ip = boost::asio::ip::address_v4::from_string(host_ip_str);
// std::string interface_ip_str = "192.168.1.9"
// auto interface_ip = boost::asio::ip::address_v4::from_string(interface_ip_str);
// auto safety_scanner = std::make_unique<sick::AsyncSickSafetyScanner>(sensor_ip, tcp_port, comm_settings, interface_ip, cb);

// Start async receiving and processing of sensor data
safety_scanner->run();

// ... Do other stuff

// Stop async processing
safety_scanner->stop();

Best regard Jaehong

leejae0720 commented 1 week ago

Screenshot from 2024-10-31 12-54-00

First, click UDP communication with wireshark.. However, when I monitor the incoming UDP communication continuously, it eventually stops receiving in the middle. I need to resolve this issue.

Screenshot from 2024-10-31 12-57-05