yarp icon indicating copy to clipboard operation
yarp copied to clipboard

Error : Failed to connect to the camera module in Gazebo with yarp server

Open 16239014 opened this issue 6 months ago • 1 comments

@LoreMoretti I am working on gazebo with an icub humanoid robot model running this example https://icub-tech-iit.github.io/documentation/sw_installation/check_your_installation/#check-icub

when I run these commands it shows that it did not connect with the camera. can you help to resolve it?

To view the output from the cameras in terminals

yarpview --name /view/left
yarpview --name /view/right

And to connect them:

yarp connect /icubSim/cam/left/rgbImage:o /view/left
yarp connect /icubSim/cam/right/rgbImage:o /view/right

I also try code:

import yarp
import sys
# Initialize YARP network
yarp.Network.init()

# Create a port to read from the camera
image_port = yarp.Port()
image_port.open("/client/image/in")

# Connect to the camera port
if not yarp.Network.connect("/icubSim/cam/left/rgbImage:0", "/client/image/in"):
    print("Failed to connect to the camera 123.")
    sys.exit()

# Prepare a YARP image to receive data
yarp_image = yarp.ImageRgb()
yarp_image.resize(640, 480)  # Set the resolution

# Read from the port
if image_port.read(yarp_image):
    print("Image received!")

# Close the port
image_port.close()
yarp.Network.fini()

16239014 avatar Aug 01 '24 10:08 16239014