13 from geometry_msgs.msg
import Twist
14 from std_msgs.msg
import String
21 implements a rotating motion. 25 def __init__(self, cmd_vel_topic, log_topic, yaw_rate = 1.2):
26 threading.Thread.__init__(self)
27 self.
pub_cmd = rospy.Publisher(cmd_vel_topic,Twist)
28 self.
pub_log = rospy.Publisher(log_topic,String)
31 self.
rate = rospy.Rate(freq)
53 start = rospy.get_rostime()
57 rotate_count = max_rotate_count
60 while not rospy.is_shutdown()
and not self.
_stop:
61 if rotate_count == max_rotate_count:
62 if twist.angular.z > 0:
66 update = mod*yaw_rate/10.0
68 while math.fabs(twist.angular.z) <= yaw_rate:
69 twist.angular.z = twist.angular.z + update
70 self.pub_cmd.publish(twist)
74 twist.angular.z = mod*yaw_rate
78 now = rospy.get_rostime()
79 msg =
"Rotate: " + str(now.secs - start.secs)
81 self.pub_cmd.publish(twist)
88 self.pub_log.publish(t)
def __init__(self, cmd_vel_topic, log_topic, yaw_rate=1.2)