question about velocity

Typically: "How do I... ", "How can I... " questions
Post Reply
LatvianStudent

question about velocity

Post by LatvianStudent » 09 Sep 2013, 14:53

Hello,
I am currently working on a robot model with 6 DoF and I've been struggling with a velocity issue for a few days now. First of all, I've got a text file containing information about each joint's angular position (in degrees) every 12 miliseconds.

Example:

time A1 A2 A3 A4 A5 A6

+0.072000 +66.135904 -37.509489 +60.583252 +144.169346 -55.776944 -281.939974
+0.084000 +66.138158 -37.513439 +60.573022 +144.132962 -55.781391 -281.900778
+0.096000 +66.141132 -37.518651 +60.559521 +144.084941 -55.787261 -281.849046
+0.108000 +66.144920 -37.525290 +60.542326 +144.023788 -55.794736 -281.783166

My program is applying each row of A1..A6 values to joint1..joint6 using simRMLMoveToJointPositions function, however, I cannot get the simulation time to match the time in my text document. I've tried calculating the velocity at each point simply by substracting the previous angle from the current angle and dividing the result by my timestep of 12 ms (0.012 s), but that didn't work. I've also tried putting simWait(0.012) after each row, but that also didn't work.

Any suggestions on how to get my robot to move to each row's angular positions in exactly 12ms?

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

Re: question about velocity

Post by coppelia » 09 Sep 2013, 15:25

Hello,

You are using the Reflexxes motion library to do your movement calculation. With that library you specify the initial position, velocity, the final position, the final velocity, the maximum velocity, the maximum acceleration and the maximum tolerated jerk. In that case, it is impossible to arrive at exactly the time that you want! You cannot specify a time constraint in that case since you specify many other constraints.

What you probably want is a simple position interpolation based on the simulation time? Is that correct?

LatvianStudent

Re: question about velocity

Post by LatvianStudent » 09 Sep 2013, 15:53

I need all the joints to have turned to each of the pre-definied angular positions in exactly 12 ms. So that if I give it a file with lets say 2000 lines the whole motion would take exactly 24 seconds (12 ms * 2000). Is there a way to achieve this? I tried simSetJointPosition, however, without success of synchronization with real-time as well, but maybe I did something wrong - my approach then was to simSetJointPosition for A1...A6 and then use simWait(0.012).

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

Re: question about velocity

Post by coppelia » 09 Sep 2013, 16:32

Have a look at following code:

Code: Select all

if (simGetScriptExecutionCount()==0) then
	jointHandle=simGetObjectAssociatedWithScript(sim_handle_self)
	positions={0,1,4,5,6,0}
	posDt=4.2 -- 0.012 in your case
	startTime=simGetSimulationTime()
end

simHandleChildScript(sim_handle_all_except_explicit)

t=simGetSimulationTime()
progressTime=t-startTime
tableIndex=math.floor(progressTime/posDt)
rest=(progressTime-(tableIndex*posDt))/posDt

if (tableIndex+1<#positions) then
	pos1=positions[tableIndex+1]
	pos2=positions[tableIndex+2]
	interpolatedPos=pos1*(1-rest)+pos2*rest
	simSetJointPosition(jointHandle,interpolatedPos)
end
Your code should run in a non-threaded child script as the one in the example. The example shows the control of one passive joints. In your case you will have to use 6 separate lists for each joint. At the same time, I guess that your robot is dynamic? In that case, instead of using simSetJointPosition, use simSetJointTargetPosition.

Cheers

LatvianStudent

Re: question about velocity

Post by LatvianStudent » 10 Sep 2013, 10:19

Thanks, I'll try it out.

Currently all of the joints are in IK mode, I don't know how to create a robot model with force/torque joints without "breaking physics". Do you have any example robots created with joints in torque/force mode? (I've looked at the dynamics how-to page)

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

Re: question about velocity

Post by coppelia » 10 Sep 2013, 10:27

You will have to set your joints into force/torque mode, and enable the motor and position control. You can do this in the joint properties, and in the joint dynamics properties.

Have a look at the robot Models/robots/non-mobile/KUKA LBR4+.ttm. That one has all its joints in force/torque mode, and has position control enabled for all of them.

Try also to follow a few tutorials, to get an idea of what can be done, that will save you lots of time.

Cheers

LatvianStudent

Re: question about velocity

Post by LatvianStudent » 10 Sep 2013, 14:00

is it possible to visualize motor torques through graphs for each joint which is in torque/force mode?

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

Re: question about velocity

Post by coppelia » 10 Sep 2013, 14:16

yes, you can do that:
  • Add a graph (menu bar --> Add --> Graph)
  • Open the graph properties, and add a new data stream to record. For Data stream type select Joint: force or torque. For Object / items to record, specify the name of your joint. Click Ok.
  • Add a floating view with [right click into view --> Add --> Floating view].
  • Select your graph, and in the floating view do [right click into view --> View --> Associate view with selected graph]
That's it.

Cheers

Post Reply