From dcec79ea89e65c9e58756ff3270f529f66ca9c89 Mon Sep 17 00:00:00 2001 From: akshita-iitk Date: Mon, 26 May 2025 15:56:09 +0530 Subject: [PATCH 1/3] Create Akshita Singh --- Akshita Singh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Akshita Singh diff --git a/Akshita Singh b/Akshita Singh new file mode 100644 index 0000000..4f62ee8 --- /dev/null +++ b/Akshita Singh @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +import rclpy +from rclpy.node import Node +from geometry_msgs.msg import Twist +from turtlesim.msg import Pose + +class DrawSquareNode(Node): + + x_min = 5.544444561004639 + y_min = 5.544444561004639 + x_max = x_min + 3 + y_max = y_min + 3 + + def __init__(self): + super().__init__("draw_square") + self.cmd_vel_pub = self.create_publisher(Twist, '/turtle1/cmd_vel', 10) + self.pose_sub = self.create_subscription(Pose, '/turtle1/pose', self.pose_callback, 10) + self.get_logger().info("Draw square node has been started") + self.counter = -1 + + def pose_callback(self, pose: Pose): + vel = Twist() + x_min = DrawSquareNode.x_min + y_min = DrawSquareNode.y_min + x_max = DrawSquareNode.x_max + y_max = DrawSquareNode.y_max + x = pose.x + y = pose.y + + # self.get_logger().info(f'Hi {x}') + + if(x == x_min and y == y_min): + self.counter += 1 + self.get_logger().info(f'Counter = {self.counter}') + + if((x>x_min-0.01 and xy_min)): + vel.linear.y = -2.0 + vel.linear.x = 0.0 + + elif((y>y_min-0.01 and yx_max-0.01 and xy_max-0.01 and yx_min)): + vel.linear.x = -2.0 + vel.linear.y = 0.0 + + self.cmd_vel_pub.publish(vel) + +def main(args=None): + rclpy.init(args=args) + node = DrawSquareNode() + rclpy.spin(node) + rclpy.shutdown() + +if(__name__ == '__main__'): + main() From 439efffa3d6568738915e3b788abc9e9e561bf1e Mon Sep 17 00:00:00 2001 From: akshita-iitk Date: Mon, 26 May 2025 16:01:16 +0530 Subject: [PATCH 2/3] Delete Akshita Singh --- Akshita Singh | 61 --------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 Akshita Singh diff --git a/Akshita Singh b/Akshita Singh deleted file mode 100644 index 4f62ee8..0000000 --- a/Akshita Singh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 -import rclpy -from rclpy.node import Node -from geometry_msgs.msg import Twist -from turtlesim.msg import Pose - -class DrawSquareNode(Node): - - x_min = 5.544444561004639 - y_min = 5.544444561004639 - x_max = x_min + 3 - y_max = y_min + 3 - - def __init__(self): - super().__init__("draw_square") - self.cmd_vel_pub = self.create_publisher(Twist, '/turtle1/cmd_vel', 10) - self.pose_sub = self.create_subscription(Pose, '/turtle1/pose', self.pose_callback, 10) - self.get_logger().info("Draw square node has been started") - self.counter = -1 - - def pose_callback(self, pose: Pose): - vel = Twist() - x_min = DrawSquareNode.x_min - y_min = DrawSquareNode.y_min - x_max = DrawSquareNode.x_max - y_max = DrawSquareNode.y_max - x = pose.x - y = pose.y - - # self.get_logger().info(f'Hi {x}') - - if(x == x_min and y == y_min): - self.counter += 1 - self.get_logger().info(f'Counter = {self.counter}') - - if((x>x_min-0.01 and xy_min)): - vel.linear.y = -2.0 - vel.linear.x = 0.0 - - elif((y>y_min-0.01 and yx_max-0.01 and xy_max-0.01 and yx_min)): - vel.linear.x = -2.0 - vel.linear.y = 0.0 - - self.cmd_vel_pub.publish(vel) - -def main(args=None): - rclpy.init(args=args) - node = DrawSquareNode() - rclpy.spin(node) - rclpy.shutdown() - -if(__name__ == '__main__'): - main() From d2058c6898aed1f5b0b5d3cbb50778e486719796 Mon Sep 17 00:00:00 2001 From: akshita-iitk Date: Mon, 26 May 2025 16:01:48 +0530 Subject: [PATCH 3/3] Create Assignment_1 --- Akshita/Assignment_1 | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Akshita/Assignment_1 diff --git a/Akshita/Assignment_1 b/Akshita/Assignment_1 new file mode 100644 index 0000000..4f62ee8 --- /dev/null +++ b/Akshita/Assignment_1 @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +import rclpy +from rclpy.node import Node +from geometry_msgs.msg import Twist +from turtlesim.msg import Pose + +class DrawSquareNode(Node): + + x_min = 5.544444561004639 + y_min = 5.544444561004639 + x_max = x_min + 3 + y_max = y_min + 3 + + def __init__(self): + super().__init__("draw_square") + self.cmd_vel_pub = self.create_publisher(Twist, '/turtle1/cmd_vel', 10) + self.pose_sub = self.create_subscription(Pose, '/turtle1/pose', self.pose_callback, 10) + self.get_logger().info("Draw square node has been started") + self.counter = -1 + + def pose_callback(self, pose: Pose): + vel = Twist() + x_min = DrawSquareNode.x_min + y_min = DrawSquareNode.y_min + x_max = DrawSquareNode.x_max + y_max = DrawSquareNode.y_max + x = pose.x + y = pose.y + + # self.get_logger().info(f'Hi {x}') + + if(x == x_min and y == y_min): + self.counter += 1 + self.get_logger().info(f'Counter = {self.counter}') + + if((x>x_min-0.01 and xy_min)): + vel.linear.y = -2.0 + vel.linear.x = 0.0 + + elif((y>y_min-0.01 and yx_max-0.01 and xy_max-0.01 and yx_min)): + vel.linear.x = -2.0 + vel.linear.y = 0.0 + + self.cmd_vel_pub.publish(vel) + +def main(args=None): + rclpy.init(args=args) + node = DrawSquareNode() + rclpy.spin(node) + rclpy.shutdown() + +if(__name__ == '__main__'): + main()