Ronan0912 / ros_opentld

50 stars 47 forks source link

unlock if not empty #1

Closed sameerparekh closed 11 years ago

sameerparekh commented 11 years ago

The one important change here is that it unlocks the semaphore if the received frame is not empty, not if it is empty. The rest are minor cleanups.

Ronan0912 commented 11 years ago

The semaphore must be unlocked only one time when the smart pointer (img_buffer_ptr) points to an image. So If the empty condition is true (so the pointer points to an image) then the semaphore is unlocked. After when you will check if an image is arrived with the "newImageReceived()" method, the main thread will try to lock this semaphore and will wait until the reception of an image. By this way, you ever have the last received image assigned to the img_buffer_ptr.

sameerparekh commented 11 years ago

Thanks-- unfortunately I'm still not understanding. It appears to me from reading the code that empty is true when the img_buffer_ptr does -not- point to an image:

    if(img_buffer_ptr.get() == 0) {
            empty = true;
    }

Am I misreading this snippet?

-s

Ronan0912 commented 11 years ago

Indeed, empty is true when the img_buffer_ptr does -not- point to an image. But, when the image is obtained from this buffer with the "getLastImageFromBuffer()" after the "newImageReceived" method returned true (and locked the semaphore), the smart pointer is cleared (img_buffer_ptr.reset();). So, img_buffer_ptr.get() returns 0 when an image was read by the main thread or no image was read before.

Ronan0912 commented 11 years ago

I just merged your modifications for the launch files and your others cleanups (I don't understand why it doesn’t appear in the network page ... I think, I made a bad manipulation during the merge process).

Thank you,

Ronan