#! /usr/bin/env python import rospy from test_package.srv import my_custom_service_message,my_custom_service_messageRequest,my_custom_service_messageResponse from geometry_msgs.msg import Twist from math import radians
def turtle1_draw_square(radius,repetitions): pub = rospy.Publisher('/turtle1/cmd_vel', Twist, queue_size=10) rate = rospy.Rate(10) move_cmd = Twist() move_cmd.linear.x = radius turn_cmd = Twist() turn_cmd.angular.z = radians(90) print('go forward') for rep in range(repetitions): for i in range(4): for x in range(20): pub.publish(move_cmd) rate.sleep() print('turn right') for z in range(10): pub.publish(turn_cmd) rate.sleep()