diff --git a/lesson_04/turtle_letter_move.py b/lesson_04/turtle_letter_move.py new file mode 100644 index 0000000000000000000000000000000000000000..4759431293be55ff85e286a36d0d26e980ba33a7 --- /dev/null +++ b/lesson_04/turtle_letter_move.py @@ -0,0 +1,44 @@ +import rclpy +from rclpy.node import Node +from rclpy.duration import Duration + +from geometry_msgs.msg import Twist +import math + + +class RurMover(Node): + def __init__(self): + super().__init__('minimal_publisher') + self.publisher_twist = self.create_publisher(Twist, 'turtle1/cmd_vel', 10) + self.main() + + def publish_twist(self, linear, angular): + msg = Twist() + msg.linear.x = float(linear) + msg.angular.z = math.radians(float(angular)) + self.publisher_twist.publish(msg) + self.get_clock().sleep_for(Duration(seconds=1.0)) + + def main(self): + self.publish_twist(0.0, 90.0) + self.publish_twist(12.0, 360.0) + self.publish_twist(2.0, 0.0) + self.publish_twist(-2.0, 0.0) + self.publish_twist(-3.0, 90.0) + # self.publish_twist(1, 0.0) + # self.publish_twist(0, 60.0) + # self.publish_twist(2, 0.0) + + +def main(args=None): + rclpy.init(args=args) + + mover = RurMover() + + rclpy.spin(mover) + + mover.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/setup.py b/setup.py index 9e5dc57746bf472f3cb9ce74d49c8f79078942e7..8ecebe77c23b17d7b8e6ba966b93745f3e01d948 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ setup( 'step_3 = lesson_04.step_3:main', 'square = lesson_04.square:main', 'mover = lesson_04.mover:main', + 'tlm = lesson_04.turtle_letter_move:main', ], }, )