Change volume colour of proximity sensor from script

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

Change volume colour of proximity sensor from script

Post by RobAtLab »

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 ... 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

Posts: 681
Joined: 09 Sep 2013, 19:28

Re: Change volume colour of proximity sensor from script

Post by fferri »

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:


Code: Select all

function sysCall_init()
    for i=1,4 do

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)
and call switchSensor(i) in the sensing phase

Post Reply