## Simple GUI controller

Typically: "How do I... ", "How can I... " questions
DannyYeong
Posts: 44
Joined: 24 Feb 2015, 17:06

### Simple GUI controller

Hi,

How do I make a simple GUI controller on a simulation that can adjust a point's location (xyz)? I was thinking like a 4 translational buttons to go left,right,front,back on x and y directions and 1 rotational button to go up,down directions. This is for controlling a quad I've made to follow that targeted point.

Thanks,
Danny

coppelia
Posts: 7396
Joined: 14 Dec 2012, 00:25

### Re: Simple GUI controller

Hello Danny,

then simply create a custom UI which has sliders (e.g. one slider for each axis). The sliders will have some IDs.

Then, inside of a non-threaded child script (for example), you could do:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
uiHandle=simGetUIHandle('myUiName')
sliderXId=2
sliderYId=3
sliderZId=4
myStaticObjectHandle=simGetObjectHandle('myStaticObjectName')
end

if (sim_call_type==sim_childscriptcall_actuation) then
posx_0_1=simGetUISlider(uiHandle,sliderXId)/1000
posy_0_1=simGetUISlider(uiHandle,sliderYId)/1000
posz_0_1=simGetUISlider(uiHandle,sliderZId)/1000
simSetObjectPosition(myStaticObjectHandle,-1,{posx_0_1,posy_0_1,posz_0_1})
end
Cheers

DannyYeong
Posts: 44
Joined: 24 Feb 2015, 17:06

### Re: Simple GUI controller

coppelia wrote:Hello Danny,

then simply create a custom UI which has sliders (e.g. one slider for each axis). The sliders will have some IDs.

Then, inside of a non-threaded child script (for example), you could do:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
uiHandle=simGetUIHandle('myUiName')
sliderXId=2
sliderYId=3
sliderZId=4
myStaticObjectHandle=simGetObjectHandle('myStaticObjectName')
end

if (sim_call_type==sim_childscriptcall_actuation) then
posx_0_1=simGetUISlider(uiHandle,sliderXId)/1000
posy_0_1=simGetUISlider(uiHandle,sliderYId)/1000
posz_0_1=simGetUISlider(uiHandle,sliderZId)/1000
simSetObjectPosition(myStaticObjectHandle,-1,{posx_0_1,posy_0_1,posz_0_1})
end
Cheers

Oh! Then how about implementing a button instead? When the button is pressed(hold), an incremental value will be sent to update the current coordinates.

Thanks,
Danny

coppelia