ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I think I found some bugs in the RCPRG laser driver. Debugging the code I saw that when laser topic stops being published, the driver gets stuck in a read of zero bytes because the buffer used to store data received from the sensor is already full (10000 bytes) without having received a valid sensor scan packet.

char buf[10000];
    fd_set rfds;
    struct timeval tv;
    int retval, len;
    len = 0;

    do {
        FD_ZERO(&rfds);
        FD_SET(sockDesc, &rfds);

        tv.tv_sec = 0;
        tv.tv_usec = 50000;
        retval = select(sockDesc + 1, &rfds, NULL, NULL, &tv);
        if (retval) {
            len += read(sockDesc, buf + len, 10000 - len);
        }
    } while ((buf[0] != 0x02) || (buf[len - 1] != 0x03));

The problems is more probable to happen when the scan message data includes remission values and angular resolution is set to 0.25ยบ, because a complete message is 8192 bytes. I set the buffer dimension to 20000 and it seems to work but I think that a more elegant solution would be to use a circular buffer. Furthermore I would like to change the exit condition of the while cycle because it doesn't guarantee that the loop breaks in case of receiving a complete scan data msg + some bytes of the next one.