Hello coppelia,
What is sample size of force sensor? When I set it to 1, what is the time interval between the two force data? If I want to set the sampling interval of the force sensor to 10ms, what should the sample size be set to?
Force sensor problem
Re: Force sensor problem
The sample size typically represents the number of simulation steps. One simulation step is by default 50ms. If your simulation step is set to 10ms, and sample size is 1, then you'll get a non-averaged value in each simulation step (however you will still get an average value over the n dynamics sub-steps, see next paragraph).
If your simulation step is 50ms, and you desire a more frequent reading of the force sensor, i.e. a raw value from the physics engine (which by default runs at 5 ms sub-step), then you can use a dynamics callback function. Have a look at this example:
Cheers
If your simulation step is 50ms, and you desire a more frequent reading of the force sensor, i.e. a raw value from the physics engine (which by default runs at 5 ms sub-step), then you can use a dynamics callback function. Have a look at this example:
Code: Select all
function sysCall_init()
h=sim.getObject('.')
end
function sysCall_sensing()
local t=sim.getSimulationTime()+sim.getSimulationTimeStep()
local r,force,torque=sim.readForceSensor(h)
if r>0 then
print(string.format("averaged force value (over sample size) at time %.3f",t),force)
end
end
function sysCall_dynCallback(inData)
if inData.afterStep then
local t=sim.getSimulationTime()
local r,force,torque=sim.readForceSensor(h|sim.handleflag_rawvalue)
if r>0 then
print(string.format("raw value in dynamics callback at time %.3f",t+inData.passCnt*inData.dynStepSize),force)
end
end
end