unit 3 edt2
unit 3 edt2
Experiment: 3.1
1. Aim of the practical:: Design a collision avoidance robot in multi obstacle-based environment
4. Code:
CODE FOR BUBBLE ROB:
function speedChange_callback(ui,id,newVal)
speed=minMaxSpeed[1]+(minMaxSpeed[2]-minMaxSpeed[1])*newVal/100
University Institute of Engineering
Department of Computer Science & Engineering
end
function sysCall_init()
-- This is executed exactly once, the first time this script is executed
robotCollection=sim.createCollection(0)
sim.addItemToCollection(robotCollection,sim.handle_tree,bubbleRobBase,0)
distanceSegment=sim.addDrawingObject(sim.drawing_lines,4,0,-1,1,{0,1,0})
robotTrace=sim.addDrawingObject(sim.drawing_linestrip+sim.drawing_cyclic,2,0,-
1,200,{1,1,0},nil,nil,{1,1,0})
graph=sim.getObject('./graph')
distStream=sim.addGraphStream(graph,'bubbleRob clearance','m',0,{1,0,0})
</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 result,distData=sim.checkDistance(robotCollection,sim.handle_all)
if result>0 then
sim.addDrawingObjectItem(distanceSegment,nil)
sim.addDrawingObjectItem(distanceSegment,distData)
sim.setGraphStreamValue(graph,distStream,distData[7])
end
local p=sim.getObjectPosition(bubbleRobBase,-1)
sim.addDrawingObjectItem(robotTrace,p)
end
function sysCall_actuation()
University Institute of Engineering
Department of Computer Science & Engineering
if (backUntilTime<sim.getSimulationTime()) then
sim.setJointTargetVelocity(leftMotor,speed)
sim.setJointTargetVelocity(rightMotor,speed)
else
sim.setJointTargetVelocity(leftMotor,-speed/2)
sim.setJointTargetVelocity(rightMotor,-speed/8)
end
end
function sysCall_cleanup()
simUI.destroy(ui)
end
function sysCall_vision(inData)
end
function sysCall_init()
end
· Effective Obstacle Detection – The robot successfully detects obstacles using proximity
sensors and adjusts its path accordingly.
· Real-Time Response – Quick sensor readings enable the robot to react immediately, preventing
collisions.
· Path Optimization – The robot efficiently navigates around obstacles but may require fine-
tuning for smoother turns.
1. Sensor Utilization – Understanding how proximity sensors detect obstacles and influence
movement decisions.
2. Autonomous Navigation – Learning to program robots for real-time path adjustments in
dynamic environments.
3. Algorithm Development – Implementing logic-based obstacle avoidance strategies like
conditional checks and path planning.
4. Simulation Mastery – Gaining hands-on experience with CoppeliaSim commands for sensor
reading and motor control.
5. Optimization Techniques – Exploring advanced methods like PID control or machine
learning for improved obstacle avoidance.
Evaluation Grid: