1

Lets say I've a robotic arm with joints at points A,B,C,D in a 3D space. Let D be the end effector(bottommost child) and A be the topmost parent. Let T be the target point anywhere in the space. The aim is to make the end effector reach the target with minimum rotations in top levels(parents).

What I initially thought:

1) Rotate the arm C by angle TCD. 2) Then rotate the arm B by new angle TBD. 3) Then rotate the arm A by new angle TAD.

But the end effector seems to point away from the target after step 2. What am I doing wrong and how can I fix it?

cegprakash
  • 2,937
  • 33
  • 60
  • 1
    Do you calculate the actual angle? Or the angle in the arm's movement plane? The latter would be the correct approach. – Nico Schertler Jun 07 '14 at 08:08
  • 1) Rotate arm C by angle TCD in axis TC X CD. 2) rotate arm B by TBD in the axis TBxBD and so on.. But this logic will not result in moving the end effector towards the Target. Because the vector CD will move away when the arm B is rotated :( – cegprakash Jun 07 '14 at 09:36
  • Can you rotate the arm in any direction? Moving farther away from the target may happen, because CCD is a rather simple approach. Does the angle TBD decrease to zero? CCD is usually applied iteratively. – Nico Schertler Jun 07 '14 at 10:25
  • I can handle the rotation limits. For now, you can assume that the arm can be rotated in any direction. TBD can become zero if it's needed. I just can't get the iterative/recursive logic. – cegprakash Jun 07 '14 at 10:45
  • @NicoSchertler Now I feel like the method I mentioned will work like a charm. All I have to do is to repeat these 3 steps for some iterations to move as much as close to the Target. Am I right? – cegprakash Jun 12 '14 at 12:14
  • 1
    That's the basic idea. – Nico Schertler Jun 12 '14 at 12:30
  • I wish I could take back the bounty. But I can't :| – cegprakash Jun 16 '14 at 17:35
  • You don't have to award the bounty if there is no satisfactory answer. At least as long as there is no answer with at least 2 up-votes. However, there is no way to get your reputation back. See [the help center](http://stackoverflow.com/help/bounty) for more details. – Nico Schertler Jun 16 '14 at 17:57
  • I didn't want it to get wasted. Awarded it to a newbie :) – cegprakash Jun 20 '14 at 12:27

2 Answers2

1

Before I started use some more advanced approaches I did it like this (using simple CCD cyclic coordinate descent):

pe=desired_new_position;

for (i=0;i<number_of_actuators;i++)
 {
 // choose better direction
                   p=direct_kinematics(); d =|p-pe|; // actual step
 actuator(i)--;  p=direct_kinematics(); d0=|p-pe|; // previous step
 actuator(i)+=2; p=direct_kinematics(); d1=|p-pe|; // next step
 actuator(i)--;  dir=0; d0=d;
      if ((d0<d)&&(d0<d1)) dir=-1;
 else if ((d1<d)&&(d1<d0)) dir=+1;
 else continue;

 for (;;)
  {
  actuator(i)+=dir; p=direct_kinematics(); d =|p-pe|;
  if (d>d0) { actuator(i)-=dir; break; }
  if (actuator(i) on the edge limit) break;
  }

 }

[notes]

  1. you can modify it to inc/dec actuator position by some step instead of 1

    stop if difference crossed zero then start again with smaller step until step == 1 This will improve performance but for most application is step=1 enough because new position is usually near the last one.

  2. beware that this can get stuck in local min/max

    if the output get stuck (effector position is unchanged) then randomize the actuators and try again. Occurrence of this depend on the kinematics complexity and on the kind of path you want to use

  3. if the arms are driven more on the top then on the bottom

    then try reverse the i-for loop

  4. if you have to control the effector normal

    then you have to exclude its rotation axises from CCD and set it before CCD

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • what is direct_kinematics() and what is actuator(i)-- – cegprakash Jun 11 '14 at 07:23
  • @cegprakash actuator is the motor position that drives each arm (there can be more then one per joint !!!) and direct kinematics is function that compute position of your effector from all actuators – Spektre Jun 11 '14 at 09:28
  • Actually there is no motor to drive the arms in my model. The arms cannot change it's length. They can only rotate. You can assume the robotic arm similar to our human hand. – cegprakash Jun 11 '14 at 09:57
  • @cegprakash rotation is also movement .. hence one motor per each degree of freedom of your joints :) ... human joints are simplificated as 2 degree of freedom (ignoring the variable offset and twists) so 2 motors (2 angles) per joint – Spektre Jun 11 '14 at 11:35
  • Can you explain your algorithm a bit more and what happens step by step if I have a robotic arm with joints at points A,B,C,D and a target point T? The terms you use are tricky for me. – cegprakash Jun 11 '14 at 12:31
  • and what do you mean by actuator(i)+=2 o.O – cegprakash Jun 11 '14 at 13:04
  • @cegprakash(i)++/-- means step left or step right; -=2 mean 2 times step left. algorithm goes through all motors (first for) then compute difference of effector from wanted position when step in both direction (d0,d1) and compare it to actual difference (d) then find the minimal difference in the better direction (second for). This is all ... the whole thing can be called more times to increase accuracy ... – Spektre Jun 11 '14 at 17:59
0

It's hard to directly code this, but you may solve this problem in a view of optimization (and many state-of-art method can be implied to solve this, which can be easily found on the Internet). Let x' and y' be the fixed topmost A, and x'' and y'' be the target. Then this problem can be formalized as the follows,

enter image description here

where gamma_i is the weight of rotation of each joint (you may simply let gamma_i=1), and alpha_i is the rotation value. Your optimization goal is to get the minimum rotation of the parents, subject to some constraints. x', y', x'', y'' are constants, the other are variables. Other inequality can be added to limit the angle of rotation.

Equation f(x',y',x_1,y_1,alpha_1)=0 means, with the rotation of A by alpha_1, point B can be relocated to x_1, y_1. If you can specify the detail of rotation (for example is f is linear, then simplex method can be implemented, but it seems that f is quadratic).

Sorry for my poor English, and wish this can help :p

zhaodaolimeng
  • 626
  • 8
  • 11
  • Your English is not poor. There should be easier ways like the one I mentioned to solve this problem than solving quadratic equations. – cegprakash Jun 12 '14 at 12:09
  • @cegprakash those are derivations (system of differential equations) not quadratic equations !!! If you would try to solve that you will get stuck on transcendent problems ... numeric solution is the only way (in most cases) ... sometimes direct algebraic solution can be found by inversing transformation matrix but that is not CCD and usually also get stuck with transcendent system of equations – Spektre Jun 16 '14 at 12:14
  • Solved using vector algebra easily. I badly had to award bounty to one of the two existing answers and so I chose yours'. – cegprakash Jun 16 '14 at 17:39