Page 1 of 1

FPS drop (calculations)

Posted: 04 Mar 2019, 15:27
by pps
Hello,

i have remoteAPI contolled robot following path which depends on the distance from road. Robot have child-script like that:

Code: Select all

if (sim_call_type==sim.syscb_init) then
    nameSuffix=sim.getNameSuffix(nil)

    if nameSuffix>=0 then
        distance0Name='distance0#'..nameSuffix
        distance4Name='distance4#'..nameSuffix
        distance8Name='distance8#'..nameSuffix
        distance16Name='distance16#'..nameSuffix
        distance32Name='distance32#'..nameSuffix
    else
        distance0Name='distance0'
        distance4Name='distance4'
        distance8Name='distance8'
        distance16Name='distance16'
        distance32Name='distance32'
    end
    
    distance0=sim.getObjectHandle(distance0Name)
    distance4=sim.getObjectHandle(distance4Name)
    distance8=sim.getObjectHandle(distance8Name)
    distance16=sim.getObjectHandle(distance16Name)
    distance32=sim.getObjectHandle(distance32Name)
    pointCloud=sim.getObjectHandle('PathPoint_cloud#')
end

if (sim_call_type==sim.syscb_sensing) then
    local res,d=sim.checkDistance(distance0,pointCloud,0)
    if res>0 then
        local seg={d[1],d[2],d[3],d[4],d[5],d[6],d[7]}
        local data=sim.packFloatTable(seg)
        sim.setStringSignal(distance0Name,data)
    else
        sim.clearStringSignal(distance0Name)
    end
    
    local res,d=sim.checkDistance(distance4,pointCloud,0)
    if res>0 then
        local seg={d[1],d[2],d[3],d[4],d[5],d[6],d[7]}
        local data=sim.packFloatTable(seg)
        sim.setStringSignal(distance4Name,data)
    else
        sim.clearStringSignal(distance4Name)
    end

    local res,d=sim.checkDistance(distance8,pointCloud,0)
    if res>0 then
        local seg={d[1],d[2],d[3],d[4],d[5],d[6],d[7]}
        local data=sim.packFloatTable(seg)
        sim.setStringSignal(distance8Name,data)
    else
        sim.clearStringSignal(distance8Name)
    end
    
    local res,d=sim.checkDistance(distance16,pointCloud,0)
    if res>0 then
        local seg={d[1],d[2],d[3],d[4],d[5],d[6],d[7]}
        local data=sim.packFloatTable(seg)
        sim.setStringSignal(distance16Name,data)
    else
        sim.clearStringSignal(distance16Name)
    end
    
    local res,d=sim.checkDistance(distance32,pointCloud,0)
    if res>0 then
        local seg={d[1],d[2],d[3],d[4],d[5],d[6],d[7]}
        local data=sim.packFloatTable(seg)
        sim.setStringSignal(distance32Name,data)
    else
        sim.clearStringSignal(distance32Name)
    end
end
Well, everything works, but only with one robot simulation runs smoothly. If I insert second robot, there are 5 more calculations and FPS drops down (and on with every new robot). Is there a way to fix it up?

Thanks.

Re: FPS drop (calculations)

Posted: 06 Mar 2019, 15:23
by coppelia
Hello,

unfortunately it is normal that your calculation increases if you double the number of calculations in your scene. What you however could do is limit the number of calculations, say, to once per second or so, if that refresh frequency is still good enough for you.

Cheers