From e7d4c6b2f5b2f3163fec8ca769791aafc838df3f Mon Sep 17 00:00:00 2001 From: Dxnil Date: Sun, 5 Nov 2023 18:55:31 +0300 Subject: [PATCH] =?UTF-8?q?Add=20new=20mover=20to=20make=20'=D0=94'=20and?= =?UTF-8?q?=20reformat=20code=20in=20square.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lesson_04/mover.py | 23 +++++++++++++++++++++-- lesson_04/square.py | 5 +++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lesson_04/mover.py b/lesson_04/mover.py index a61bebe..80446ac 100644 --- a/lesson_04/mover.py +++ b/lesson_04/mover.py @@ -21,15 +21,34 @@ class RurMover(Node): self.get_clock().sleep_for(Duration(seconds=1.0)) def main(self): - pass + self.publish_twist(0.0, -60) + self.publish_twist(0.5, 0) + self.publish_twist(-0.5, 0) + + self.publish_twist(0.0, 120) + self.publish_twist(1.5, 0) + + self.publish_twist(0.0, -120) + self.publish_twist(1.5, 0) + + self.publish_twist(0.0, -60) + self.publish_twist(0.5, 0) + + self.publish_twist(-0.5, 0) + self.publish_twist(0.0, -60) + self.publish_twist(1.5, 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 + main() diff --git a/lesson_04/square.py b/lesson_04/square.py index 21f4687..22c1bec 100644 --- a/lesson_04/square.py +++ b/lesson_04/square.py @@ -22,7 +22,7 @@ class RurMover(Node): def main(self): while True: - self.publish_twist(0, 90.0) + self.publish_twist(0.0, 90.0) self.publish_twist(3.0, 0.0) @@ -36,5 +36,6 @@ def main(args=None): mover.destroy_node() rclpy.shutdown() + if __name__ == '__main__': - main() \ No newline at end of file + main() -- GitLab