I was trying to reproduce this youtube tutorial in V-rep and I came across some problems concerning blob detection. There are some complaints on this matter under the video. I don't believe that blob detection stopped working in recent v-rep versions, but I was unable to make it work (as a new v-rep user myself). Has anyone any idea how to properly implement it?
More specifically, I have a vision sensor named
cam and I want it to follow a red ball. The vision sensor will detect the position of the ball and I will use it to control the joints that steer the sensor (
pitch). My script follows
threadFunction=function() yaw=simGetObjectHandle("yaw") pitch=simGetObjectHandle("pitch") cam=simGetObjectHandle("cam") while simGetSimulationState()~=sim_simulation_advancing_abouttostop do result,pack1,pack2=simReadVisionSensor(cam) if result>0 then xtarget=pack2 ytarget=pack2 simAuxiliaryConsolePrint(out,string.format("\n x: %0.2f, y: %0.2f",xtarget,ytarget)) simSetJointTargetVelocity(yaw,1*(0.5-xtarget)) simSetJointTargetVelocity(pitch,1*(0.5-ytarget)) end end end simSetThreadSwitchTiming(2) out = simAuxiliaryConsoleOpen("Debug",8,1) res,err=xpcall(threadFunction,function(err) return debug.traceback(err) end) if not res then simAddStatusbarMessage('Lua runtime error: '..err) end
Here is my scene