Skip to content

Commit

Permalink
Merge pull request #71 from atom-robotics-lab/vansh/selection2024
Browse files Browse the repository at this point in the history
  • Loading branch information
NOEMOJI041 authored Sep 11, 2024
2 parents 8eab406 + d2873b3 commit 7ab64b1
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 83 deletions.
16 changes: 15 additions & 1 deletion markdown/ros/node/node.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -164,4 +178,4 @@ Command: ros2 node

.. code:: shell
ros2 node kill <node_name>
ros2 node kill <node_name>
2 changes: 1 addition & 1 deletion markdown/ros/package/package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/<package_name> directory containing the public headers for the package
Expand Down
21 changes: 14 additions & 7 deletions markdown/selectiontask24/Electronics_selection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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!


Expand Down Expand Up @@ -60,15 +60,22 @@ 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
~~~~~~~~~~~~~~~
`video link <https://www.youtube.com/shorts/lbVagJaASJ8>`__

.. raw:: html

<center><iframe width="560" height="315" src="https://www.youtube.com/embed/iGsrljodarg&t" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center><br>
<center><iframe width="560" height="315" src="https://youtube.com/embed/lbVagJaASJ8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center>



.. note::

If you don't have hardware available, you can use a simulator such as `Wokwi <https://www.wokwi.com>`__



Task 1B
Expand All @@ -77,15 +84,15 @@ 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
~~~~~~~~~~~~~~~
`video link <https://www.youtube.com/watch?v=iGsrljodarg&t=2s>`__

.. raw:: html

<center><iframe width="560" height="315" src="https://www.youtube.com/embed/iGsrljodarg&t" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center><br>
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/iGsrljodarg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center><br>


Level 2 - Expert Territory: 8pts
Expand All @@ -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
Expand All @@ -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
Head over to `Submissions <https://atom-robotics-lab.github.io/wiki/markdown/selectiontask24/submissions.html>`__ to submit your work
144 changes: 72 additions & 72 deletions markdown/selectiontask24/ROS_selection_task24.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Expected Output
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/R6udlXtyplk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center><br>


.. 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
-----
Expand All @@ -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
.. <center><iframe width="560" height="315" src="https://www.youtube.com/embed/tjGNhEe-S_k" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></center><br>
Commands used:

Expand Down Expand Up @@ -179,4 +179,4 @@ Follow the instructions given below to get started with the task.
the official `ROSWIKI <http://wiki.ros.org/Documentation>`__ if you
need help with anything regarding ROS2.

Head over to `Submissions <./submissions.rst>`__ to submit your work
Head over to `Submissions <https://atom-robotics-lab.github.io/wiki/markdown/selectiontask24/submissions.html>`__ to submit your work
Binary file added markdown/selectiontask24/cad1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions markdown/selectiontask24/cad_sel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ Expected Output

.. figure:: Task1.png

.. raw:: html

</center>

.. figure:: cad1.png


Task 2: 8pts
Task 2: 5pts
--------------
.. raw:: html

Expand Down Expand Up @@ -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
Head over to `Submissions <https://atom-robotics-lab.github.io/wiki/markdown/selectiontask24/submissions.html>`__ to submit your work

0 comments on commit 7ab64b1

Please sign in to comment.