# Get\_inverse\_kin "close to qnear"

**URL:** <https://forum.universal-robots.com/t/get-inverse-kin-close-to-qnear/4765>\
**Category:** URScript\
**Created:** [July 19, 2019, 8:41am UTC](https://forum.universal-robots.com/t/get-inverse-kin-close-to-qnear/4765 "2019-07-19T08:41:35Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![anon77491662](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@anon77491662](https://forum.universal-robots.com/u/anon77491662)\
**Post date:** [July 31, 2020, 12:54pm UTC](https://forum.universal-robots.com/t/get-inverse-kin-close-to-qnear/4765/7 "2020-07-31T12:54:00Z")

</div>

Hello,  
I’m not 100% sure that my issue is related to this topic, but it seems like it to me.

I’m currently struggling to understand how get\_inverse\_kin and qnear work.  
in a script I’ve got this:  
textmsg("Drop\_Pre\_Pt1: ",Drop\_Pre\_Pt1)   
Drop\_Pre\_Pt1J=get\_inverse\_kin(pose\_trans(Uframe,Drop\_Pre\_Pt1))  
textmsg("Drop\_Pre\_Pt1J[0]: ",r2d(Drop\_Pre\_Pt1J[0]))  
textmsg("Drop\_Pre\_Pt1J[1]: ",r2d(Drop\_Pre\_Pt1J[1]))  
textmsg("Drop\_Pre\_Pt1J[2]: ",r2d(Drop\_Pre\_Pt1J[2]))  
textmsg("Drop\_Pre\_Pt1J[3]: ",r2d(Drop\_Pre\_Pt1J[3]))  
textmsg("Drop\_Pre\_Pt1J[4]: ",r2d(Drop\_Pre\_Pt1J[4]))  
textmsg("Drop\_Pre\_Pt1J[5]: ",r2d(Drop\_Pre\_Pt1J[5]))  
textmsg("Drop\_Pre\_Pt1J: ",Drop\_Pre\_Pt1J)  
Drop\_Pre\_Pt1J=get\_inverse\_kin(pose\_trans(Uframe,Drop\_Pre\_Pt1),[d2r(-100),d2r(-80),d2r(-120),d2r(-70),d2r(90),d2r(-90)])  
textmsg("Drop\_Pre\_Pt1J[0]: ",r2d(Drop\_Pre\_Pt1J[0]))  
textmsg("Drop\_Pre\_Pt1J[1]: ",r2d(Drop\_Pre\_Pt1J[1]))  
textmsg("Drop\_Pre\_Pt1J[2]: ",r2d(Drop\_Pre\_Pt1J[2]))  
textmsg("Drop\_Pre\_Pt1J[3]: ",r2d(Drop\_Pre\_Pt1J[3]))  
textmsg("Drop\_Pre\_Pt1J[4]: ",r2d(Drop\_Pre\_Pt1J[4]))  
textmsg("Drop\_Pre\_Pt1J[5]: ",r2d(Drop\_Pre\_Pt1J[5]))  
textmsg("Drop\_Pre\_Pt1J: ",Drop\_Pre\_Pt1J)

Drop\_Pre\_Pt1 is calculated and relative to Uframe.  
I log inverse kinematic because time to time I’ve got some “weird” axes configuration, which led to collision.

On the last collision the log return this:  
Drop\_Pre\_Pt1: p[0.308678,0.0377616,0.3,2.16857,2.273,-9.39359e-05]

#get\_inverse\_kin solution with **no** qnear parameter  
Drop\_Pre\_Pt1J[0]: 25.3461  
Drop\_Pre\_Pt1J[1]: 13.3889  
Drop\_Pre\_Pt1J[2]: -99.7442  
Drop\_Pre\_Pt1J[3]: -184.133  
Drop\_Pre\_Pt1J[4]: 90.5411  
Drop\_Pre\_Pt1J[5]: 23.6616  
Drop\_Pre\_Pt1J: [0.442372,0.233681,-1.74087,-3.21372,1.58024,0.412974]

#get\_inverse\_kin solution with qnear parameter  
Drop\_Pre\_Pt1J[0]: 25.3461  
Drop\_Pre\_Pt1J[1]: 13.3889  
Drop\_Pre\_Pt1J[2]: -99.7442  
Drop\_Pre\_Pt1J[3]: -184.133  
Drop\_Pre\_Pt1J[4]: 90.5411  
Drop\_Pre\_Pt1J[5]: 23.6616  
Drop\_Pre\_Pt1J: [0.442372,0.233681,-1.74087,-3.21372,1.58024,0.412974]

How come get\_inverse\_kin with qnear gives such results?  
Drop\_Pre\_Pt1J[0]: **25.3461** qnear[0]=d2r( **-100** ) -\> more than 90° difference  
Drop\_Pre\_Pt1J[1]: **13.3889** qnear[1]=d2r( **-80** ) -\> more than 90° difference  
Drop\_Pre\_Pt1J[2]: **-99.7442** qnear[2]=d2r( **-120** ) -\> acceptable  
Drop\_Pre\_Pt1J[3]: **-184.133** qnear[3]=d2r( **-70** ) -\> more than 90° difference  
Drop\_Pre\_Pt1J[4]: **90.5411** qnear[4]=d2r( **90** ) -\> fine  
Drop\_Pre\_Pt1J[5]: **23.6616** qnear[5]d2r( **-90** ) -\> more than 90° difference

Especially when a solution exist with the following axes angle really close to qnear.  
Drop\_Pre\_Pt1J[0]: -117.25  
Drop\_Pre\_Pt1J[1]: -75.15  
Drop\_Pre\_Pt1J[2]: -121.52  
Drop\_Pre\_Pt1J[3]: -73.19  
Drop\_Pre\_Pt1J[4]: 89.15  
Drop\_Pre\_Pt1J[5]: -119.1

Something doesn’t seem to work properly or I’m miss something?

---

_[View the full topic](https://forum.universal-robots.com/t/get-inverse-kin-close-to-qnear/4765)._
