Getting error as - "ERROR: Unable to communicate with master!" [closed]
Hi,
I am trying to capture images (python code) from the "/camera/rgb/image_color" topic on which images are published from kinect and saving them locally. But call back of subscriber stops and doesn't even get called up after 1-2 times calling up. So could capture image only once but stops later. I want python code to capture image from some topic and store them locally. Please suggest what should I use webcam or kinect and how.
Code is as follows-
import roslib
roslib.load_manifest('beginner_tutorials')
import sys
import rospy
import cv
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
class image_converter:
def __init__(self):
#self.image_pub = rospy.Publisher("image_topic_2",Image)
print "1"
cv.NamedWindow("Image window", 1)
self.bridge = CvBridge()
self.image_sub = rospy.Subscriber("/camera/rgb/image_color",Image,self.callback)
def callback(self,data):
print "2"
try:
cv_image = self.bridge.imgmsg_to_cv(data, "bgr8")
except CvBridgeError, e:
print e
#(cols,rows) = cv.GetSize(cv_image)
#if cols > 60 and rows > 60 :
# cv.Circle(cv_image, (50,50), 10, 255)
cv.SaveImage("foo.png", cv_image)
#cv.ShowImage("Image window", cv_image)
#cv.WaitKey(3)
try:
pass
#self.image_pub.publish(self.bridge.cv_to_imgmsg(cv_image, "bgr8"))
except CvBridgeError, e:
print e
def main(args):
#app = wx.App()
ic = image_converter()
rospy.init_node('image_converter', anonymous=True)
try:
rospy.spin()
except KeyboardInterrupt:
print "Shutting down"
cv.DestroyAllWindows()
if __name__ == '__main__':
main(sys.argv)
Did you run `roscore` to start master?
Thanks alot for responding No, in Robo machine I tried these commands, roslaunch turtlebot_bringup minimal.launch rosrun turtlebot_dashboard turtlebot_dashboard roslaunch openni_launch openni.launch so I don't think it requres roscore to be started. Please let me know if there is some error in code.
No clue about the code. Since you're using roslaunch, roscore will be running. It's another issue then.