Untitled
unknown
plain_text
10 months ago
647 B
2
Indexable
Never
import rospy import math from geometry_msgs.msg import Twist from turtlesim.msg import Pose def move(): rospy.init_node('square') pub = rospy.Publisher('/turtle1/cmd_vel', Twist) rospy.sleep(1) twist = Twist() side_length = 2.0 while not rospy.is_shutdown(): twist.linear.x=1.0 twist.angular.z=0.0 for _ in range(int(side_length * 10)): pub.publish(twist) rospy.sleep(0.1) twist.linear.x=0.0 twist.angular.z=(math.pi / 2.0) for _ in range(10): pub.publish(twist) rospy.sleep(0.1) if __name__ == '__main__': move()