Page 1 of 1

Khepera K3 model, how is the UI done?

Posted: 16 Nov 2019, 22:20
by RobAtLab
The default khepera K3 model includes in v-rep 3.5 includes a UI which when thr robot is clicked upo9n will appear but if the robot, during the simulation run, doesn't get selected stays invisible. How is this done? I want to do something similar for models of my own but all I can see within the khepera's script is a reference to a UI object named "K3_stateVisualization". I can't see that object in the hieracrhy anywhere. The youbot 4 wheeled one armed manipulator robot also has a similar featrue where the Ui is only seen when the robot model is selected. How do you make a UI which only opens when a robot is selected? Thank You


P.S. I've previously tried UI's based on the example from the BubbleRob tutorial but either these stay in place permanently, or you enable the "closeable" which gives them a red X to click on to close but then there is no apparent way of re-opening them later on during the sim.

P.P.S. I started this thread reporting two issues, I just managed to fix the second one though, I had made a typo in my code which caused the trouble that I thought was down to the UIs

Re: Khepera K3 model, how is the UI done?

Posted: 18 Nov 2019, 11:50
by fferri
RobAtLab wrote: 16 Nov 2019, 22:20 How is this done? I want to do something similar for models of my own but all I can see within the khepera's script is a reference to a UI object named "K3_stateVisualization". I can't see that object in the hieracrhy anywhere.
Those old-style UIs are deprecated, because they don't offer much versatility.

The same can be achieved with the CustomUI plugin, but the UI will be in a separate window rather than being in the 3D view.

Re: Khepera K3 model, how is the UI done?

Posted: 22 Nov 2019, 16:24
by RobAtLab
Just for quick testing if there an easy way to write lua script, much like that used on the bubblerob tutorial which, like the khepera's UI, lets the UI only appear when the robot is selected. I only need basic sliders like the bubbleRob uses and I can get those working fine. The one change I want to make is to have it appear only when the robot is selected ratehr than get in the way all the time.

Re: Khepera K3 model, how is the UI done?

Posted: 27 Nov 2019, 14:32
by coppelia
Hello, sorry about the delay,

yes, you will have to use a customization script for that, if you intent to have the dialog also appear/disappear while simulation is not running. Much like it was done with the default floor in a CoppeliaSim scene (here only the relevant code, refer to the original for details):

Code: Select all

function sysCall_init()
    model=sim.getObjectAssociatedWithScript(sim.handle_self)
end

function sysCall_cleanup()
    hideDlg()
end

function sysCall_nonSimulation()
    local s=sim.getObjectSelection()
    if s and #s>=1 and s[1]==model then
        showDlg()
    else
        hideDlg()
    end
end

function sysCall_beforeSimulation()
    hideDlg()
end

function sysCall_beforeSimulation()
    hideDlg()
end

function closeEventHandler(h)
    sim.removeScript(sim.handle_self)
end

function showDlg()
    if not ui then
        ...
    end
end

function hideDlg()
    if ui then
        simUI.destroy(ui)
        ui=nil
    end
end
Cheers