AI_Lab MANUAL.docx it contains 50 AI robotics program
shakthipriyaaids
8 views
31 slides
Sep 22, 2025
Slide 1 of 31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
About This Presentation
AI ROBOTICS MANUALS
Size: 322.22 KB
Language: en
Added: Sep 22, 2025
Slides: 31 pages
Slide Content
21AD521 AI AND ROBOTICS LABORATORY PRACTICAL RECORD
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA
SCIENCE
SRI SHAKTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY An
Autonomous Institution, Affiliated to Anna University
Accredited by NAAC with “A” Grade
COIMBATORE – 62
DECEMBER 2024
SRI SHAKTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
COIMBATORE - 62.
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
CERTIFICATE
Certified that this is a bonafide record of practical work done by Mr./Ms. bearing Register
Number _______________ of FIFTH Semester
Bachelor of Technology in Artificial Intelligence and Data Science in the 21AD521 AI And
Robotics during the Academic Year 2024-2025 under our supervision.
Place: Coimbatore
Date:
Staff In-Charge Head of the Department
Submitted for the End Semester Practical Examination held on ……………… Internal
Examiner External Examiner
INDEX
S.NO DATE TITLE MARK SIGNATURE
1 DESIGN A LINE FOLLOWING BOT
2 DESIGN A GESTURE CONTROLLED BOT
3 DESIGN A 4DOF ROBOTIC ARM
4 DESIGN A HOME SECURITY
SYSTEM USING NODEMCU
5 DESIGN A RF CONTROLLED OR
WIFI CONTROLLED NAVIGATION
BOT
6 DESIGN A PICK AND PLACE BOT
WITH OBJECT DETECTION
7 DESIGN A WALL FOLLOWING BOT
8 DESIGN A MAZE SOLVING ROBOT
9 DESIGN A FORWARD AND
REVERSE KINEMATICS BASED
EXPERIMENT USING OPEN
SOURCE PLATFORMS
10 DESIGN A COMPUTER VISION
BASED ROBOTIC TASK
EXECUTION
AIM:
EXPT.NO: 1 DESIGN A LINE FOLLOWING BOT
DATE:
To design and test a line-following robot that
autonomously navigates a predefined path
by detecting and following a black line using infrared sensors and Arduino programming.
REQUIRED HARDWARE COMPONENTS:
1. Arduino board (e.g., Arduino Uno)
2. Infrared (IR) sensors (typically 2 or more)
3. Motor driver (e.g., L298N or L293D)
4. DC motors and wheels
5. Chassis to assemble the robot
6. Power source (batteries)
7. Jumper wires
8. Breadboard (optional)
9. Optional: a body/frame for your robot
ALGORITHM :
1. Initialise the Arduino and the necessary pins.
2. Calibrate the sensors to detect the difference between the line and the background. 3.
Read sensor values to determine the position of the line.
4. Based on the sensor readings, adjust the robot's movement.
- If both sensors are on the line, move forward.
- If the left sensor is off the line, turn slightly to the right.
- If the right sensor is off the line, turn slightly to the left.
- If both sensors are off the line or you encounter a junction or obstacle, you may need more
complex logic to handle these situations.
5. Repeat steps 3-4 in a loop to continuously follow the line.
PROGRAM :
// Define sensor pins
int leftSensor = 2; // Connect to the left sensor
int rightSensor = 3; // Connect to the right sensor
// Define motor pins
int leftMotor = 4; // Connect to the left motor
int rightMotor = 5; // Connect to the right motor
// Define threshold values for sensor readings
int sensorThreshold = 500; // Adjust this value based on your sensor and lighting conditions
void setup() {
// Initialize sensor pins as inputs
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);
// Initialize motor pins as outputs
pinMode(leftMotor, OUTPUT);
pinMode(rightMotor, OUTPUT);
}
void loop() {
int leftValue = analogRead(leftSensor);
int rightValue = analogRead(rightSensor);
// Compare sensor readings with threshold
if (leftValue < sensorThreshold && rightValue < sensorThreshold) {
// Both sensors are off the line, go forward
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, HIGH);
} else if (leftValue < sensorThreshold) {
// Left sensor is off the line, turn slightly to the right
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, LOW);
} else if (rightValue < sensorThreshold) {
// Right sensor is off the line, turn slightly to the left
digitalWrite(leftMotor, LOW);
digitalWrite(rightMotor, HIGH);
} else {
// Both sensors are on the line, go forward
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, HIGH);
}
}
OUTPUT :
RESULT :
The line-following robot successfully follows a black line on a white surface by adjusting its
direction based on infrared sensor readings.
EXPT.NO: 2 DESIGN A GESTURE CONTROLLED BOT
DATE:
AIM :
To design and build a gesture-controlled robot that can be operated by hand gestures,
providing a hands-free and intuitive control method.
REQUIRED HARDWARE COMPONENTS :
1. Arduino board (e.g., Arduino Uno or Arduino Nano)
2. Gesture sensor (e.g., MPU6050 or APDS9960)
3. Motor driver (e.g., L298N or L293D)
4. DC motors and wheels
5. Chassis for the robot
6. Power source (batteries)
7. Jumper wires
8. Breadboard (optional)
9. Optional: a body/frame for your robot
ALGORITHM :
1. Initialize the Arduino and the necessary pins.
2. Set up and configure the gesture sensor to read hand gestures.
3. Define gestures and corresponding actions (e.g., forward, backward, left, right,
stop).
4. Continuously read the sensor to detect gestures.
5. Based on the detected gestures, control the movement of the robot.
- If a forward gesture is detected, move the robot forward.
- If a backward gesture is detected, move the robot backward.
- If a left gesture is detected, turn the robot left.
- If a right gesture is detected, turn the robot right.
- If a stop gesture is detected, stop the robot.
6. Repeat step 4-5 in a loop to continuously respond to hand gestures.
PROGRAM :
#include <Servo.h>
int leftMotor = 4; // Connect to the left motor
int rightMotor = 5; // Connect to the right motor
void setup() {
pinMode(leftMotor, OUTPUT);
pinMode(rightMotor, OUTPUT);
}
void loop() {
int randomGesture = random(0, 5); // Generate random gestures (0-4) if
(randomGesture == 0) {
// Move the robot forward
moveForward();
} else if (randomGesture == 1) {
// Move the robot backward
moveBackward();
} else if (randomGesture == 2) {
// Turn the robot left
turnLeft();
RESULT :
The gesture-controlled robot successfully responds to predefined hand gestures,
allowing for intuitive control without physical contact.
EXPT.NO: 3 DESIGN A 4DOF ROBOTIC ARM
DATE:
AIM :
To design and build a 4 Degrees of Freedom (4DOF) robotic arm that can be
controlled using an Arduino.
REQUIRED HARDWARE COMPONENTS :
1. Arduino board (e.g., Arduino Uno or Arduino Mega)
2. Servo motors (4 or more, depending on the design)
3. Motor drivers for servos (e.g., PCA9685 or dedicated servo motor controller) 4.
Power supply for servos
5. Mechanical parts for the arm6. Connectors and fasteners
7. Jumper wires
8. Breadboard or custom PCB
9. Gripper or end-effector (optional, depending on the application)
ALGORITHM :
1. Initialize the Arduino and servo motor library.
2. Configure and attach servo motors to their respective pins.
3. Define the range of motion and initial positions for each servo.
4. Implement control logic to move the robotic arm in different directions and angles. 5.
Create functions for specific movements such as forward, backward, up, down, rotate,
etc.
6. Continuously loop to accept user input or predefined sequences of movements.
PROGRAM :
#include <Servo.h>
// Define servo objects for each joint
Servo baseServo;
Servo shoulderServo;
Servo elbowServo;
Servo gripperServo;
void setup() {
// Attach servo motors to their respective pins
baseServo.attach(2); // Pin for the base joint
shoulderServo.attach(3); // Pin for the shoulder joint
elbowServo.attach(4); // Pin for the elbow joint
gripperServo.attach(5); // Pin for the gripper (optional)
// Initialize servo positions
baseServo.write(90); // Initial position for the base joint
shoulderServo.write(90); // Initial position for the shoulder joint
elbowServo.write(90); // Initial position for the elbow joint // You
can set an initial position for the gripper if present
}
void loop() {
// Implement control logic to move the robotic arm based on user input //
Example: Move the arm forward
moveForward();
delay(1000); // Delay for one second
}
void moveForward() {
// Implement code to move the arm forward
// Adjust the servo positions accordingly
baseServo.write(90);
shoulderServo.write(90);
elbowServo.write(60);
// You can set gripper position here if needed
}
OUTPUT :
RESULT :
The 4DOF robotic arm successfully performs a sequence of movements,
demonstrating its ability to be controlled by an Arduino and servo motors.
EXPT.NO: 4 DESIGN A HOME SECURITY SYSTEM USING NODEMCU
DATE:
AIM :
To design and implement a home security system using a NodeMCU (ESP8266)
microcontroller to monitor and secure a home or specific area.
REQUIRED HARDWARE COMPONENTS :
1. NodeMCU (ESP8266) or similar Wi-Fi-enabled microcontroller.
2. PIR (Passive Infrared) motion sensor.
3. Door/window contact sensors (optional).
4. Webcam or IP camera (optional).
5. Buzzer or alarm.
6. LEDs for status indication.
7. Wi-Fi connection for NodeMCU.
8. Power supply for NodeMCU.
9. Smartphone or computer for remote access.
ALGORITHM :
1. Initialize the NodeMCU and connect it to Wi-Fi.
2. Connect PIR motion sensors, door/window contact sensors, and other sensors. 3.
Set up a cloud platform or local server to store and access data.
4. Continuously monitor the sensors for any changes.
5. If motion or sensor activity is detected, trigger an alert and capture images or video. 6.
Send notifications and alerts to the homeowner's smartphone or computer. 7. Implement
remote access to view live camera feed and sensor status.
PROGRAM :
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
const char* serverName = "http://yourserver.com/endpoint"; // Replace with your
server or cloud platform
const int motionPin = D1; // PIR sensor pin
const int alarmPin = D2; // Buzzer or alarm pin
void setup() {
pinMode(motionPin, INPUT);
pinMode(alarmPin, OUTPUT);
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}
void loop() {
int motionDetected = digitalRead(motionPin);
if (motionDetected) {
Serial.println("Motion detected!");
activateAlarm();
sendAlert();
}
delay(1000); // Check every 1 second
}
void activateAlarm() {
digitalWrite(alarmPin, HIGH);
delay(500); // Alarm on for 0.5 seconds
digitalWrite(alarmPin, LOW);
}
void sendAlert() {
HTTPClient http;
http.begin(serverName);
int httpCode = http.GET();
if (httpCode > 0) {
Serial.println("Alert sent to server");
}
http.end();
}
OUTPUT :
RESULT :
The home security system using NodeMCU successfully detects motion and sends
alerts to a designated server or platform when an intrusion is detected.
EXPT.NO: 5 DESIGN A RF CONTROLLED OR WIFI CONTROLLED
NAVIGATION BOT
DATE:
AIM :
To design and build an RF (Radio Frequency) or Wi-Fi controlled navigation bot that can
be remotely controlled for movement and navigation using a dedicated RF remote or a
smartphone application.
REQUIRED HARDWARE COMPONENTS :
1. Arduino board or ESP8266/ESP32 (e.g., NodeMCU or Wemos D1)
2. Motor driver (e.g., L298N or L293D)
3. DC motors and wheels
4. Chassis for the robot
5. Power source (batteries)
6. Smartphone with Wi-Fi capability
7. Wi-Fi router or access point
8. Jumper wires
9. Optional: body/frame for the robot
ALGORITHM :
1. Set up the Arduino or ESP8266/ESP32 as a Wi-Fi server.
2. Initialize the Arduino and the necessary pins.
3. Configure the motor driver to control the robot's movement.
4. Create a smartphone application or a web interface for controlling the robot over
Wi-Fi.
5. Establish communication between the smartphone and the robot using Wi-Fi. 6.
Send control commands from the smartphone app to control the robot's movement
(e.g., forward, backward, left, right).
7. Execute the corresponding movement based on the received Wi-Fi command.
PROGRAM :
// Define motor pins
int leftMotor = 4; // Connect to the left motor
int rightMotor = 5; // Connect to the right motor
void setup() {
// Initialize motor pins as outputs
pinMode(leftMotor, OUTPUT);
pinMode(rightMotor, OUTPUT);
// Initialize RF module or set up Wi-Fi communication
}
void loop() {
// For RF-Controlled Bot
int rfCommand = readRFCommand(); // Replace with actual function to read RF
commands
executeRFCommand(rfCommand);
// For Wi-Fi-Controlled Bot
int wifiCommand = readWiFiCommand(); // Replace with actual function to read Wi Fi
commands
executeWiFiCommand(wifiCommand);
}
void executeRFCommand(int command) {
// Implement code to control the robot based on RF commands
// Adjust motor control logic for forward, backward, left, right, etc.
if (command == FORWARD_COMMAND) {
// Move forward
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, HIGH);
} else if (command == BACKWARD_COMMAND) {
// Move backward
digitalWrite(leftMotor, LOW);
digitalWrite(rightMotor, LOW);
} else if (command == LEFT_COMMAND) {
// Turn left
digitalWrite(leftMotor, LOW);
digitalWrite(rightMotor, HIGH);
} else if (command == RIGHT_COMMAND) {
// Turn right
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, LOW);
}
// Add more conditions based on your specific control method }
void executeWiFiCommand(int command) {
// Implement code to control the robot based on Wi-Fi commands //
Adjust motor control logic for forward, backward, left, right, etc. if
(command == FORWARD_COMMAND) {
// Move forward
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, HIGH);
} else if (command == BACKWARD_COMMAND)
{ // Move backward
digitalWrite(leftMotor, LOW);
digitalWrite(rightMotor, LOW);
} else if (command == LEFT_COMMAND) {
// Turn left
digitalWrite(leftMotor, LOW);
digitalWrite(rightMotor, HIGH);
} else if (command == RIGHT_COMMAND) {
// Turn right
digitalWrite(leftMotor, HIGH);
digitalWrite(rightMotor, LOW);
}
// Add more conditions based on your specific control method }
int readRFCommand() {
// Function to read and return the received RF command
// Replace this with actual RF module code
int randomCommand = random(0, 4); // Generates random commands (0-3)
return randomCommand;
}
int readWiFiCommand() {
// Function to read and return the received Wi-Fi command
// Replace this with actual Wi-Fi communication code
int randomCommand = random(0, 4); // Generates random commands (0-3)
return randomCommand;
}
// Define command constants
const int FORWARD_COMMAND = 0;
const int BACKWARD_COMMAND = 1;
const int LEFT_COMMAND = 2;
const int RIGHT_COMMAND = 3;
const int NO_COMMAND = -1;
OUTPUT :
RESULT :
The RF-controlled or Wi-Fi-controlled navigation bot successfully receives and
executes remote commands for movement and navigation.
EXPT.NO: 6 DESIGN A PICK AND PLACE BOT WITH OBJECT
DETECTION
DATE:
AIM :
To design and build a pick-and-place robot with object detection capabilities to
autonomously identify and handle objects within a predefined workspace.
REQUIRED HARDWARE COMPONENTS :
1. Robotic arm (e.g., 4-DOF or 6-DOF)
2. Object detection sensor (e.g., camera, LiDAR, ultrasonic, IR, or any suitable sensor) 3.
Gripper or end-effector for object manipulation
4. Arduino or microcontroller for control (e.g., Arduino Uno, Raspberry Pi)
5. Motor drivers and motors for the robot arm
6. Power supply for the robot arm and sensors
7. Chassis or frame for the robot
8. Jumper wires and connectors
9. Computer or display for monitoring and control
10. Optional: conveyor belt or object feeding mechanism
ALGORITHM :
1. Initialize the robotic arm, object detection sensor, and necessary components.
2. Configure and calibrate the object detection sensor for the workspace. 3.
Continuously monitor the sensor for object presence.
4. If an object is detected, determine its position and orientation.
5. Calculate the desired pick-and-place trajectory for the robotic arm.
6. Move the robotic arm to grasp the object using the gripper.
7. Verify successful pick-up or adjust the gripper if necessary.
8. Move the arm to the desired placement location.
9. Release the object at the designated location.
10. Repeat the process for object detection and handling.
PROGRAM :
#include <Servo.h> // Include the servo library for arm control
Servo armServo1;
Servo armServo2;
Servo armServo3;
Servo armServo4;
// Define pins for object detection sensor
const int objectSensorPin = A0; // Analog pin for sensor input
// Define threshold value for object detection
const int thresholdValue = 500; // Adjust this value based on your sensor and object
characteristics
void setup() {
armServo1.attach(2); // Attach servo motors for arm control
armServo2.attach(3);
armServo3.attach(4);
armServo4.attach(5);
pinMode(objectSensorPin, INPUT); // Initialize sensor pin as input
// Initialize random seed for object simulation
randomSeed(analogRead(0));
}
void loop() {
int objectPresence = analogRead(objectSensorPin);
if (objectPresence > thresholdValue) {
// Object detected, proceed with pick-and-place
pickAndPlaceObject();
}
}
void pickAndPlaceObject() {
int objectPositionX = random(0, 180);
int objectPositionY = random(0, 180);
int objectOrientation = random(0, 180);
armServo1.write(objectPositionX);
armServo2.write(objectPositionY);
armServo3.write(objectOrientation);
delay(1000);
armServo1.write(random(0, 180));
armServo2.write(random(0, 180));
armServo3.write(random(0, 180));
delay(1000); // Delay to simulate object placement
}
OUTPUT :
RESULT :
The pick-and-place robot with object detection successfully identifies objects within
its workspace and autonomously grasps and moves them to the designated locations.
EXPT.NO:7 DESIGN A WALL FOLLOWING BOT
DATE:
AIM:
To design and build a wall-following robot that can autonomously navigate a
predefined path while maintaining a consistent distance from a wall or obstacle.
REQUIRED HARDWARE COMPONENTS :
1. Robot chassis with wheels
2. Ultrasonic distance sensor (e.g., HC-SR04)
3. Motor driver (e.g., L298N or L293D)
4. DC motors and wheels
5. Arduino board (e.g., Arduino Uno or Arduino Nano)
6. Power supply (batteries or power bank)
7. Jumper wires
8. Chassis or frame for the robot
9. Optional: H-bridge motor controller for precise motor control
10. Optional: LCD display or LEDs for status indication
ALGORITHM :
1. Initialize the Arduino and configure the ultrasonic distance sensor.
2. Set up the motor control system using the motor driver.
3. Define the desired distance from the wall.
4. Continuously monitor the distance to the nearest wall using the ultrasonic sensor. 5.
Based on the distance measurement, implement control logic to adjust the robot's
movement:
- If the distance is greater than the desired distance, turn toward the wall. - If the
distance is less than the desired distance, turn away from the wall. 6. Execute the
corresponding motor commands to maintain the desired distance from the wall.
7. Repeat the process in a continuous loop for autonomous navigation.
PROGRAM :
#include <Servo.h> // Include the servo library for motor control
Servo leftMotor;
Servo rightMotor;
// Define pins for ultrasonic sensor
const int trigPin = 9; // Trigger pin
const int echoPin = 10; // Echo pin
// Define desired distance from the wall (in centimeters)
const int desiredDistance = 10; // Adjust as needed
void setup() {
leftMotor.attach(2); // Attach servo motors for left wheel control
rightMotor.attach(3); // Attach servo motors for right wheel control
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// Initialize the serial communication for debugging (optional)
Serial.begin(9600);
}
void loop() {
// Measure distance from the wall using the ultrasonic sensor
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration / 58.2;
// Debugging: Print distance to the serial monitor
Serial.print("Distance: ");
Serial.println(distance);
// Implement wall-following logic based on distance
if (distance > desiredDistance) {
// Turn toward the wall (adjust motor control as needed)
leftMotor.write(90); // Adjust the servo angle for left wheel
rightMotor.write(60); // Adjust the servo angle for right wheel
} else {
// Turn away from the wall (adjust motor control as needed)
leftMotor.write(60); // Adjust the servo angle for left wheel
rightMotor.write(90); // Adjust the servo angle for right wheel
}
}
OUTPUT :
RESULT :
The wall-following robot successfully maintains a consistent distance from the wall or
obstacle while autonomously navigating a predefined path.
EXPT.NO: 8 DESIGN A MAZE SOLVING ROBOT
DATE:
AIM :
Design and build a maze-solving robot capable of autonomously navigating through a
maze to find its way from a designated starting point to the maze's exit.
REQUIRED HARDWARE COMPONENTS :
1. Robot chassis with wheels.
2. Infrared (IR) or ultrasonic sensors for obstacle detection.
3. Arduino board (e.g., Arduino Uno or Arduino Nano).
4. Motor driver (e.g., L298N or L293D).
5. DC motors and wheels.
6. Power supply (batteries or power bank).
7. Jumper wires.
8. Chassis or frame for the robot.
9. Optional: Line following sensors for path tracking.
10. Optional: LCD display or LEDs for status indication.
ALGORITHM :
1. Initialize the Arduino and configure the sensors for obstacle detection.
2. Set up the motor control system using the motor driver.
3. Define the maze layout, including the starting point and exit.
4. Implement an algorithm to navigate through the maze, such as the "left-hand rule" or
"right-hand rule."
5. Continuously monitor the sensors for obstacles.
6. Based on sensor readings and the chosen algorithm, make decisions on which
direction to move:
- If an obstacle is detected, turn in the direction with the most open space. -
If a path is found, follow it until the exit is reached.
- Adjust the algorithm based on your maze's layout and complexity.
7. Execute the corresponding motor commands to navigate through the maze.
8. Repeat the process until the robot successfully reaches the maze's exit.
PROGRAM :
#include <Servo.h> // Include the servo library for motor control
Servo leftMotor;
Servo rightMotor;
// Define pins for obstacle detection sensors
const int leftSensorPin = 2;
const int rightSensorPin = 3;
void setup() {
leftMotor.attach(4); // Attach servo motors for left wheel control
rightMotor.attach(5); // Attach servo motors for right wheel control
pinMode(leftSensorPin, INPUT);
pinMode(rightSensorPin, INPUT);
// Initialize the serial communication for debugging (optional)
Serial.begin(9600);
}
void loop() {
// Read sensor values
int leftSensorValue = digitalRead(leftSensorPin);
int rightSensorValue = digitalRead(rightSensorPin);
// Debugging: Print sensor values to the serial monitor
Serial.print("Left Sensor: ");
Serial.println(leftSensorValue);
Serial.print("Right Sensor: ");
Serial.println(rightSensorValue);
// Implement maze-solving logic based on sensor readings
if (leftSensorValue == LOW && rightSensorValue == LOW) { //
No obstacles, move forward
leftMotor.write(90); // Adjust the servo angle for left wheel (forward)
rightMotor.write(90); // Adjust the servo angle for right wheel (forward) }
else if (leftSensorValue == HIGH && rightSensorValue == LOW) { //
Obstacle on the left, turn right
leftMotor.write(90); // Adjust the servo angle for left wheel (forward)
rightMotor.write(60); // Adjust the servo angle for right wheel (turn right) }
else if (leftSensorValue == LOW && rightSensorValue == HIGH) { //
Obstacle on the right, turn left
leftMotor.write(60); // Adjust the servo angle for left wheel (turn left)
rightMotor.write(90); // Adjust the servo angle for right wheel (forward) }
else {
// Obstacles on both sides, turn around or backtrack
leftMotor.write(60); // Adjust the servo angle for left wheel (turn left)
rightMotor.write(60); // Adjust the servo angle for right wheel (turn right) }
}
OUTPUT :
RESULT:
The maze-solving robot autonomously navigates through the maze, following the
chosen algorithm and avoiding obstacles using obstacle detection sensors.
EXPT.NO: 9 DESIGN A FORWARD AND REVERSE KINEMATICS
BASED EXPERIMENT USING OPEN SOURCE PLATFORMS
DATE:
AIM:
To understand and implement forward and reverse kinematics using open-source
platforms.
REQUIRED HARDWARE COMPONENTS :
1. Robotic arm (hardware or simulation platform).
2. Open-source robotics software platform (e.g., ROS - Robot Operating System, or
similar).
3. Computer with necessary software tools installed.
4. Optional: Sensors (e.g., encoders, cameras) for feedback and calibration.
ALGORITHM :
1. Set up the robotic arm and ensure it is connected to the computer running the open
source platform.
2. Use the open-source platform to define the robotic arm's kinematic model, including
the number of joints, joint types, and link lengths.
3. Implement forward kinematics by creating a mathematical model or using built-in
functions in the open-source platform. Calculate the end-effector's position and
orientation based on joint angles.
4. Implement reverse kinematics by creating a mathematical model or using built-in
functions in the open-source platform. Determine the joint angles required to reach a
specific end-effector position and orientation.
5. Experiment with different joint angles and end-effector positions to validate the
forward and reverse kinematics calculations.
6. Optionally, use sensors for feedback and calibration to improve the accuracy of the
kinematic calculations.
PROGRAM :
#include <Servo.h>
Servo baseServo;
Servo endEffectorServo;
const int baseServoPin = 2;
const int endEffectorServoPin = 3;
void setup() {
baseServo.attach(baseServoPin);
endEffectorServo.attach(endEffectorServoPin);
}
void loop() {
// Forward kinematics
float baseAngle = map(analogRead(A0), 0, 1023, 0, 180); // Map sensor value to
servo angle
float endEffectorAngle = map(analogRead(A1), 0, 1023, 0, 180);
// Move the servos based on forward kinematics
baseServo.write(baseAngle);
endEffectorServo.write(endEffectorAngle);
// Reverse kinematics
// Calculate joint angles based on end-effector position (Not implemented in this
simplified example)
}
OUTPUT : RESULT :
The experiment results in a better understanding of forward and reverse kinematics, as
well as the ability to use open-source platforms like ROS to perform these calculations.
EXPT.NO: 10 DESIGN A COMPUTER VISION BASED ROBOTIC TASK
EXECUTION
DATE:
AIM :
To develop a computer vision-based robotic system capable of executing specific tasks in
a real-world environment, such as object detection, recognition, and manipulation.
REQUIRED HARDWARE COMPONENTS :
1. Robot chassis with wheels or robotic arm (depending on the task).
2. Computer or single-board computer (e.g., Raspberry Pi or NVIDIA Jetson). 3.
Camera or vision sensor (e.g., webcam, depth camera, or stereo camera). 4.
Motors and motor drivers (if applicable).
5. Mechanical gripper or end-effector (if applicable).
6. Power supply (batteries or power adapter).
7. OpenCV or other computer vision libraries.
8. Internet connection for cloud-based solutions (if needed).
9. Additional sensors for environmental awareness (e.g., ultrasonic, IR, or lidar).
ALGORITHM :
1. Set up the robot hardware, including attaching the camera or vision sensor. 2.
Develop a computer vision algorithm to perform the desired task (e.g., object
detection, recognition, tracking).
3. Capture video frames or images from the camera sensor.
4. Process the images using computer vision techniques to identify objects or features of
interest.
5. Implement the robotic control algorithm to execute the task based on the vision data. 6.
For object manipulation tasks, use inverse kinematics or motion planning to control the
robotic arm or gripper.
7. Continuously loop through the image processing and control steps to provide real
time task execution.
PROGRAM :
import cv2
net = cv2.dnn.readNet("yolov3.weights", "yolov3.cfg")
# Load class names for detected objects
classes = []
with open("coco.names", "r") as f:
classes = f.read().strip().split('\n')
# Initialize the camera or image source
cap = cv2.VideoCapture(0) # 0 for the default camera
while True:
ret, frame = cap.read()
height, width, _ = frame.shape
# Perform object detection
blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), (0, 0, 0), True,
crop=False)
net.setInput(blob)
outs = net.forward()
# Process detection results
for out in outs:
for detection in out:
scores = detection[5:]
class_id = np.argmax(scores)
confidence = scores[class_id]
if confidence > 0.5:
# Perform task execution based on the detected object (e.g., move the robot to
pick it up)
# Display the frame with detected objects
cv2.imshow("Object Detection", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
OUTPUT :
RESULT :
The result of the computer vision-based robotic task execution experiment is successful
task execution, which could involve detecting and manipulating objects in a real world
environment.