Python Remote API IK Mode--Joints Spaz Out

Typically: "How do I... ", "How can I... " questions
Post Reply
jchoi2507
Posts: 7
Joined: 11 Jun 2021, 09:46

Python Remote API IK Mode--Joints Spaz Out

Post by jchoi2507 »

I'm using CoppeliaSim 4.1 and remote API connection (through Python) to control the joints of the UR10 robot. I'm using 4.1 so that I can use inverse kinematics and tip&target tracing so that the robot's tip will follow the target. The current version of 4.2 only has inverse kinematics through child scripting and Lua, but since my goal is to control the robot purely remotely, you can see why I need an earlier version..

My python script essentially moves the coordinates of the target to the desired user's input's coordinates (x,y,z,alpha,beta,gamma). Essentially, I've replicated the action of the robotic arm moving to wherever the user wants it to move it to.

The one problem I have is this: The joints in the robot seem to behave erratically. I have created an IK group + element, and linked tip and target. Previous forum posts suggest experimenting with the dynamic mode + hybrid enabled, but those didn't work. Moreover, I've tried increasing the maximum torque + speed allowed in the dynamics settings but to no avail. The joints just seem to "spaz out" sporadically and uncontrollably whenever I start the simulation.

Any input is highly appreciated, thanks.

jchoi2507
Posts: 7
Joined: 11 Jun 2021, 09:46

Re: Python Remote API IK Mode--Joints Spaz Out

Post by jchoi2507 »

To clarify, the tip does indeed follow the target when I change the target coordinates, it just doesn't do it so "smoothly"--all the joints just keep twitching. However, the fact that the joints react to changes in the target coordinates does imply some sort of connection between the tip and target.

This is why I suspect the problem has to do with the pre-defined settings of the joints (initial angles) or something to do with the robot's singularity...

jchoi2507
Posts: 7
Joined: 11 Jun 2021, 09:46

Re: Python Remote API IK Mode--Joints Spaz Out

Post by jchoi2507 »

Okay so I figured the problem out--in the IK element settings, I disabled the orientation (alpha-beta, gamma) checkmarks and my remote API Python script works like a charm! One question is why though, considering the UR10 robotic arm has 6 degrees of freedom, shouldn't it be suited to take 6 variables?

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Python Remote API IK Mode--Joints Spaz Out

Post by coppelia »

Hello,

first, you can do exactly the same kind of IK operations with the new, scripted IK functionality: once your IK task is prepared, you can simply move the target and the mechanism (e.g. kinematic chain) will follow. You can do this locally, but also remotely of course (e.g. from a remote API client or from a ROS node).

You can even set-up the kinematic tasks remotely. For that you have different possibilities, the simplest would probably to script the task, and send it over for execution in CoppeliaSim.

To your other question: having a kinematic chain that has 6 joints doesn't necessarily mean that the end-effector will have 6 degrees of freedom. Normally yes, but not at all times (e.g. think of singular configurations, or situations where one or more joints are locked because of joint limits, etc.).
Make sure to also carefully chose the resolution method and damping factor. If you have singular configurations happening from time to time, it is probably better to use a damped resolution method (DLS) with some good damping. And increase the number of iterations.

Have a look at the demo scene (available from V4.2.0) scenes/kinematics/smoothMovementsInFkAndIk.ttt that uses the same robot, and where its end-effector is controlled in position and orientation (and the robot is additionally also controlled in FK).

Cheers

Post Reply