Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

function sysCall_init()

-- do some initialization here


cinta = sim.getObject(".")
sensor = sim.getObject("/Proximity_sensor")
detecta = false
tiempoanterior=sim.getSimulationTime()
tiempoactual=tiempoanterior
cubo=sim.createPrimitiveShape(sim.primitiveshape_cuboid,{0.1,0.1,0.05})
sim.setObjectPosition(cubo,sim.handle_world,{-0.7250,-0.1250,0.9700})
sim.setObjectInt32Param(cubo,sim.shapeintparam_static,0)
sim.setObjectInt32Param(cubo,sim.shapeintparam_respondable,1)
cantidadProductos=1
end

function sysCall_actuation()
-- put your actuation code here
tiempoactual=sim.getSimulationTime()
if (((tiempoactual-tiempoanterior)>= 20) and (cantidadProductos<16)) then
cubo=sim.createPrimitiveShape(sim.primitiveshape_cuboid,{0.1,0.1,0.05})
sim.setObjectPosition(cubo,sim.handle_world,{-0.7250,-0.1250,1})
sim.setObjectInt32Param(cubo,sim.shapeintparam_static,0)
sim.setObjectInt32Param(cubo,sim.shapeintparam_respondable,1)
cantidadProductos=cantidadProductos+1
tiempoanterior=tiempoactual
end
if detecta == true then
sim.writeCustomTableData(cinta,'__ctrl__',{vel=0})
else
sim.writeCustomTableData(cinta,'__ctrl__',{vel=0.07})
end
end

function sysCall_sensing()
-- put your sensing code here
if sim.readProximitySensor(sensor) == 1 then
detecta = true
else
detecta = false
end
end

function sysCall_cleanup()
-- do some clean-up here

You might also like