Page 1 of 1

Simple GUI controller

Posted: 12 Jul 2015, 21:08
by DannyYeong
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

Re: Simple GUI controller

Posted: 13 Jul 2015, 11:13
by coppelia
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

Re: Simple GUI controller

Posted: 13 Jul 2015, 12:06
by DannyYeong
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

Re: Simple GUI controller

Posted: 13 Jul 2015, 19:05
by coppelia
Have a look at this topic.

Have alos a look how the model Models/examples/simple Ackermann steering.ttm works.

Cheers