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.
i was reading up on poses and features today. Check out c) Express a point w.r.t a feature
The Math should be the same i think
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
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:
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:
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.