# Generating an ikfast solution for 4 DOF arm

Hi,

I'm trying to make a 4DOF ikfast plugin. ROS version: Kinetic Ubuntu: Xenial

I'm following these instructions: http://wiki.ros.org/Industrial/Tutori...

the first problem I run into is that I can't install the openrave package

```
sudo apt update
Ign:3 http://ppa.launchpad.net/openrave/release/ubuntu xenial InRelease
Err:4 http://ppa.launchpad.net/openrave/release/ubuntu xenial Release
404 Not Found
```

and of course:

```
parallels@ubuntu:~/matilda-ikfast$ sudo apt install openrave0.8-dp-ikfast
[sudo] password for parallels:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package openrave0.8-dp-ikfast
E: Couldn't find any package by glob 'openrave0.8-dp-ikfast'
E: Couldn't find any package by regex 'openrave0.8-dp-ikfast'
```

So I installed from source, following these instructions http://fsuarez6.github.io/blog/workst...

With as result openrave 0.9 (the tags on de github account van 0.8.0 en 0.8.2 gave compilation errors.)

Then I succesfully made a collada file (openrave matilda.dae shows my robot)

```
parallels@ubuntu:~/matilda-ikfast$ openrave-robot.py matilda.dae --info links
name index parents
-------------------------
base 0
base_link 1 base
link_1 2 base_link
link_2 3 link_1
link_3 4 link_2
link_4 5 link_3
tool0 6 link_4
-------------------------
name index parents
```

While I try to make the cpp file I get a sympy matrices.matrices.ShapeError:

```
parallels@ubuntu:~/matilda-ikfast$ python ../openrave/python/ikfast.py --robot=matilda.dae --iktype=translationyaxisangle4d --baselink=0 --eelink=6 --savefile=output_ikfast61.cpp
...
...
INFO: trying to guess variable from [j0]
INFO: have only one variable left j0 and most likely it is not in equations [-pz*sin(j1) + cos(j1)/20 + 11029*cos(j2)/20000, pz*cos(j1) + sin(j1)/20 + 11029*sin(j2)/20000 + 123/200, sin(j1)*sin(j2)*cos(j3) - sin(j1)*sin(j3)*cos(j2) + sin(j2)*sin(j3)*cos(j1) + cos(j1)*cos(j2)*cos(j3) - cos(r00), -pz**2 - 123*pz*cos(j1)/100 - 123*sin(j1)/2000 - 30651159/400000000, -pz*sin(j1)*sin(j2) - pz*cos(j1)*cos(j2) - sin(j1)*cos(j2)/20 + sin(j2)*cos(j1)/20 - 123*cos(j2)/200, -pz*sin(j1)*cos(j2) + pz*sin(j2)*cos(j1) + sin(j1)*sin(j2)/20 + 123*sin(j2)/200 + cos(j1)*cos(j2)/20 + 11029/20000]
INFO: depth=0, c=2, iter=0/1, adding newcases: set([Abs(px) + Abs(py)])
Traceback (most recent call last):
File "../openrave/python/ikfast.py", line 9548, in <module>
chaintree = solver.generateIkSolver(options.baselink,options.eelink,options.freeindices,solvefn=solvefn)
File "../openrave/python/ikfast.py", line 2297, in generateIkSolver
chaintree.leftmultiply(Tleft=self.multiplyMatrix(LinksLeft), Tleftinv=self.multiplyMatrix(LinksLeftInv[::-1]))
File "../openrave/python/ikfast.py", line 1122, in leftmultiply
self.Pfk = Tleft[0:2,0:2]*self.Pfk+Tleft[0:2,3]
File "/home/parallels/.local/lib/python2.7/site-packages/sympy/matrices/matrices.py", line 404, in __mul__
return matrix_multiply(self,a)
File "/home/parallels/.local/lib/python2.7/site-packages/sympy/matrices/matrices.py", line 2458, in matrix_multiply
raise ShapeError()
sympy.matrices.matrices.ShapeError
```

Any ...

After Hydro, I've never bothered installing OpenRAVE - using binaries or from sources. I've always just used docker/personalrobotics/ros-openrave.

Also: see #q196753 for a question about 5dofs, but the same approach should work for 4dofs. I'm not sure that will solve / work around the issue that you are seeing, but it's worth a try.

Finally: probably not something you want to hear, but unfortunately we're only users of OpenRAVE/IKFast just as you. If something is really broken / not working as it should, rdiankov/openrave/issues would be the place to report it.

I've tried the linked docker image, where I get other kinds of errors (matrices size mismatch etc, but not the error above). I followed your links re. 5DOF's too. This looks like it's going to be a non-trivial exercise with limited chance of success...

...Going to look into manually coding the IK. Thanks for the links and looking into my problem

It's actually about the same amount of work as the regular procedure to generate an IK plugin. The

`.dae`

you need to make anyway, and then only the small additional wrapper is needed. After that copy-paste the command line I already gave as an example in #q196753.I'm probably a little biased, but it shouldn't be too much work actually.

Ok, i get held back by the links to the openrave mailing list and my experience with my non-standard kinematics. I'll try the wrapper approach.

Don't spend too much time on it: I can't guarantee that it'll actually work. I just wanted to clarify that it shouldn't be too different from the 'regular' approach wrt the amount of work.

I just spent some time on this, and after fiddling a little with the

`personalrobotics`

Docker image and writing a very minimal OpenRAVE wrapper xml file I got it to generate a`translationyaxisangle4d`

cpp. I haven't tested it yet, will do that later today.