ros-drivers / ros2_ouster_drivers

ROS2 Drivers for the Ouster OS-0, OS-1, and OS-2 Lidars
https://ouster.com/
Apache License 2.0
139 stars 79 forks source link

Disabled IPv6 - Failed to send lidar UDP data to destination host #94

Open Sollimann opened 2 years ago

Sollimann commented 2 years ago

In case you're getting this kind of error from the Lidar (OS0-128 in my case), I thought I should share a fix:

image

It could be that you're computer has IPv6 disabled by default. In my case the Intel NuC on the Clearpath Jackal has disabled IPv6 in the GRUB bootloaderen: /etc/default/grub. To fix the issue you can either enable IPv6 or your can make changes to the drivers client.cpp file. I did the latter:

  1. change hints.ai_family to AF_INET (line 77 ish) client.cpp

    memset(&hints, 0, sizeof hints);
    // hints.ai_family = AF_INET6;
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_DGRAM;
    hints.ai_flags = AI_PASSIVE;
  2. comment out the following (ish line 103 - 112) client.cpp

    // int off = 0;
    // if (setsockopt(
    //     sock_fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&off,
    //     sizeof(off)))
    // {
    //   std::cerr << "udp setsockopt(): " << impl::socket_get_error() <<
    //     std::endl;
    //   impl::socket_close(sock_fd);
    //   return SOCKET_ERROR;
    // }

related issue: https://github.com/ouster-lidar/ouster_example/issues/185

zehranrgi commented 1 year ago

hi, where is cpp files? I couldnt find it in drivers folder? @Sollimann