Do coppeliasim execute different child scripts at the same rate that specfied at the top of UI?
For if i have IMU and laser work in the same scene, Is it possible to execute the child scripts associated to corresponding sensor object at it's own rate independently?
frequency of different sensor
Re: frequency of different sensor
Hello,
yes, you are in full control about at which rate you want to execute and/or read things. First of all, during a simulation, there are two callback functions of particular interest:
For instance, if you want to check for collision between two objects in every simulation step, you'd simply do:
If however you want to check for collision in every other simulation step (i.e. half of the time only), you could do:
Proximity sensors are implicitly handled in each simulation step by default. But you can also explicitly handle them by checking their Explicit handling checkbox. Then, you can also do something like:
Cheers
yes, you are in full control about at which rate you want to execute and/or read things. First of all, during a simulation, there are two callback functions of particular interest:
- sysCall_actuation()
- sysCall_sensing()
For instance, if you want to check for collision between two objects in every simulation step, you'd simply do:
Code: Select all
function sysCall_init()
object1=sim.getObjectHandle("shape1")
object2=sim.getObjectHandle("shape2")
end
function sysCall_sensing()
local result=sim.checkCollision(object1,object2)
print(result)
end
Code: Select all
function sysCall_init()
object1=sim.getObjectHandle("shape1")
object2=sim.getObjectHandle("shape2")
cnt=0
end
function sysCall_sensing()
cnt=cnt+1
if cnt==2 then
cnt=0
local result=sim.checkCollision(object1,object2)
print(result)
end
end
Code: Select all
function sysCall_init()
sensorHandle=sim.getObjectHandle('myProxSensor')
objectTodetect=sim.getObjectHandle('aRandomShape')
-- sim.setExplicitHandling(sensorHandle,1) -- here via API, but via GUI also possible
cnt=0
end
function sysCall_sensing()
cnt=cnt+1
if cnt==2 then
cnt=0
local result=sim.checkProximitySensor(sensorHandle,objectTodetect)
print(result)
end
end