Exp 9
Exp 9
DISRUPTIVE TECHNOLOGY – 2
EXPERIMENT-9
1
University Institute of Engineering
Department of Computer Science & Engineering
4.Code:
function speedChange_callback(ui,id,newVal)
speed=minMaxSpeed[1]+(minMaxSpeed[2]-minMaxSpeed[1])*newVal/10
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')
2
University Institute of Engineering
Department of Computer Science & Engineering
</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()
sim.addDrawingObjectItem(distanceSegment,nil)
sim.addDrawingObjectItem(distanceSegment,distData)
sim.setGraphStreamValue(graph,distStream,distData[7])
end
sim.addDrawingObjectItem(robotTrace,p)
end
function sysCall_actuation()
3
University Institute of Engineering
Department of Computer Science & Engineering
-- When in forward mode, we simply move forward at the desired speed
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)
simVision.sensorImgToWorkImg(inData.handle) -- copy the vision sensor image to the work image
simVision.workImgToSensorImg(inData.handle) -- copy the work image to the vision sensor image buffer
end
function sysCall_init()
end
4
University Institute of Engineering
Department of Computer Science & Engineering
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: