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
14 stars 32 forks source link

The c++ version driver has no data connected to the li #32

Closed weiOverlord closed 1 month ago

weiOverlord commented 1 month ago

Hello, when I used the c++ version driver code to connect the nanoscan3 radar, no data was sent out when I printed data. The c++ driver download address is: https://www.sick.com/cn/zh/catalog/products/safety/safety-laser-scanners/nanoscan3/nans3-caaz30an1/p/p653980?category=g5 69793&tab=downloads The name is C++ library for safety laser scanners I downloaded the C++ nanoscan3 driver code from this path,When I use this driver, I only add content to the main function, and nothing else changes. The contents are as follows:

int mai() { std::string sensor_ip_str = "192.168.192.10"; 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.192.11";
    comm_settings.host_ip = boost::asio::ip::address_v4::from_string(host_ip_str);
    comm_settings.host_udp_port = 0;

    // 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);

      safety_scanner->run();
 while(true)
  {
  sleep(100);
  }

return 0; }

 I have modified the Lidar ip before use,I've confirmed that the Lidar's ip is 192.168.192.10,Local ip: 192.168.192.11,My Linux system is 16.04.At the same time, when I used this computer to test the ROS driver, there was no problem with the ros driver, and there was some cloud data.ROS drivers are as follows:

ROS driver: https://github.com/SICKAG/sick_safetyscanners

So when I started the drive, only one prompt appeared,as follows: [INFO]: Command Method Acknowledged

I tried again to print the log in the UDPClient.cpp file, and when I used the isConnected() function, the connection status returned True. The port number is also returned when the connection port is obtained using the getLocalPort function.When I checked the PacketBuffer.cpp file again,When I checked the PacketBuffer.cpp file again and printed the length of m_buffer in the setBuffer(const std::vector&buffer) function, the output was as follows: 18 18 24 24 18 18

Anyway, for such an application, radar has been the point cloud data I need.Could you please help me find out where I have a problem and I need your support。
lenpuc commented 1 month ago

Hi, first of all, 16.04 is a fairly old system that might not have all dependencies. However, if it builds, it might work especially if the ROS1 driver works. I don't see an immediate mistake in your code. As far as I understand it, the callback (CB) is never called, and no data has arrived. You could take a look into the ROS2 driver, that utilizes the base C++ driver. You can find the code here https://github.com/SICKAG/sick_safetyscanners2/blob/master/src/SickSafetyscanners.cpp#L124, and the setup of the communication is invoked from here: https://github.com/SICKAG/sick_safetyscanners2/blob/master/src/SickSafetyscannersRos2.cpp#L70

weiOverlord commented 1 month ago

I am very glad to receive your reply. I am very sorry. For NanoScan3 radar, we do not use ROS framework for development, and we just want to use C++ version driver to establish communication with the radar. Also, why does running ROS1 on Ubuntu16.04 allow you to connect to radar and get data?

1059482396 @.***

 

------------------ 原始邮件 ------------------ 发件人: "SICKAG/sick_safetyscanners_base" @.>; 发送时间: 2024年10月16日(星期三) 晚上8:26 @.>; @.**@.>; 主题: Re: [SICKAG/sick_safetyscanners_base] The c++ version driver has no data connected to the li (Issue #32)

Hi, first of all, 16.04 is a fairly old system that might not have all dependencies. However, if it builds, it might work especially if the ROS1 driver works. I don't see an immediate mistake in your code. As far as I understand it, the callback (CB) is never called, and no data has arrived. You could take a look into the ROS2 driver, that utilizes the base C++ driver. You can find the code here https://github.com/SICKAG/sick_safetyscanners2/blob/master/src/SickSafetyscanners.cpp#L124, and the setup of the communication is invoked from here: https://github.com/SICKAG/sick_safetyscanners2/blob/master/src/SickSafetyscannersRos2.cpp#L70

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lenpuc commented 1 month ago

The base driver and the ROS1 driver diverged at some stage; they are not the same; the base driver is the newer version and is the basis for the ROS2 driver. Could you elaborate on the complete log output of your program? So that I get an understanding of what is happening.

weiOverlord commented 1 month ago

When I used the C++ driver, I could normally connect with the nanoscan3 driver. I checked the TCP connection and got the port number, but no data was sent. Now I don't know which direction to check, I compared the parameters of ROS driver. The parameters of the Commetting class are almost the same, but I do not understand why no data is sent

1059482396 @.***

 

------------------ 原始邮件 ------------------ 发件人: "SICKAG/sick_safetyscanners_base" @.>; 发送时间: 2024年10月16日(星期三) 晚上9:39 @.>; @.**@.>; 主题: Re: [SICKAG/sick_safetyscanners_base] The c++ version driver has no data connected to the li (Issue #32)

The base driver and the ROS1 driver diverged at some stage; they are not the same; the base driver is the newer version and is the basis for the ROS2 driver. Could you elaborate on the complete log output of your program? So that I get an understanding of what is happening.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lenpuc commented 1 month ago

Can you see packages being transmitted in wireshark? to the correct IP address and port? And could you give the parameters you set?

weiOverlord commented 1 month ago

I don't quite understand what you mean. I compared the configuration parameters of ROS driver with those of C++, and they are almost the same, but the results are different. Therefore, I would like to trouble you to try C++ driver and follow the main() function written by me to see if you can find out where the problem is.

 

------------------ 原始邮件 ------------------ 发件人: "SICKAG/sick_safetyscanners_base" @.>; 发送时间: 2024年10月16日(星期三) 晚上9:45 @.>; @.**@.>; 主题: Re: [SICKAG/sick_safetyscanners_base] The c++ version driver has no data connected to the li (Issue #32)

Can you see packages being transmitted in wireshark? to the correct IP address and port? And could you give the parameters you set?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lenpuc commented 1 month ago

Try adding these lines around your Async client, it might be that the comm_settigns are rejected by the sensor, since they are the wrong type, by reading the type from the sensor and updating it, it should work

auto safety_scanner = std::make_unique<sick::AsyncSickSafetyScanner>(sensor_ip, tcp_port, comm_sett      ings, cb);

sick::datastructure::TypeCode type_code;
safety_scanner->requestTypeCode(type_code);
comm_settings.e_interface_type = type_code.getInterfaceType();
safety_scanner->run();
safety_scanner->changeSensorSettings(comm_settings);
weiOverlord commented 1 month ago

I understand. I will try it tomorrow morning. Thank you very much for your help. I will inform you immediately if there is any result. Thanks again

1059482396 @.***

 

------------------ 原始邮件 ------------------ 发件人: "SICKAG/sick_safetyscanners_base" @.>; 发送时间: 2024年10月16日(星期三) 晚上10:57 @.>; @.**@.>; 主题: Re: [SICKAG/sick_safetyscanners_base] The c++ version driver has no data connected to the li (Issue #32)

Try adding these lines around your Async client, it might be that the comm_settigns are rejected by the sensor, since they are the wrong type, by reading the type from the sensor and updating it, it should work auto safety_scanner = std::make_unique<sick::AsyncSickSafetyScanner>(sensor_ip, tcp_port, comm_sett ings, cb); sick::datastructure::TypeCode type_code; safety_scanner->requestTypeCode(type_code); comm_settings.e_interface_type = type_code.getInterfaceType(); safety_scanner->run(); safety_scanner->changeSensorSettings(comm_settings);
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lenpuc commented 1 month ago

As far as I understood it, this resolved the issue. Therefore closing it

weiOverlord commented 1 month ago

Yes, the problem has been solved. Now that part of the code has been added, and the data is available now. Thank you very much for your help! Yes, the problem has been solved. Now that part of the code has been added, and the data is available now. Thank you very much for your help!

1059482396 @.***

 

------------------ 原始邮件 ------------------ 发件人: "SICKAG/sick_safetyscanners_base" @.>; 发送时间: 2024年10月17日(星期四) 下午5:23 @.>; @.**@.>; 主题: Re: [SICKAG/sick_safetyscanners_base] The c++ version driver has no data connected to the li (Issue #32)

Closed #32 as completed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>