# Shifting the joint position based on cartesian translation

**URL:** <https://forum.universal-robots.com/t/shifting-the-joint-position-based-on-cartesian-translation/37032>\
**Category:** URScript\
**Created:** [November 17, 2024, 5:25pm UTC](https://forum.universal-robots.com/t/shifting-the-joint-position-based-on-cartesian-translation/37032 "2024-11-17T17:25:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danaiaiai](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@danaiaiai](https://forum.universal-robots.com/u/danaiaiai)\
**Post date:** [November 17, 2024, 5:25pm UTC](https://forum.universal-robots.com/t/shifting-the-joint-position-based-on-cartesian-translation/37032/1 "2024-11-17T17:25:59Z")

</div>

I am using python to run the ur3. I have a series of poses stored in a database. Each pose contains the output of getj() and getl().

I have a case where I need to get the joint positions of a pose translated 10mm in the z-axis.

Is there a way that I can use the IK solver to provide the new joint data for use in the python script?

---

<div class="post-metadata">

**Author:** ![robin\_gdwl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/robin_gdwl/32/2676_2.png) [@robin\_gdwl](https://forum.universal-robots.com/u/robin_gdwl)\
**Post date:** [November 17, 2024, 11:04pm UTC](https://forum.universal-robots.com/t/shifting-the-joint-position-based-on-cartesian-translation/37032/2 "2024-11-17T23:04:10Z")

</div>

yes

the cartesian coordinate of a joint pose is calculated with forward kinematics. Make sure you use the right TCP.

`cartesian = get_forward_kin(jointpose) `

offsetting the pose in z could be done with pose\_add if its in base coordinates.  
`c_offset = pose_add(cartesian, p[0, 0, 0.01, 0, 0, 0])`

you can get the joint pose again by doing inverse kinematics.  
Use the original jointpose as “q\_near”

`offset_joints = get_inverse_kin(c_offset, jointpose) `

you can then move to the new jointpose.

`moveJ(offset_joints) `

So the full URScript would be:

```python
cartesian = get_forward_kin(jointpose) 
c_offset = pose_add(cartesian, p[0, 0, 0.01, 0, 0, 0])
offset_joints = get_inverse_kin(c_offset, jointpose) 
movej(offset_joints) 

```

---

<div class="post-metadata">

**Author:** ![danaiaiai](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@danaiaiai](https://forum.universal-robots.com/u/danaiaiai)\
**Post date:** [November 27, 2024, 8:46pm UTC](https://forum.universal-robots.com/t/shifting-the-joint-position-based-on-cartesian-translation/37032/3 "2024-11-27T20:46:04Z")

</div>

Thanks!

I will give this a try, but what I have working, I think, for now is simply adding 10mm to the z coord from getl() and passing these coords to movej().

It seems to be working, but I have yet to test it’s accuracy.

```auto

pose = getl()
pose[2] += 0.001 * zo
bot.send_program(f"movej(p({pose[0]},{pose[1]},{pose[2]}, a=.5, v=.5, r=0)")

```
