Page 1 of 2

Applying a Constant Force

Posted: 08 Jun 2017, 15:21
by javl0p
Hello there,

I'm working on the following simulation:

https://www.dropbox.com/s/fbfi0lejl1uj5 ... 1.ttt?dl=0

It's simply an iiwa robot in inverse kinematic mode, to which I try to apply a constant force. As you can see, I've used a dynamically enable but non-respondable shape (which is attached to the robots end effector) to do this, due to the fact that I want to apply a force in the center of mass of this shape.

I wonder if there is a way to apply a constant force to the shape. So far I'm using simAddForceAndTorque, which applies an instant force. I've used a non-threaded child script in order to do so. Apart from the error message that I am getting (One of the function's table size is not correct. (simAddForceAndTorque)) I have another problem: the force is not constant, but intermittent.

I suposse that this is due to the fact that the force is applied everytime the actuation part of the non-threaded child script is ran, and that the physics engine is using a much smaller time step (10 times smaller, if I'm not mistaken). So, as a result, the force is applied intermittently.

I'd like to know how could I set the time step in order to be equal for both, the physic engine and the simulation itself, and what consequences could be derived from it. Also, I'd like to know if there is a simpler way to apply a constant force. (shouldn't there be a function to do this?)

As always, thank you for the help!

Re: Applying a Constant Force

Posted: 09 Jun 2017, 18:28
by coppelia
Hello,

first, simAddForceAndTorque is complaining because the third arg. is not current, since it contains {0,0,w}=={0,0,nil} in the first simulation step, or as long as no signal is being set for Weight.
The force that you apply with simAddForceAndTorque will be appropriately applied over all dynamic time steps, so this shouldn't be the reason.

If you want the same simulation step as dynamic step, then adjust the Time step to 5ms (in here), or the same amount as the dynamic time step.

Cheers

Re: Applying a Constant Force

Posted: 14 Jun 2017, 09:18
by javl0p
Hello,

thank you for the answer. I changed the simulation time step to 5ms. However, results are the same. When applying the -120N force, the 6th joint starts to follow a sinusoidal motion up and down. I figured that if the force is applied at every step and the robot is in IK mode, it should be able to find a new stable position, but instead I get this constant motion. I've tried with different physic engines but results are similar.

One interesting fact is that by changing the applied "weight" to 120N (positive), the results match my expectations: joint torques change to adapt to the new dynamic situation and new equilibrium is reached. What could be happening?

Thanks!!

EDIT: the applied forces and torques in the function simAddForceAndTorque are referred to the global reference frame or to a local one?

EDIT 2: I found some odd behaviour in my model. When applied force "Weight" is -60, -80 or even -110, the robot behaves as expected. However, when forces reach -120, the iiwa starts to follow this up-down motion, which is even more obvious when forces are higher (-150N)

Re: Applying a Constant Force

Posted: 14 Jun 2017, 14:05
by coppelia
From the doc:
  • force: pointer to 3 values that represent the force (in absolute coordinates) to add. Can be NULL.
  • torque: pointer to 3 values that represent the torque (in absolute coordinates) to add. Can be NULL
So the force and torque is relative to the world reference frame.

You are applying a force/torque to a robot that is handled in IK mode. Even if the joints are in hybrid IK mode, each joint's controller will exert the force needed in order to reach the joint angles that were computed by IK. On top of that you are adding an external force and mixing things up.

Cheers

Re: Applying a Constant Force

Posted: 14 Jun 2017, 14:57
by javl0p
Hi coppelia,

thanks for the fast answer.

I already fixed the problem with simAddForceAndTorque by putting a if w~=nil then command before the action takes place.

Regarding the forces put on top of the IK action, Is that really problematic? Because that is exactly what I intend to do, to subject the iiwa to external forces while in IK mode, in order to study the reaction torques at the joints. Is there any other way to do that, less problematic perhaps?

As part of my study, I also need to know the reaction forces at the end tip of the robot. For that matter, putting a force sensor was very useful, but the results are distorted when the robot moves, since the orientation of the force sensor also moves, and the measured forces and torques are relative to the sensor's frame of reference. Is there any way to make the sensor measure forces and torques relative to the general frame of reference?

I post the scene here, in case it is useful for you:

https://www.dropbox.com/s/fbfi0lejl1uj5 ... 1.ttt?dl=0

Again, thank you very much!

Re: Applying a Constant Force

Posted: 16 Jun 2017, 07:50
by coppelia
You will have to perform coordinate transformations. Have a look at simGetObjectMatrix, simMultiplyVector, simInvertMatrix and simMultiplyMatrices for instance.

e.g. if you have a vector V expressed relative to the ref. frame of object A, you can express that vector relative to the world coordinate with:

Code: Select all

local m=simGetObjectMatrix(objectA,-1)
local vAbs=simMultiplyVector(m,V)
if that vector V is a force, then you only want to orient it relative to the world, so you will have to first discard the translation info in the matrix as in following example:

Code: Select all

local m=simGetObjectMatrix(objectA,-1)
m[4]=0 -- x=0
m[8]=0 -- y=0
m[12]=0 -- z=0
local vAbs=simMultiplyVector(m,V)
Cheers

Re: Applying a Constant Force

Posted: 16 Jun 2017, 09:01
by javl0p
Ok thanks coppelia! I'll implement that right away!

Going back to the point of applying forces over a IK constrained system: when applied forces are bigger (over 100 N generlly), the robots start to act crazy. What can I do about it?

EDIT: I simulated with the new actualization (3.40) and the problem seems to be solved. No stumbling behavior.

Regards!!

Re: Applying a Constant Force

Posted: 01 May 2019, 11:11
by Misbah Iqbal
Sir I am also working on this type of work. I have made a 3 DOF manipulator. at the end I have attached a force sensor and then en-effector. I have set all the joints in torque/force mode and manipulator makes a circle. I want to apply the external force at the end-effector such that it deviates from its path and when I remove this external force manipulator come back and follow rest of its path...
How can I do this task
PLease help me out..

Re: Applying a Constant Force

Posted: 07 May 2019, 09:53
by coppelia
Did you try with sim.addForce or sim.addForceAndTorque?

Cheers

Re: Applying a Constant Force

Posted: 16 Jun 2019, 12:42
by Misbah Iqbal
Yes, I have used both commands one by one. It seems that it deviates from path when I set force along x-axis 100 only, like this

q=sim.getSimulationTime()
if q >= 10 and q <= 11 then
sim.addForce(Tip,{0,0,0},{200,0,0})
--sim.addForceAndTorque(Tip,{100,0,0},{0,0,0})
end
w=sim.getSimulationTimeStep()
if q >= 11 then
w=sim.handleDynamics(w)

But when I read joint angles, it gives nill value. I don't know what's the problem.

I have another question, can I call such thing "impedance control". if is it not an impedance control then how can I implement it.
if anyone has any idea about it, please tell me its solution

Best regards