def __init__(self): self.node_name = 'cv_bridge_demo' rospy.init_node(self.node_name) #what we do during shutdown rospy.on_shutdown(self.cleanup) #create the opencv display window for the rgb image self.cv_window_name = self.node_name cv.NamedWindow(self.cv_window_name,cv.CV_WINDOW_NORMAL) cv.MoveWindow(self.cv_window_name,25,75) # and one for the depth image cv.NamedWindow("depth image",cv.CV_WINDOW_NORMAL) cv.MoveWindow('depth image',25,300) # create the cv_bridge object self.bridge = CvBridge() # subscribe to the camera image and depth topics and set # the appropriate callbacks self.image_sub = rospy.Subscriber('/camera/rgb/image_color',Image,self.image_callback) self.depth_sub = rospy.Subcriber('/camera/depth_registered/image_rect',Image,self.depth_callback) rospy.loginfo("waiting for the image topics...")
def mission(): desired_publisher = rospy.Publisher('borbcat/desired', State, queue_size=1) current_publisher = rospy.Publisher('borbcat/state', State, queue_size=1) rospy.Subscriber('sensors/imu', Imu, imu_callback) rospy.Subcriber('sensors/depth', Depth, depth_callback) desired_msg = State() desired_msg.header.seq = 0 desired_msg.header.timestamp = rospy.get_rostime() current_msg = State() current_msg.header.seq = 0 current_msg.header.timestamp = rospy.get_rostime() rate = rospy.Rate(10) while not rospy.is_shutdown(): desired_msg.state = [0, 0, 0, 0, 0, 0] desired_msg.header.seq += 1 desired_msg.header.timestamp = rospy.get_rostime() desired_publisher.publish(desired_msg) current_publisher.publish(current_msg) rate.sleep()
def __init__(self, mbed): self.mbed = mbed self.finger_state_sub = rospy.Subscriber("/finger_state", UInt8MultiArray, self.finger) self.pose_sub = rospy.Subcriber("/adjusted_pose", PoseStamped, self.pose) self.cmd = {"finger":0x0a, "pose":0x0b}
def inicializar(self): receptor = rospy.Subcriber( "angulos", Int8MultiArray, actualizarValoresServos) #se crea el suscriptor del topic rospy.spin()
#caffemodel = os.path.join(cfg.DATA_DIR, 'faster_rcnn_models', # NETS[args.demo_net][1]) if not os.path.isfile(caffemodel): raise IOError(('{:s} not found.\nDid you run ./data/script/' 'fetch_faster_rcnn_models.sh?').format(caffemodel)) if args.cpu_mode: caffe.set_mode_cpu() else: caffe.set_mode_gpu() caffe.set_device(args.gpu_id) cfg.GPU_ID = args.gpu_id net = caffe.Net(prototxt, caffemodel, caffe.TEST) print '\n\nLoaded network {:s}'.format(caffemodel) # Warmup on a dummy image im = 128 * np.ones((300, 500, 3), dtype=np.uint8) for i in xrange(2): _, _ = im_detect(net, im) roi_pub = rospy.Publisher('fasterrcnn', output, queue_size=100) rawimage_sub = rospy.Subcriber("/camera/rgb/image_raw", Image, rawCallback) rospy.init_node('fasterrcnn', anonymous=True) while cv_frame == None: rospy.spinonce() demo(net, cv_frame, roi_pub) plt.show()
rate = rospy.Rate(10) while fabs(goal.orientation-actuator.position())>0.01: if a.is_preempt_requested(): success = False break feedback.current_orientation = actuator.position() a.publish_feedback(feedback) rate.sleep() result.final_orientation = actuator.position() if success: a.set_succeeded(result) else: a.set_preempted(result) if __name__ == '__main__': actuator = FakeActuator() # initialize the node rospy.init_node('fake') # topic for the volume t = rospy.Subcriber('fake/volume',Float32,volume_callback) # service for the light s = rospy.Service('fake/light',Light,light_callback) # Action for the position a = actionlib.SimpleActionServer('fake/position',RotationAction,exxcute_cb = rotation_callback,False) a.start() # start everything rospy.spin()
def __init__(self): self.laserProj = LaserProjection() self.pcPub = rospy.Publisher("/laserPointCloud", pc2, queue_size = 1) self.laserSub = rospy.Subcriber("/scan", LaserScan, self.laserCallback)