From edd0398c8f11667a08e4ede8555e2ac56e63797b Mon Sep 17 00:00:00 2001 From: Yurii Date: Mon, 8 Jan 2024 19:11:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=84=D0=B0=D0=B9=D0=BB,=20=D0=B2=D0=B4=D0=BE=D1=85?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D1=8F=D1=8E=D1=89=D0=B8=D0=B9=20=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BF=D0=B0=D1=85=D1=83=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B1=D1=83?= =?UTF-8?q?=D0=BA=D0=B2=D1=8B=20Y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lesson_04/basics.py | 17 ----------- lesson_04/{square.py => letter_Y.py} | 22 ++++++++------ lesson_04/mover.py | 35 ---------------------- lesson_04/step_0.py | 9 ------ lesson_04/step_1.py | 18 ------------ lesson_04/step_2.py | 31 -------------------- lesson_04/step_3.py | 44 ---------------------------- 7 files changed, 13 insertions(+), 163 deletions(-) delete mode 100644 lesson_04/basics.py rename lesson_04/{square.py => letter_Y.py} (60%) delete mode 100644 lesson_04/mover.py delete mode 100644 lesson_04/step_0.py delete mode 100644 lesson_04/step_1.py delete mode 100644 lesson_04/step_2.py delete mode 100644 lesson_04/step_3.py diff --git a/lesson_04/basics.py b/lesson_04/basics.py deleted file mode 100644 index 3dfb7d8..0000000 --- a/lesson_04/basics.py +++ /dev/null @@ -1,17 +0,0 @@ -import math - - -def to_degree(val): - return val*180/3.1415 - - -a = 3.14 -a = a/2 -print("В радианах:") -print(a) -print("В градусах:") -print(to_degree(a)) - -b = math.degrees(a) -print("В градусах библиотечное:") -print(b) diff --git a/lesson_04/square.py b/lesson_04/letter_Y.py similarity index 60% rename from lesson_04/square.py rename to lesson_04/letter_Y.py index 21f4687..5182d01 100644 --- a/lesson_04/square.py +++ b/lesson_04/letter_Y.py @@ -12,23 +12,26 @@ class RurMover(Node): self.publisher_twist = self.create_publisher(Twist, 'turtle1/cmd_vel', 10) self.main() - def publish_twist(self, linear, angular): - self.get_logger().info('Linear: "%d", angular: "%d"' % (linear, angular)) + def publish_twist(self, linear: float, angular=0.0): msg = Twist() msg.linear.x = float(linear) - msg.angular.z = math.radians(float(angular)) + msg.angular.z = angular self.publisher_twist.publish(msg) self.get_clock().sleep_for(Duration(seconds=1.0)) def main(self): - while True: - self.publish_twist(0, 90.0) - self.publish_twist(3.0, 0.0) + self.publish_twist(0, -math.pi / 3) + self.publish_twist(3.0) + self.publish_twist(0, 2 * math.pi / 3) + self.publish_twist(3.0) + self.publish_twist(0, math.pi) + self.publish_twist(3.0) + self.publish_twist(0, math.pi / 6) + self.publish_twist(3.5) def main(args=None): rclpy.init(args=args) - mover = RurMover() rclpy.spin(mover) @@ -36,5 +39,6 @@ def main(args=None): mover.destroy_node() rclpy.shutdown() -if __name__ == '__main__': - main() \ No newline at end of file + +if __name__ == "__main__": + main() diff --git a/lesson_04/mover.py b/lesson_04/mover.py deleted file mode 100644 index a61bebe..0000000 --- a/lesson_04/mover.py +++ /dev/null @@ -1,35 +0,0 @@ -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): - self.get_logger().info('Linear: "%d", angular: "%d"' % (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): - pass - - -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/lesson_04/step_0.py b/lesson_04/step_0.py deleted file mode 100644 index 4fa986c..0000000 --- a/lesson_04/step_0.py +++ /dev/null @@ -1,9 +0,0 @@ -import rclpy - - -def main(args=None): - rclpy.init(args=args) - rclpy.shutdown() - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/lesson_04/step_1.py b/lesson_04/step_1.py deleted file mode 100644 index 1a43ae0..0000000 --- a/lesson_04/step_1.py +++ /dev/null @@ -1,18 +0,0 @@ -import rclpy -from rclpy.node import Node - -class RurMover(Node): - def __init__(self): - super().__init__('rur_mover') - -def main(args=None): - rclpy.init(args=args) - mover = RurMover() - - rclpy.spin(mover) - - mover.destroy_node() - rclpy.shutdown() - -if __name__ == '__main__': - main() diff --git a/lesson_04/step_2.py b/lesson_04/step_2.py deleted file mode 100644 index b62db7a..0000000 --- a/lesson_04/step_2.py +++ /dev/null @@ -1,31 +0,0 @@ -import rclpy -from rclpy.node import Node - -from geometry_msgs.msg import Twist - - -class RurMover(Node): - def __init__(self): - super().__init__('rur_mover') - self.publisher_twist = self.create_publisher(Twist, 'turtle1/cmd_vel', 10) - self.main() - - def main(self): - msg = Twist() - msg.linear.x = 2.0 - msg.angular.z = -3.14 - self.publisher_twist.publish(msg) - - -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/lesson_04/step_3.py b/lesson_04/step_3.py deleted file mode 100644 index e4b7ac3..0000000 --- a/lesson_04/step_3.py +++ /dev/null @@ -1,44 +0,0 @@ -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, 90.0) - self.publish_twist(3, 0.0) - self.publish_twist(0, -120.0) - self.publish_twist(1, 0.0) - self.publish_twist(0, -120.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 -- GitLab