def __init__(self): rospy.initnode('obstacle_avoidance') self.cmdvel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=10) self.rospy.Subscriber('dist_back', Float32, self.dist_back_callback) self.rospy.Subscriber('dist_right', Float32, self.dist_right_callback) self.rospy.Subscriber('dist_left', Float32, self.dist_left_callback)
def talker(): pub = rospy.Publisher('miprimertopicenROS', String, queuesize=10) rospy.initnode('talker', anonymous=True) rate = rospy.Rate(10) #10 hz while not rospy.isshutdown(): hellostr="Hola grupo de robotica %s" %rospy.gettime() rospy.loginfo(hellostr) pub.publish(hellostr) rate.sleep()
def __init__(self): rospy.initnode('wallfollower') self.safeDistance = 2 self.following = LEFT #f o l l o w i n g w a l l on LEFT or RIGHT self.listener = tf.TransformListener() self.publisher = rospy.Publisher('/cmd_vel', Twist, queue_size=10) self.subscriber = rospy.Subscriber('/base_scan', LaserScan, self.scanReceived) self.m = Marker.Markers() #used f o r draw ing in r v i z
#!/usr/bin/env python import rospy import math import tf2_ros import geometry_msgs.msg if __name__ == '__main__': rospy.initnode('tf_yippy_listener') tfBuffer = tf2_ros.Buffer() listener = tf2_ros.TransformListener(tfBuffer) # transform a point once every second rate = rospy.Rate(10.0) while not rospy.is_shutdown(): try: trans = tfBuffer.lookup_transform() rospy.spin()
def __init__(self, debug=True): rospy.initnode("CameraTest") self.image_sub = rospy.Subscriber("/angela/cameras/main/capture", Image, self.imageCallback) rospy.spin