Cannot use cv_bridge


#1

I get the following error

init_DRLagent:40: 'NoneType' object has no attribute 'imgmsg_to_cv2'

on the following code

    # internal keras-rl agent to persist
    @nrp.MapVariable("agent", initial_value=None, scope=nrp.GLOBAL)
    @nrp.MapVariable("bridge", initial_value=None, scope=nrp.GLOBAL)
    # subscribe to images from the robot
    @nrp.MapRobotSubscriber("camera", Topic('/husky/camera', sensor_msgs.msg.Image))
    @nrp.MapRobotSubscriber("vel", Topic('/husky/cmd_vel', geometry_msgs.msg.Twist))
    @nrp.Robot2Neuron()
    def init_DRLagent(t, agent, bridge, camera, vel):
        # some code...
    	    
    	    import numpy as np
    	    # OpenCV bridge for ROS <-> CV image conversion
    	    from cv_bridge import CvBridge
    	        
    	    bridge.value = CvBridge()
            # convert the ROS image to an OpenCV image and Numpy array
            cv_image = bridge.value.imgmsg_to_cv2(camera.value, "rgb8")
            numpy_image = np.expand_dims(cv_image, axis=0)

            obs_shape = numpy_image.shape
            nb_actions = 2
            ...

don’t know where to go with this, as I can from cv_bridge import CvBridge in my enviroment and access the member function imgmsg_to_cv2(...)

would appreciate any help