diff --git a/markdown/ros/node/node.rst b/markdown/ros/node/node.rst index fc06f21d..431f298c 100644 --- a/markdown/ros/node/node.rst +++ b/markdown/ros/node/node.rst @@ -88,6 +88,20 @@ Steps to Create a Node in Python chmod +x node_hello_ros.py +- To add your newly created script, in CMakeLists.txt file + - Open CmakeLists.txt in your package + - add the following piece of code as follows + +.. code:: shell + + install(PROGRAMS + scripts/node_hello_ros.py + DESTINATION lib/${PROJECT_NAME} + ) + + + + - Now to run your node: - Open a terminal and run: @@ -164,4 +178,4 @@ Command: ros2 node .. code:: shell - ros2 node kill + ros2 node kill \ No newline at end of file diff --git a/markdown/ros/package/package.rst b/markdown/ros/package/package.rst index abd1acf8..50216396 100644 --- a/markdown/ros/package/package.rst +++ b/markdown/ros/package/package.rst @@ -28,7 +28,7 @@ You can create a package using either CMake or Python, which are officially supp ROS 2 CMake packages each have their own minimum required contents: -.. code-block:: console +.. note:: * CMakeLists.txt file that describes how to build the code within the package * include/ directory containing the public headers for the package diff --git a/markdown/selectiontask24/Electronics_selection.rst b/markdown/selectiontask24/Electronics_selection.rst index dce6b4af..2e4927d0 100644 --- a/markdown/selectiontask24/Electronics_selection.rst +++ b/markdown/selectiontask24/Electronics_selection.rst @@ -22,7 +22,7 @@ the problem statement. Your performance will determine your score, and points wi **Qualification Criteria** -To progress to the next stage, which is the interview phase, you must accumulate a minimum of 7 points in total. These +To progress to the next stage, which is the interview phase, you must accumulate a minimum of 5 points in total. These points will be awarded after evaluating your submissions. Therefore, ensure you put your best foot forward for a chance to advance! @@ -60,7 +60,7 @@ Task Description: 1. Servo Motor Control: Rotate a servo motor based on the input from a potentiometer. The servo should move proportionally to the potentiometer's position. 2. Angle Display: Print the current angle of the servo motor on an OLED screen. Ensure that the displayed angle accurately reflects the servo's position. - 3. Analyze the provided code and submit the output as demonstrated in the video. 5 pts + 3. Analyze the provided code and submit the output as demonstrated in the video. Expected Output ~~~~~~~~~~~~~~~ @@ -68,7 +68,14 @@ Expected Output .. raw:: html -

+
+ + + +.. note:: + + If you don't have hardware available, you can use a simulator such as `Wokwi `__ + Task 1B @@ -77,7 +84,7 @@ Task 1B elevates the complexity with more intricate problems and higher point al Task Description: ~~~~~~~~~~~~~~~~~ -Light up six LEDs using only three GPIO pins of Arduino/ESP32/Microcontroller. **5 pts** +Light up six LEDs using only three GPIO pins of Arduino/ESP32/Microcontroller. Expected Output ~~~~~~~~~~~~~~~ @@ -85,7 +92,7 @@ Expected Output .. raw:: html -

+

Level 2 - Expert Territory: 8pts @@ -96,7 +103,7 @@ substantial point rewards. Task Description ^^^^^^^^^^^^^^^^ PCB Designing - Create a schematic, perform routing, and submit a Gerber file. Additionally, provide screenshots of the -schematics and a text file explaining your approach and detailing the schematic. 10 pts +schematics and a text file explaining your approach and detailing the schematic. Problem Statement @@ -108,4 +115,4 @@ track size to handle output currents of up to 2 Amps accordingly. The **Deadline** for completing the task: **15th October, 2024** -Head over to `Submissions <./submissions.rst>`__ to submit your work \ No newline at end of file +Head over to `Submissions `__ to submit your work \ No newline at end of file diff --git a/markdown/selectiontask24/ROS_selection_task24.rst b/markdown/selectiontask24/ROS_selection_task24.rst index 27614bde..00877692 100644 --- a/markdown/selectiontask24/ROS_selection_task24.rst +++ b/markdown/selectiontask24/ROS_selection_task24.rst @@ -41,7 +41,7 @@ Expected Output

-.. caution:: THE Candy SHOULD BE VERTICAL . +.. caution:: The CANDY should be VERTICAL. Also the max number of spirals can be of your choice but 3 spirals are required. Hints ----- @@ -55,86 +55,86 @@ Hints - Use linear velocity and angular velocity to get this done. - Keep tracking the distance travelled so as to know when to stop. You - can refer to Overview of rospy for more hint + can refer to Overview of rclpy for more hint Sample Code Snippet ----------------------- **Question:** Write a python code to move ROS's turtlesim bot on a straight path -while bot's distance is less than 6. +while bot's distance is less than 3. .. code-block:: python - - #!/usr/bin/env python3 - - import rclpy - from rclpy.node import Node - from geometry_msgs.msg import Twist - from turtlesim.msg import Pose - - my_X = 0.0 - my_Y = 0.0 - x_dist = 8.0 - - # Subscriber callback that gives the position of the turtle (x & y) - def pose_callback(pose): - global my_X, my_Y - my_X = pose.x - my_Y = pose.y - node.get_logger().info(f"Robot X = {pose.x}: Robot Y = {pose.y}") - - class MoveTurtle(Node): - def __init__(self, lin_vel): - super().__init__('move_turtle') - self.publisher_ = self.create_publisher(Twist, '/turtle1/cmd_vel', 10) - self.subscriber_ = self.create_subscription(Pose, '/turtle1/pose', pose_callback, 10) - self.lin_vel = lin_vel - self.timer = self.create_timer(0.1, self.move_callback) # 10hz - self.vel_msg = Twist() - - def move_callback(self): - global my_X, x_dist - - # Set the linear velocity - self.vel_msg.linear.x = self.lin_vel - self.vel_msg.linear.y = 0.0 # Ensure this is a float - self.vel_msg.linear.z = 0.0 # Ensure this is a float - self.vel_msg.angular.x = 0.0 - self.vel_msg.angular.y = 0.0 - self.vel_msg.angular.z = 0.0 - - self.get_logger().info(f"Linear Vel = {self.lin_vel}") - - # Stop the turtle when it reaches x_dist - if my_X >= x_dist: - self.get_logger().info("Turtle Reached destination") - self.get_logger().warn("Stopping Turtle") - - # Set the velocity to zero to stop the turtle - self.vel_msg.linear.x = 0.0 - self.publisher_.publish(self.vel_msg) - rclpy.shutdown() - else: - self.publisher_.publish(self.vel_msg) - - def main(args=None): - rclpy.init(args=args) - - lin_vel = 2.0 # Set linear velocity - global node - node = MoveTurtle(lin_vel) - - try: - rclpy.spin(node) - except KeyboardInterrupt: - pass - finally: - node.destroy_node() + + #!/usr/bin/env python3 + + import rclpy + from rclpy.node import Node + from geometry_msgs.msg import Twist + from turtlesim.msg import Pose + import math + + class MoveTurtle(Node): + + def __init__(self): + super().__init__('move_turtle') + self.start_x = None + self.start_y = None + self.target_distance = 3.0 # Distance to move in pixels + self.lin_vel = 2.0 # Linear velocity + + # Create a publisher for controlling the turtle's velocity + self.pub = self.create_publisher(Twist, '/turtle1/cmd_vel', 10) + # Create a subscriber for getting the turtle's position + self.sub = self.create_subscription(Pose, '/turtle1/pose', self.pose_callback, 10) + + def pose_callback(self, pose): + if self.start_x is None and self.start_y is None: + # Set the starting position when the first pose message is received + self.start_x = pose.x + self.start_y = pose.y + self.get_logger().info(f"Starting position set to X = {self.start_x:.2f}, Y = {self.start_y:.2f}") + + # Calculate the distance from the starting position + distance = math.sqrt((pose.x - self.start_x) ** 2 + (pose.y - self.start_y) ** 2) + self.get_logger().info(f"Distance from start = {distance:.2f}") + + # Create a Twist message to set the turtle's velocity + vel = Twist() + vel.linear.x = self.lin_vel + vel.linear.y = 0.0 + vel.linear.z = 0.0 + vel.angular.x = 0.0 + vel.angular.y = 0.0 + vel.angular.z = 0.0 + + if distance >= self.target_distance: + self.get_logger().info("Turtle reached the target distance") + vel.linear.x = 0.0 # Stop the turtle + self.get_logger().warn("Stopping Turtle") + self.pub.publish(vel) + rclpy.shutdown() + else: + self.pub.publish(vel) + + def main(args=None): + rclpy.init(args=args) + move_turtle_node = MoveTurtle() + rclpy.spin(move_turtle_node) + move_turtle_node.destroy_node() rclpy.shutdown() - if __name__ == '__main__': - main() + if __name__ == '__main__': + main() + + + + +.. Output video +.. ----------------------- + +.. .. raw:: html +..

Commands used: @@ -179,4 +179,4 @@ Follow the instructions given below to get started with the task. the official `ROSWIKI `__ if you need help with anything regarding ROS2. -Head over to `Submissions <./submissions.rst>`__ to submit your work +Head over to `Submissions `__ to submit your work \ No newline at end of file diff --git a/markdown/selectiontask24/cad1.png b/markdown/selectiontask24/cad1.png new file mode 100644 index 00000000..f8e57489 Binary files /dev/null and b/markdown/selectiontask24/cad1.png differ diff --git a/markdown/selectiontask24/cad_sel.rst b/markdown/selectiontask24/cad_sel.rst index c41409f7..e90cf9ef 100644 --- a/markdown/selectiontask24/cad_sel.rst +++ b/markdown/selectiontask24/cad_sel.rst @@ -60,8 +60,14 @@ Expected Output .. figure:: Task1.png +.. raw:: html + + + +.. figure:: cad1.png + -Task 2: 8pts +Task 2: 5pts -------------- .. raw:: html @@ -123,4 +129,4 @@ Expected Output .. caution:: THE DRAWING SHOULD BE DONE ACCURATELY AND AS EXPECTED . -Head over to `Submissions <./submissions.rst>`__ to submit your work \ No newline at end of file +Head over to `Submissions `__ to submit your work \ No newline at end of file