Khepera K3 model, how is the UI done?

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

Khepera K3 model, how is the UI done?

Post 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

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

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

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

RobAtLab
Posts: 92
Joined: 10 Jan 2018, 17:49

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

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

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

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

Post 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

Post Reply