Change volume colour of proximity sensor from script

Typically: "How do I... ", "How can I... " questions
Post Reply
RobAtLab
Posts: 59
Joined: 10 Jan 2018, 17:49

Change volume colour of proximity sensor from script

Post by RobAtLab » 24 Aug 2018, 15:51

Through the GUI one can click on a proximity sensor in the hierachy, then "adjust volume colour" in the "scene object properties" dialog box, then change things like ambient colour or visual pulsation frequency. Is there any way to do this from within a child script, I'm using proximity sensor to send line of sight messages within their illuminatex cones and it would be really helpful for debugging if I could write child scripts such that the cone's visible colour changes when I am sending particular messages. I wondered if some sort of sim.getObjectInt32Paramter() call might help, but I don't thyink there is a parameter available for editing proximity sensor volume colour http://www.coppeliarobotics.com/helpFil ... itySensors . Is there any method y which I might achieve the changing of the volume colour of a proximity sensor from within the child script of the robot which has the proximity sensor as a child object?
Thank you

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

Re: Change volume colour of proximity sensor from script

Post by fferri » 04 Sep 2018, 16:46

It seems it is not possible via the API.

Here's a trick you can try, if you are working with a finite set of colors: create multiple identical copies of the sensor, which differ only by the volume color; change their visibility layer with sim.setObjectInt32Paramter() and sim.objintparam_visibility_layer such that alway only one sensor of the chosen color is visible.

Something like this:

Image

Code: Select all

function sysCall_init()
    sens={}
    for i=1,4 do
        sens[i]=sim.getObjectHandle('Proximity_sensor'..i)
    end
    ...
end

Code: Select all

function switchSensor(j)
    for i=1,#sens do
        sim.setObjectInt32Parameter(sens[i],sim.objintparam_visibility_layer,i==j and 8 or 0)
    end
end
and call switchSensor(i) in the sensing phase

Post Reply