Gas sensors in CoppeliaRobotics

Typically: "How do I... ", "How can I... " questions
Post Reply
kgsingh555
Posts: 3
Joined: 04 Jul 2023, 10:55

Gas sensors in CoppeliaRobotics

Post by kgsingh555 »

Hii

I would like to use a gas sensor to tap the concentration and make the
mobile robot decide its course in the arena. How it can be done? Is it
possible to simulate a plume dispersion and record its concentration
with a gas sensor?

coppelia
Site Admin
Posts: 10410
Joined: 14 Dec 2012, 00:25

Re: Gas sensors in CoppeliaRobotics

Post by coppelia »

Hello,

the best you can do is have a function the will compute a concentration wased on a 3D position, e.g.:

Code: Select all

function getConcentration(pos)
    return(pos[1]+pos[2]+pos[3])
end 
Then, as your robot moves in the 3D space, you can get a computed gas concentration based on the robot's position e.g. obtained with sim.getObjectPosition.

Cheers

kgsingh555
Posts: 3
Joined: 04 Jul 2023, 10:55

Re: Gas sensors in CoppeliaRobotics

Post by kgsingh555 »

coppelia wrote: 05 Jul 2023, 14:54 Hello,

the best you can do is have a function the will compute a concentration wased on a 3D position, e.g.:

Code: Select all

function getConcentration(pos)
    return(pos[1]+pos[2]+pos[3])
end 
Then, as your robot moves in the 3D space, you can get a computed gas concentration based on the robot's position e.g. obtained with sim.getObjectPosition.

Cheers
Hi!! Thanks for response. For a while, I was not active on the forum. I have a case that needs plume simulation and tapping the odor concentration with gas sensor. Can the plume simulation is possible alongwith measurement of concentration at different locations with a mobile robot?
Hope my question will be addressed?

fferri
Posts: 1267
Joined: 09 Sep 2013, 19:28

Re: Gas sensors in CoppeliaRobotics

Post by fferri »

Yes.

You would compute the diffusion model yourself e.g. in sysCall_actuation() updating C[x][y][z] (the gas concentration at position x, y, z) using whatever diffusion model and environment parameters you wish.

e.g.

Code: Select all

-- lua
function sysCall_init()
    C = ... -- create new 3D grid
end

function sysCall_actuation()
    C_new = table.deepcopy(C)
    for i = 2, nx-1 do
        for j = 2, ny-1 do
            for k = 2, nz-1 do
                -- Update concentration
                C_new[i][j][k] = C_new[i][j][k] + ... -- C[i][j][k] is the concentration at previous step
            end
        end
    end
    C = C_new
end

function getConcentration(x, y, z)
    local i = ...
    local j = ...
    local k = ...
    return C[i][j][k]
end
then from another script (e.g. from robot's script) you can call the getConcentration(x, y, z) function, using sim.callScriptFunction or sim.getScriptFunctions

kgsingh555
Posts: 3
Joined: 04 Jul 2023, 10:55

Re: Gas sensors in CoppeliaRobotics

Post by kgsingh555 »

Thanks for reply. Is it possible to visualize the plume simulation in coppeliaSim?

fferri
Posts: 1267
Joined: 09 Sep 2013, 19:28

Re: Gas sensors in CoppeliaRobotics

Post by fferri »

Yes, you can use OcTrees, Point Clouds or Drawing Objects, and their relative APIs.

However with a dense scalar field like this, it would be difficult to look at the whole field at once. Probably you want to look at it one particular 2D slice at a time.

Post Reply