You are on page 1of 9

University Institute of Engineering

Department of Mechanical Engineering

Experiment: 3.2

Student Name: PRATIK MISHRA UID :21BCS7830


Branch: CSE
Semester: 2ND Date of Performance:2022/04/22
Subject Name: Disruptive Technology
Subject Code:21ECH-103

1. Aim of the practical: Design a two wheel line following robot integrated with infrared sensors.

2. Tool Used: Coppeliasim.

STEPS TO MAKE ROBOT ON COPPLEASIM


University Institute of Engineering
Department of Mechanical Engineering
University Institute of Engineering
Department of Mechanical Engineering
University Institute of Engineering
Department of Mechanical Engineering

CODE FOR BUBBLE ROB:


University Institute of Engineering
Department of Mechanical Engineering

function sysCall_init()
bubbleRobBase=sim.getObject('.')
leftMotor=sim.getObject("./leftMotor")
rightMotor=sim.getObject("./rightMotor")
noseSensor=sim.getObject("./sensingNose")
minMaxSpeed={50*math.pi/180,300*math.pi/180}
backUntilTime=-1 -- Tells whether bubbleRob is in forward or
backward mode
floorSensorHandles={-1,-1,-1}
floorSensorHandles[1]=sim.getObject("./leftSensor")
floorSensorHandles[2]=sim.getObject("./middleSensor")
floorSensorHandles[3]=sim.getObject("./rightSensor")

robotTrace=sim.addDrawingObject(sim.drawing_linestrip+sim.drawing_
cyclic,2,0,-1,200,{1,1,0},nil,nil,{1,1,0})
-- Create the custom UI:
xml = '<ui title="'..sim.getObjectAlias(bubbleRobBase,1)..'
speed" closeable="false" resizeable="false" activate="false">'..[[
<hslider minimum="0" maximum="100" on-
change="speedChange_callback" id="1"/>
<label text="" style="* {margin-left: 300px;}"/>
</ui>
]]
ui=simUI.create(xml)
speed=(minMaxSpeed[1]+minMaxSpeed[2])*0.5

simUI.setSliderValue(ui,1,100*(speed-minMaxSpeed[1])/(minMaxSpeed[
2]-minMaxSpeed[1]))

end

function sysCall_sensing()
local p=sim.getObjectPosition(bubbleRobBase,-1)
sim.addDrawingObjectItem(robotTrace,p)
end

function speedChange_callback(ui,id,newVal)

speed=minMaxSpeed[1]+(minMaxSpeed[2]-minMaxSpeed[1])*newVal/100
University Institute of Engineering
Department of Mechanical Engineering

end

function sysCall_actuation()
result=sim.readProximitySensor(noseSensor)
if (result>0) then backUntilTime=sim.getSimulationTime()+4 end

-- read the line detection sensors:


sensorReading={false,false,false}
for i=1,3,1 do
result,data=sim.readVisionSensor(floorSensorHandles[i])
if (result>=0) then
sensorReading[i]=(data[11]<0.5) -- data[11] is the
average of intensity of the image
end
end

-- compute left and right velocities to follow the detected


line:
rightV=speed
leftV=speed
if sensorReading[1] then
leftV=0.03*speed
end
if sensorReading[3] then
rightV=0.03*speed
end
if sensorReading[1] and sensorReading[3] then
backUntilTime=sim.getSimulationTime()+2
end

if (backUntilTime<sim.getSimulationTime()) then
-- When in forward mode, we simply move forward at the
desired speed
sim.setJointTargetVelocity(leftMotor,leftV)
sim.setJointTargetVelocity(rightMotor,rightV)
else
-- When in backward mode, we simply backup in a curve at
reduced speed
sim.setJointTargetVelocity(leftMotor,-speed/2)
University Institute of Engineering
Department of Mechanical Engineering

sim.setJointTargetVelocity(rightMotor,-speed/8)
end
end

function sysCall_cleanup()
simUI.destroy(ui)
end

CODE FOR PATH:

path=require('path_customization')

function path.shaping(path,pathIsClosed,upVector)
local section={-0.02,0.001,0.02,0.001}
local color={0.3,0.3,0.3}
local options=0
if pathIsClosed then
options=options|4
end
local
shape=sim.generateShapeFromPath(path,section,options,upVector)

sim.setShapeColor(shape,nil,sim.colorcomponent_ambient_diffuse,col
or)
return shape
end
University Institute of Engineering
Department of Mechanical Engineering

6.Results:The robot succesfully detect the obstacles and change its direction.

7. Additional Creative Inputs (If Any):

Learning outcomes (What I have learnt):

1.We are designed in vehicles and car factories.

2.We are designed mounting circuits on electronic devise e.g. mobile phone.

3.We are working where there might be danger e.g. nuclear leaks and bomb
disposal.

4.We are designed to Toy robots are good source of entertaining for like kids
e.g.dancing talking robots.

5.We are able to help the people by robots do not get bored or tired and they can
work 24/7without salary and food.

Evaluation Grid (To be filled by Faculty):


Sr. Parameters Marks Obtained Maximum Marks
No.
1. Worksheet completion including 10
writinglearning objectives/Outcomes.
(To besubmitted at the end of the day)
2. Post Lab Quiz Result. 5
3. Student Engagement in 5
Simulation/Demonstration/
Performance and Controls/Pre-Lab
Questions.
Signature of Faculty (with Date): Total Marks Obtained: 20
University Institute of Engineering
Department of Mechanical Engineering

You might also like