## Problem with Ik configuration

Typically: "How do I... ", "How can I... " questions
Bellinsbauer
Posts: 21
Joined: 22 Apr 2018, 07:44

### Problem with Ik configuration

Hello!
I post here my scene. Inside, I created a Scara robot and a producer of pure shapes to simulate random pieces that flow on a conveyor belt. My purpose is to follow these random pieces once they pass through a proximity sensor that gives me the handle of the current piece. After some time I would like to grab the piece and to move it to the other conveyor. I hope the main idea is clear. My questions are:
- When the piece passes through the proximity sensor the Scara robot makes a sort of "jump" and I read that to avoid this issue, I should place the target dummy at the tip dummy position. I did it in the function to enable the ik mode but it seems that something is wrong.
- The suction pad doesn't grab the objects but I think there is something wrong with the high where I place the target.
- When I move my robot in the other conveyor belt It doesn't reach it but it moves in the position (0,0,0) and I am wondering why.

This is my scene:
https://www.dropbox.com/s/68ft9h3ffuja5 ... a.ttt?dl=0

If you could help me with some advices , they would be really appreciated.
Thank you in advance,
Leonardo.

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

### Re: Problem with Ik configuration

Hello,

you are trying to solve several problems at once, you should focus on one problem at a time.
First, with your scara robot, I am not sure it is the right approach to move the end-effector in Euclidean space, since you'll have to deal with the singular configurations of your robot (typically at simulation start). I'd run the robot in configuration space.
In any case, you can't simply have the target IK dummy jump into a position instantaneously: you should gradually guide and move that dummy to where you want to be with your end-effector. You'll have to use the sim.rmlMoveToPosition for instance.

Also, if you want your sucction cup to work, it should come closer to the part (the sucction cup works with a proximity sensor that will first have to detect the part).

Cheers

Bellinsbauer
Posts: 21
Joined: 22 Apr 2018, 07:44

### Re: Problem with Ik configuration

For what concern the suction pad, I supposed the problem was the distance between the pad and the object and I will solve it later. But my main issue is the other one. When a piece is created, I want to follow it with my end-effector. Why? Because I want to record the time that my scara robot takes to reach the object. After that, I would like to compare my Scara with a redundant Scara robot, always in terms of time took to reach several objects. For this reason, I thought to make my target child of the object and then, using the sim.rmlMoveToPosition, bring the end effector closed to the object with the max velocity and the max acceleration. But when I use sim.setObjectParent to put the IK target in the wanted position, the end effector jumps immediactely there, without using the sim.rmlMovetoPosition. And I'm wondering why.
Thank you.

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

### Re: Problem with Ik configuration

Maybe it is a good idea to first start with something simple, and go step-by-step, since what you are trying to achieve is not that straight-forward.
Have a look at this scene, that illustrates in a simple way how the RML-functions can be used to move a joint (the approach is very similar in case you want to move an object via the RML-functions).

Cheers

Bellinsbauer
Posts: 21
Joined: 22 Apr 2018, 07:44

### Re: Problem with Ik configuration

Thank you. But should I work in dynamics for what I'm trying to do? Because if I put all the links of my robot in 'not dynamic' the end-effector jumps immediately to the target position.

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

### Re: Problem with Ik configuration

Because you are not using the RML functionality to move your target dummy. If you did, your target dummy would not jump (or you are using the RML functions not correctly). Of course you can also, when your robot is in dynamic mode, set the joint upper velocity limit . But then you are not in control of the end-effector trajectory, which might not be a straight line anymore.

Cheers

Bellinsbauer
Posts: 21
Joined: 22 Apr 2018, 07:44

### Re: Problem with Ik configuration

Two posts before, you said "you can't simply have the target IK dummy jump into a position instantaneously: you should gradually guide and move that dummy to where you want to be with your end-effector". I understand the idea but I can't do that. Because my robot should know that it must follow the object where the target is attached to. If I gradually move the target dummy to the object, then the tip dummy should follow it till the object. But this is not what I want. I would like that the robot intercepts (with his tip dummy attched to the end-effector) the object ( where the target dummy should be attached to) as soon as possible , once defined his joint velocity and acceleration limits. I give you an example: when the proximity sensor sees an object, the robot should start to follow it ( which is moving on a conveyor belt) with the minimum actuation time.
I don't know if it is possible to do or if I'm not able to understand if you got the idea.
Thank you.

Bellinsbauer
Posts: 21
Joined: 22 Apr 2018, 07:44

### Re: Problem with Ik configuration

I replace here my question. Is it possible with V-rep to reach a moving object with the end-effector of a robot with the MINIMUM ACTUATION TIME (the minimum time used by a motor to make a movement with velocity and acceleration limits)? So, without knowing WHERE the object will be reached but just knowing the joint velocity and acceleration limits. I don't need that my end-effector follows a straight line. The trajectory followed by the end effector will be the one which allows my robot to reach as soon as possible the object. In a positive case , what would be the best way to do it?
Cheers.

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

### Re: Problem with Ik configuration

You can do this, but how you do it and how the result looks like really depends on the used algorithm. It is not such an easy task. There are different approaches, but this is not dependent on V-REP. V-REP offers tools, you create the algorithms.

Here a raw example of part tracking from within a threaded child script:

Code: Select all

RobPick = function(_dummyHandleToFollow,approachHeight,blend,nulling,dwTime)
local dummyHandleToFollow=createDummyToFollowWithOffset(_dummyHandleToFollow,pickOffset)

mDone = 0
app = approachHeight
while (mDone < 4) do
local dt=sim.getSimulationTimeStep()
partPos = sim.getObjectPosition(dummyHandleToFollow,model)
partOr =  sim.getObjectOrientation(dummyHandleToFollow,model)
partVel,partorV = sim.getObjectVelocity(dummyHandleToFollow)
partPV = {partPos[1]+partVel[1]*dt,partPos[2]+partVel[2]*dt,partPos[3]+partVel[3]*dt+app,0.0,
partVel[1]*dt,partVel[2]*dt,partVel[3]*dt,0.0}

local rmlObj=sim.rmlPos(4,0.0001,-1,curPVA,MaxVAJ,selVec,partPV)
res,nextPVA=sim.rmlStep(rmlObj,dt)
sim.rmlRemove(rmlObj)

newPos = {nextPVA[1],nextPVA[2],nextPVA[3]}
sim.setObjectPosition(ikModeTargetDummy,model,newPos)
sim.setObjectOrientation(ikModeTargetDummy,model,{0,0,nextPVA[4]})
handleKinematics()
curPVA = nextPVA;
dist2go = math.sqrt((nextPVA[1]-partPV[1])*(nextPVA[1]-partPV[1]) + (partPV[2]-nextPVA[2])*(partPV[2]-nextPVA[2]) + (partPV[3]-nextPVA[3])*(partPV[3]-nextPVA[3]))--*1000.0
if (mDone == 0) and(dist2go < blend) then
mDone =1
dist2go = 100.0--denom*proMov
app = .0
end
if (mDone == 1) and(dist2go < nulling) then
mDone =2
dist2go = 100.0--denom*proMov
t2=sim.getSimulationTime()+dwTime
end
if (mDone == 2) and(t2 < sim.getSimulationTime()) then
mDone =3
dist2go = 100.0--denom*proMov
app = approachHeight
end
if (mDone == 3) and(dist2go < blend) then
mDone =4
end
sim.switchThread() -- Important, in order to have the thread synchronized with the simulation loop!
end
sim.removeObject(dummyHandleToFollow)
end

Cheers

Bellinsbauer
Posts: 21
Joined: 22 Apr 2018, 07:44

### Re: Problem with Ik configuration

Is it possible for you to post the scene of that script? Because it's a bit tough for me to understand what happens.
Thank you for you help