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

braccio_xy_bb_target.py stuck waiting for image data #4

Open
Wael-Mas opened this issue Feb 10, 2023 · 8 comments
Open

braccio_xy_bb_target.py stuck waiting for image data #4

Wael-Mas opened this issue Feb 10, 2023 · 8 comments

Comments

@Wael-Mas
Copy link

Wael-Mas commented Feb 10, 2023

I've been trying to redo this project, Everything works fine till i get to the 5th step. I run the python script (braccio_xy_bb_target.py). I tried the poses like "home" and "up" it works fine but when I try "calibrate " nothing happens. Can you help with that?

In the braccio_xy_target script, I used some print statements in the script to find where it breaks. It gets stuck in the while loop.

while len(self.current_image.data ==0;
time.sleep(10)

@stedn stedn changed the title (braccio_xy_bb_target.py) error braccio_xy_bb_target.py stuck waiting for image data Feb 10, 2023
@stedn
Copy link
Member

stedn commented Feb 10, 2023

So it's waiting to make sure there is image data in the popup camera window. Is the image popping up? Have you closed the popup window? If the image doesn't appear then your camera might be streaming to a different location.

Did you go through the DroidCam setup at the bottom of the README or are you using a different setup for your usb_cam? If so you might need to change where it is streaming to and/or where ROS is listening for it.

@Wael-Mas
Copy link
Author

Once I type in 'c' for calibration, nothing pops up at all.
Regarding the camera. Im using a USB webcam, not a phone so I skipped the DroidCam section.
The camera is streaming to /dev/video0.
In (detection.launch) and (demo.launch) it's selected as:
/dev/video2
so edited it to: /dev/video0

I also tried the following for launching the backend:

cd braccio_opencv_ws
source devel/setup.bash
roslaunch su_chef demo.launch start_detect:=true connect_braccio:=true video_device:=/dev/video0

Still no response.
Is that it or further changes are needed?

@stedn
Copy link
Member

stedn commented Feb 10, 2023

That seems alright, but it's hard to say. I would first and foremost check that your usb_cam package is set up correctly. Try running the simplest ROS usb_cam example you can find. This one might be a good start: https://github.com/ros-drivers/usb_cam/blob/develop/launch/usb_cam-test.launch If you can get that working then you can transfer the matching info into the usb_cam block in su_chef's detection.launch.

Also if no window is opening at all, then it sounds like you might also have a problem with your cv2 install. Just running cv2.namedWindow('image') from an ipython shell should open a blank popup image window. But check that usb_cam works first and then check that you cv2 installed correctly.

@Wael-Mas
Copy link
Author

Wael-Mas commented Feb 10, 2023

Tried the usb_cam example and it works fine, and transferred the matching parameters to detection.launch .
The problem still not solved. How can I go about the cv2.namedWindow('image') function, tried it in a ipython shell but nothing showed up?

@stedn
Copy link
Member

stedn commented Feb 11, 2023

That sounds like a problem with your build of openCV perhaps. Not sure I can help debug that. Maybe try creating a new virtual env on your machine, with only opencv-python installed. Then you can isolate how to make that display on your machine.

@Wael-Mas
Copy link
Author

Will do so and let you know what happens then.
Many thanks Will.

@Wael-Mas
Copy link
Author

The function NamedWindow() now shows the pop-up window. However, it's a blank black window. The print statements show that code is still stuck in the while function too.

@stedn
Copy link
Member

stedn commented Feb 13, 2023

One thing to check is to put a print statement inside cal_im_callback (here: https://github.com/lots-of-things/su_chef/blob/main/scripts/braccio_xy_bb_target.py#L76) to see if that callback is even being triggered and what if anything is being returned in the ros_data variable there.

If the callback won't run, that means that the /usb_cam/image_raw/compressed isn't publishing properly. I can only guess for how to fix that. Maybe for your webcam you don't get a compressed image, which would explain why https://github.com/ros-drivers/usb_cam/blob/develop/launch/usb_cam-test.launch worked since you were using just /usb_cam/image_raw.

If the callback runs, but ros_data doesn't have a data field then you can inspect the ros_data variable to see what is being sent.

Really sorry that your setup happens to be so funky. Getting all the peripherals to work with ROS seems to be the most difficult part.

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