Simple GUI controller

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

Simple GUI controller

Post by DannyYeong » 12 Jul 2015, 21:08

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
Site Admin
Posts: 7267
Joined: 14 Dec 2012, 00:25

Re: Simple GUI controller

Post by coppelia » 13 Jul 2015, 11:13

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

Post by DannyYeong » 13 Jul 2015, 12:06

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
Site Admin
Posts: 7267
Joined: 14 Dec 2012, 00:25

Re: Simple GUI controller

Post by coppelia » 13 Jul 2015, 19:05

Have a look at this topic.

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

Cheers

Post Reply