# Control robot from gamepad with SpeedJ or ServoJ

**URL:** <https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293>\
**Category:** URScript\
**Created:** [May 13, 2020, 10:34am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293 "2020-05-13T10:34:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon51669579](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon51669579](https://forum.universal-robots.com/u/anon51669579)\
**Post date:** [May 13, 2020, 10:34am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/1 "2020-05-13T10:34:57Z")

</div>

Hey,

I have encountered a problem. If I use the servoj script command and then speedj script command I got polyscope error: “Another thread is controlling the robot”. What is the problem? why can’t I switch from servoj to speedj?

Thanks in Advance,

---

<div class="post-metadata">

**Author:** ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)\
**Post date:** [May 15, 2020, 8:01am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/2 "2020-05-15T08:01:06Z")

</div>

Hi,

i never used a switch to speedj from servoj, but a switch to movel,movep and movej. I think the servoj command is not yet completed as you’re switching. Are you using the optional t param of the speedj command? can you show a minimal example of your code?

---

<div class="post-metadata">

**Author:** ![anon51669579](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon51669579](https://forum.universal-robots.com/u/anon51669579)\
**Post date:** [May 17, 2020, 1:20pm UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/3 "2020-05-17T13:20:19Z")

</div>

Yes, that’s right. I have to wait until servoj complete the motion. however I don’t want to wait till the robot stops. for example if I use speedl with specific linear velocity and after that with another speedl command. the arm will complete the first velocity command then stops and after that initiate another velocity command. I want to execute a siries of velocity commands so the arm will execute smooth trajectory. Do you know how can I manage to do that with speedl or any other velocity control method?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)\
**Post date:** [May 18, 2020, 6:37am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/4 "2020-05-18T06:37:10Z")

</div>

which velocity command is suitable highly depends on your application. If you want a dynamic change of the motion on runtime, servoj is best. If your path is pre-defined and does not have too narrow waypoint distances, i would recommend using movej with high blend settings. Can you describe your application?

---

<div class="post-metadata">

**Author:** ![anon51669579](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon51669579](https://forum.universal-robots.com/u/anon51669579)\
**Post date:** [May 18, 2020, 12:22pm UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/5 "2020-05-18T12:22:55Z")

</div>

I want to control the robot via logitech gamepad with velocity commands in operational space. I have tried speedl, but I must wait until the arm reaches the defined linear velocity and then stop. after that the arm executes the next velocity command. servoj gets a joints input and I want to send velocity commands.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)\
**Post date:** [May 18, 2020, 1:36pm UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/6 "2020-05-18T13:36:08Z")

</div>

Hi,

interesting task 🙂 i would love to try that too…  
you can generate a pose and use servoj with the inverse kinematics of that pose:  
servoj(get\_inverse\_kin(targetPose),t=…)  
I would try generating waypoints depeding on your analog sticks direction and position.

---

<div class="post-metadata">

**Author:** ![anon51669579](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon51669579](https://forum.universal-robots.com/u/anon51669579)\
**Post date:** [May 21, 2020, 10:00am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/7 "2020-05-21T10:00:53Z")

</div>

thanks, my problem is that it is not smooth. I can send commands, but it completes the commands one at a time, it makes not a smooth motion. I mean if I give one position commands it stops not smoothly in the end of the motion.

thanks for the support.

---

<div class="post-metadata">

**Author:** ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)\
**Post date:** [May 25, 2020, 8:33am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/8 "2020-05-25T08:33:58Z")

</div>

Hi,

what are your servoj parameters and your target position data update cycle?

---

<div class="post-metadata">

**Author:** ![anon51669579](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon51669579](https://forum.universal-robots.com/u/anon51669579)\
**Post date:** [May 31, 2020, 8:34am UTC](https://forum.universal-robots.com/t/control-robot-from-gamepad-with-speedj-or-servoj/7293/9 "2020-05-31T08:34:22Z")

</div>

Hey I have managed to control the arm with gamepad + ros (I will share the code once it will work with ros). However, I need to disable the ros controller first otherwise the controller brings it back to initial position, before the gamepad manipulation. I struggle to disable the controller because once I disable it. the communication drops down.
