Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import rospy
00019 import math
00020 from geometry_msgs.msg import Twist
00021
00022
00023 def velPub():
00024 rospy.init_node("test_publisher_twist", anonymous=True)
00025
00026 pub_vel = rospy.Publisher("command", Twist, queue_size=1)
00027 rospy.sleep(1.0)
00028
00029 freq = 10.0
00030 r = rospy.Rate(freq)
00031
00032 a = 0.5
00033 b = 0.1 * (2.0*math.pi/freq)
00034 c = -math.pi/2.0
00035 d = a
00036 i = 0.0
00037
00038 vel_msg = Twist()
00039 time = rospy.Time.now()
00040
00041 while not rospy.is_shutdown():
00042 vel = a*math.sin(b*i+c) + d
00043
00044 vel_msg.angular.z = vel
00045 pub_vel.publish(vel_msg)
00046 i += 1.0
00047 r.sleep()
00048
00049 if __name__ == '__main__':
00050 try:
00051 velPub()
00052 except rospy.ROSInterruptException: pass