University Institute of Engineering
Department of Computer Science & Engineering
DISRUPTIVE TECHNOLOGY – 2
EXPERIMENT-8
Student Name: Peeyush Chaurasia UID: 22BCS16408
Branch: Computer Science & Engineering Section/Group:403-A
Semester: II Date of Performance:28/04/2023
Subject Name: Disruptive Technologies-2
Subject Code: 22ECH-103
1. Aim of the practical:
Design a two-wheel line following robot integrated with infrared sensors.
2. Tool Used:
Coppeliasim
3. Basic Concept /Command Description:
The robotics simulator CoppeliaSim, with integrated development environment, is based on
a distributed control architecture: each object/model can be individually controlled via an
embedded script, a plugin, ROS / ROS2 nodes, remote API clients, or a custom solution.
This makes CoppeliaSim very versatile and ideal for multi-robot applications. Controllers
can be written in C/C++, Python, Java, Lua, Matlab or Octave.
1
University Institute of Engineering
Department of Computer Science & Engineering
4.Code:
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
2
University Institute of Engineering
Department of Computer Science & Engineering
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
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
3
University Institute of Engineering
Department of Computer Science & Engineering
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)
sim.setJointTargetVelocity(rightMotor,-speed/8)
end
end
function sysCall_cleanup()
simUI.destroy(ui)
4
University Institute of Engineering
Department of Computer Science & Engineering
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,color)
return shape
end
5.Observations, Simulation Screen Shots and Discussion:
5
University Institute of Engineering
Department of Computer Science & Engineering
University Institute of Engineering
Department of Computer Science & Engineering
6
6. Result and Summary:
CoppeliaSim is a powerful cross-platform robot simulator which has a free educational version.
CoppeliaSim's strength comes from several features:
1. CoppeliaSim provides a unified framework combining many powerful internal and
external libraries that are often useful for robotics simulations. This includes dynamic
simulation engines, forward/inverse kinematics tools, collision detection libraries,
vision sensor simulations, path planning, GUI development tools, and built-in models
of many common robots.
2. CoppeliaSim is highly extensible. CoppeliaSim developers provide an API that allows
one to write custom plugins that add new features. You can embed Lua scripts directly
into a simulation scene that, for example, process simulated sensor data, run control
algorithms, implement user interfaces, or even send data to a physical robot. They also
provide a remote API that allows one to develop standalone applications in many
programming languages that are able to pass data in and out of a running CoppeliaSim
simulation.
3. CoppeliaSim is cross-platform, mostly open-source, and provides a free educational
license.
7.Additional Creative Inputs (If Any): -
Null
8.Learning outcomes (What I have learnt):
1. We have learned about open-source coppeliasim cross platform.
2. Learnt about robotics development platform environment to model, program and simulate
robots.
2. Learnt about various GUI development tools, dynamic simulation engines, collision
detection libraries and built in models.
University Institute of Engineering
Department of Computer Science & Engineering
Evaluation Grid (To be filled by Faculty):
Sr. Parameters Marks Obtained Maximum
No. Marks
1. Worksheet completion 8
including writing
learning Objective/Outcomes
(To be submitted at the end of
the day)
2. Viva-Voce 10
3. Conduct 8
Signature of Faculty Total Marks 30
(with Date): Obtained:
University Institute of Engineering
Department of Computer Science & Engineering