Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect to nS3 via CPP driver? #27

Open
kinni318 opened this issue Apr 4, 2024 · 1 comment
Open

How to connect to nS3 via CPP driver? #27

kinni318 opened this issue Apr 4, 2024 · 1 comment

Comments

@kinni318
Copy link

kinni318 commented Apr 4, 2024

Hello,
Failed to connecting the nanoScan3 by the following steps...
We have no idea what caused this problem.
Could you some one to help on it?

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

2, Building via the command below;
g++ main.cpp -I../sick_safetyscanners_base/include/ -L. -lsick_safetyscanners_base -lboost_system -o main

3.Result of running $./main ;
[INFO]: Command Method Acknowledged.
terminate called after throwing an instance of 'sick::timeout_error'
what(): Timeout exceeded while waiting for sensor data [timeout: 5seconds]
......
PS: We can run sick_safetyscanners.launch and get data by python at the same PC and the same nonaScan3.

===>The file - main.cpp;<===

int main()
{

// Sensor IP and Port
    std::string sensor_ip_str = "192.168.1.2";
    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 CommPP Settings for Sensor streaming data
    sick::datastructure::CommSettings comm_settings;
    std::string host_ip_str = "192.168.1.21";
    comm_settings.host_ip = boost::asio::ip::address_v4::from_string(host_ip_str);
    comm_settings.host_udp_port = 0;
    
// Create a sensor instance
    auto safety_scanner = std::make_unique<sick::SyncSickSafetyScanner>(sensor_ip, tcp_port, comm_settings);

    // Receive one sensor data packet
    auto timeout = boost::posix_time::seconds(5);
    sick::datastructure::Data data = safety_scanner->receive(timeout);


std::cout << "hello" << std::endl;
//printf("hello\n");
return(1);

}
Thanks in advance.

@puck-fzi
Copy link
Collaborator

Hello, what is the IP of the sensor? is it the one configured in the CPP code? And is your host IP correctly configured?

And since you are using the .launch as well, maybe I think you want to use the ASync Interface https://github.com/SICKAG/sick_safetyscanners_base?tab=readme-ov-file#asynchronous-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants