## Control a robot arm with a joystick

Typically: "How do I... ", "How can I... " questions
Tabo
Posts: 11
Joined: 28 Oct 2014, 10:45

### Control a robot arm with a joystick

Good afternoon. I would like to know how I can do to control a robot arm with a joystick. My OS is windows, and as I have read I need to download a plugin. I would like to bring forth some information from me as I do and where I download this plugin.

Thank you.

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

### Re: Control a robot arm with a joystick

Hello,

the Joystick plugin should already be installed on your Windows V-REP installation (i.e. it is the file v_repExtJoystick.dll). The project files for this plugin are located in programming/windowsOnlyProjects/v_repExtJoystick.

From within a child script you can retrieve information about your joysticks with following 2 functions:

Code: Select all

local numberOfJoyticks=simExtJoyGetCount()
local axes,buttons,rotAxes,slider,pov=simExtJoyGetData(deviceIndex)

Cheers

Tabo
Posts: 11
Joined: 28 Oct 2014, 10:45

### Re: Control a robot arm with a joystick

Thank you very much . I would like to ask also if you could show a little code as me these functions are used( or any example that you provided ) as the support not find them explained. I would be helpful since I am new to this world.

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

### Re: Control a robot arm with a joystick

There are only the two functions that I listed in my previous post. The first reads the number of devices attached, the second reads the state of the joystick.

Try something like (from within a non-threaded child script):

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
console=simAuxiliaryConsoleOpen("output",20,0)
end

if (sim_call_type==sim_childscriptcall_sensing) then
local axes,buttons,rotAxes,slider,pov=simExtJoyGetData(0)
if axes then
simAuxiliaryConsolePrint(console,"Axis1: "..axes[1]..", axis2: "..axes[2].."\n")
else
simAuxiliaryConsolePrint(console,"Could not find a joystick\n")
end
end
Cheers

lshachar
Posts: 9
Joined: 01 Aug 2015, 18:00

### Re: Control a robot arm with a joystick

I would have not figured out how to use the plugin without your example... I think this should be better documented since I found no other working example for it.

Thank you :)