## sim.rmlMoveToPosition problem

Typically: "How do I... ", "How can I... " questions
sumi_boss
Posts: 31
Joined: 21 Sep 2020, 11:44

### sim.rmlMoveToPosition problem

Hello,

I have a problem with sim.rmlMoveToPosition function. I planned a trajectory for my robot and I want to use this function in a for loop for each small part of this trajectory. The first time I call the function the robot does move, but when I call the function repeatedly (in the loop), for small trajectory increments the robot does not move. Could you give me an idea as to why this happens and how I could fix it?

Cheers

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

### Re: sim.rmlMoveToPosition problem

Hello,

you are probably using bad input values, or the same input values. Have a look at the different possibilities by looking at the demo scene scenes/reflexxesMotionLibraryExamples.ttt. From there you can also see that this function can be decomposed into 3 individual functions: sim.rmlPos, sim.rmlStep and sim.rmlRemove.

Cheers

sumi_boss
Posts: 31
Joined: 21 Sep 2020, 11:44

### Re: sim.rmlMoveToPosition problem

Thanks for the info, I looked at the examples you mentioned. In the examples, you used sim.rmlPos in a threaded script. You first set the object with that function, and then you call the sim.rmlStep function in a while loop. However, this is just for 'stepping'. The original trajectory object remains unchanged. What I would like to do is to slightly change some parameters of the trajectory in the while loop (such as maxVel or targetPos). Is there a way for me to do this?

Cheers

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

### Re: sim.rmlMoveToPosition problem

Yes, you would use the same approach: when calling sim.rmlStep, the function returns a lot of information such as the current position, velocity, etc. If, at some point in the trajectory you feel you want to change the maximum velocity, then simply destroy the RML object, and create a new one that uses as initial parameters (e.g. initial position, velocity, etc.) the ones last returned by previous movement calculations, i.e returned by last call to sim.rmlStep.

Cheers

sumi_boss
Posts: 31
Joined: 21 Sep 2020, 11:44

### Re: sim.rmlMoveToPosition problem

Hi,

I tried doing that, and it works fine for the first iteration of the loop. In the second iteration, the sim.rmlStep function returns an error code -100: RML_ERROR_INVALID_INPUT_VALUES. Since the input values are just the object handle and the time step, I assume something is wrong with the time step. (I checked the object handle, and it is indeed created.) I tried putting sim.getSimulationTimeStep() as the time step, but the error remains. I structured my code as is shown in the example scene. I turn off the automatic thread switching before the while loop and then switch manually near the end of the loop so that the loop is executed once in each simulation step. I don't know what to try next and would very much appreciate any help you could provide.

I am attaching a minimalistic version of the scene.
https://github.com/sumiboss95/coppelia

The problematic part is in the tagretMovements#0 script starting at line 130, before the while loop.

Cheers

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

### Re: sim.rmlMoveToPosition problem

Have a look at the values you are feeding to sim.rmlPos, those are very probably invalid. I get for tragetPosVel following:

Code: Select all

{-0.0028325691819191, -0.94003677368164, 0.38230527153015, 1.6932561397552, 1.5313456058502, -1.702525138855, 0.001, 0.001, -15.297894569397, 0, 0, 0}
which would be 15.29 meters/sec for the 3rd degree of freedom. The RML algorithms can't cope with that, because probably not possible given the other input values.

Cheers

sumi_boss
Posts: 31
Joined: 21 Sep 2020, 11:44

### Re: sim.rmlMoveToPosition problem

Hi,

Yes, that was indeed the problem, and after changing the targetPosVelAccel values, it now works much better. My task is the assemblage of two pieces (each held by a gripper) under a certain force. I place the objects close to each other in a pre-assembly position and then try to assemble them in a loop, as I wrote above. Before the loop, when the objects are close enough in the pre-assembly position, I attach them via a force sensor so I can measure the contact forces. However, I keep encountering the same problem. When the loop starts and the upper gripper tries to lower the upper object (top part), it remains stuck and can't be assembled. At first, I thought this happens because the position isn't good, and it keeps colliding with the bottom part and getting stuck. But that doesn't seem to be the problem. I tried numerous different pre-assembly and assembly positions, and the same thing keeps happening. The weird thing is, the objects don't even seem to collide or touch. The top part gets stuck before it even touches the bottom part.
Do you have any idea why this is happening? And what I could do to find and fix the problem.

Cheers

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

### Re: sim.rmlMoveToPosition problem

Did you try to visualize the contact points? Also, did you try to switch to another physics engine? Is the problem same there?

The two shapes can assemble, I tried it manually. So there must be something else hindering the assembly. Maybe some collision you don't see.

Cheers

sumi_boss
Posts: 31
Joined: 21 Sep 2020, 11:44

### Re: sim.rmlMoveToPosition problem

What do you mean by visualizing contact points? I paused the simulation after the top part gets stuck, zoom the objects, and inspect them visually and I cant see a collision anywhere. As I said, the objects aren't even touching.

I tried with different physics engines and the same thing happened. I also tried assembling it out of the loop, with a single call to sim.rmlMoveToPosition, and it did work. That's why I find it strange that it won't work now. It's as if there's some problem with this idea of incrementally changing the trajectory in a loop.

Or there's maybe a collision despite the fact that it seems like there isn't one. But I don't know how to check that.

Cheers

coppelia