# Get Points Relative To Feature Frame

**URL:** <https://forum.universal-robots.com/t/get-points-relative-to-feature-frame/17421>\
**Category:** URCaps SDK\
**Created:** [November 4, 2021, 9:56am UTC](https://forum.universal-robots.com/t/get-points-relative-to-feature-frame/17421 "2021-11-04T09:56:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon53438463](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@anon53438463](https://forum.universal-robots.com/u/anon53438463)\
**Post date:** [November 4, 2021, 9:56am UTC](https://forum.universal-robots.com/t/get-points-relative-to-feature-frame/17421/1 "2021-11-04T09:56:59Z")

</div>

Hi,

I wanted to know if it is possible to get pose values relative to a feature frame using the URCaps SDK. Ideally I’d like to store these points relative to the feature in the data model.

Please let me know if any further information is required.

Thanks!

---

<div class="post-metadata">

**Author:** ![anon90247165](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@anon90247165](https://forum.universal-robots.com/u/anon90247165)\
**Post date:** [November 4, 2021, 3:00pm UTC](https://forum.universal-robots.com/t/get-points-relative-to-feature-frame/17421/2 "2021-11-04T15:00:38Z")

</div>

Hi,

i was reading up on poses and features today. Check out c) Express a point w.r.t a feature

[https://www.universal-robots.com/articles/ur/programming/urscript-move-with-respect-to-a-custom-featureframe/](https://www.universal-robots.com/articles/ur/programming/urscript-move-with-respect-to-a-custom-featureframe/)

The Math should be the same i think

---

<div class="post-metadata">

**Author:** ![anon53438463](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@anon53438463](https://forum.universal-robots.com/u/anon53438463)\
**Post date:** [November 5, 2021, 6:41pm UTC](https://forum.universal-robots.com/t/get-points-relative-to-feature-frame/17421/3 "2021-11-05T18:41:32Z")

</div>

Hi,

Thanks, that’s what I was doing originally, just wanted to know if there was a way to do it via the URCaps SDK directly

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [November 5, 2021, 7:08pm UTC](https://forum.universal-robots.com/t/get-points-relative-to-feature-frame/17421/4 "2021-11-05T19:08:21Z")

</div>

The “easy” way to do this is to cheat and just let UR Script do the transforms for you.

First, this is just a useful tip for ANY future CAP developing you do, you can view the Script generated by Polyscope by saving the file, then clicking the “Script” command. Switch it from Line to File and then open the job you just saved.

So, to see exactly what script you need your CAP to ultimately write, we can just add a simple MoveJ node in Polyscope, set it to reference a feature, save the file, open it as a script, and you will see something like the following:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/4/404b7b8334aa7c0183ef77fc805844e3dd96f693.png)

Once you have this, you just need to identify which pieces of the script need to be pulled from your dataModel. The important pieces here are, in my case, “Plane\_1” which is the feature it was taught to, the original Feature pose p[blah blah blah], and Waypoint\_1\_p (You’ll notice a “qnear” parameter as well, which you would need if you intend this to be a JointPositions as opposed to a Pose. If you had used a MoveL to generate this code, you wouldn’t see the qnear parameter).

So in your generateScript, you’d just do something like writer.appendLine(“get\_inverse\_kin(pose\_trans(” + model.get(stored\_activefeature, default\_feature) + “, pose\_trans(” + model.get(stored\_originalFeatureAsPose, default\_pose) + ", " + model.get(stored\_target\_pose, default\_pose))

(I’m sure I botched some quotes or commas in there but hopefully you get the idea.)

Now, that’s all great if you just need to execute that line in script. However, if you want to be able to, say Move To that position from Java, you need that whole result to be ACCESSIBLE from Java. I will leave you this link:

> [@URCap Sample: URCap-ScriptCommunicator](https://forum.universal-robots.com/t/urcap-sample-urcap-scriptcommunicator/8460):
>
> Dear community, I have forked Jacobs URCap-ScriptCommunicator and added the framework to proxy URScript functions from Java. So far it is only a subset of the functions that are implemented yet. I hope you will add the functions when you need is there and then share it with the rest of the community! Description of functionality: This sample implements a Java class to: Send URScript commands for immediate execution by URControl Extract a variable from URScript to Java Proxy URScript functio…

Which includes some incredibly helpful functions for executing URScript from Java without needing to run the program. This enables you to send a URScript command, and return the result back into Java. Essentially, you can write a function, pass it the dataModel’s active feature, the dataModel’s original feature, and the dataModel’s target\_pose, and send just the get\_inverse\_kin([all the rest of the stuff inside this function]) script to the robot. It will return a String back into Java, which is the exact Pose that it needs to move to a point relative to a feature.

You will need to parse the string (to remove the “p[” and “]” characters) into an array, and then use the poseFactory to construct a Pose type variable. (myProgramAPI.getValueFactoryProvider().getPoseFactory().createPose())

If you do all this, you will now have a variable of type Pose that you can feed into robotMovement Callbacks to jog the robot correctly, all from Java!

It’s definitely still a lot of work, but being able to send/receive URScript over sockets like this can be very useful in other applications as well, so it’s a good tool to add to your belt.
