Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

**First time visiting? Here are some places to start:**

- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

# How do I get relative Position and Orientation between two mates?

javl0p_2
Member Posts:

**37**✭✭
I'm working inside an Assembly. I have two mates

Mates are basically reference systems, and relative position and orientation between reference systems are typically represented with a

The problem is that a haven't figured out a way in OnShape to get the necessary information to compute relative orientations between mates. I can easily get the translation by selecting both of them and clicking the measure icon and I have found a

Has anyone else encountered this limitation or found a way to sort it out?

I understand this is not a typical design problem, but transformations are used quite often in other industries, such as robotics.

**already**placed, each of thems belongs to a different Part. I would like to know the position and orientation of one mate relative to the other one.Mates are basically reference systems, and relative position and orientation between reference systems are typically represented with a

**4x4 Transformation Matrix**. Other options include a traslation + orientation (which can be defined with**Euler angles**, in**Axis angle**representation or through**quaternions**). Each way of representing relative orientations has its pros and cons but for me they would be equally valid.The problem is that a haven't figured out a way in OnShape to get the necessary information to compute relative orientations between mates. I can easily get the translation by selecting both of them and clicking the measure icon and I have found a

*Multi Mate Connector FS*that could potentially help me, but since I'm inside an Assembly I can not rely on that either.Has anyone else encountered this limitation or found a way to sort it out?

I understand this is not a typical design problem, but transformations are used quite often in other industries, such as robotics.

0

## Answers

2,243PROhttps://forum.onshape.com/discussion/19018/measure-mate-connector-orientation

https://forum.onshape.com/discussion/11293/measure-between-mate-connectors-in-mate-connector-frame

37✭✭https://forum.onshape.com/discussion/20536

2,005PROA mate connector doesn't map to a transformation, you need 2 transforms.

If you don't use the bottom rotation, then you can get away with 1 matrix transform. I don't think these matrices are part of a mate connector and you'll have to build them. You could just perform the last rotation using trig but I wouldn't. It seems like a waste to construct a matrix to perform a simple rotation, but in the end, linear algebra is just accounting so you want to keep things in the same 4x4 form.

1 MatrixIn cad everything goes through the origin.

M1 is the transformation from the origin to mate connector 1.

M2 is the transformation from the origin to mate connector 2.

So your transformation actually looks like this:M1 -> origin -> M2.

M1 -> to the origin is the inverse matrix of origin -> M1. Onshape calls these "sketch to origin" or "origin to sketch". So the 1st step is to go from the mate connector to the origin which is the inverse of the definition when placing the mate connector.

Using value with units and M1 & M2 are matrices.

M1^-1 * M2 = would equal the matrix you're looking for when not using the bottom rotation in the mate connector dialog.

Figuring out the translation between 2 mate connectors is easy: M2-M1. There's only 2 vectors involved. I doubt if you could subtract the 2 mate connectors, but instead, pull the vectors from the M1 & M2 and perform the math on them.

I don't know if values with units handles matrices, I believe it does and I'm sure how to call a matrix inversion inv(M1)?

2 MatrixM1.1^1*M1.2^*M2.1*M2.2 there's 4 transformations when using 2 mate connectors. If you're at a mate connector and want to get back to the origin, you have to use the inverse matrix.

So with the transformation feature script I'm writing, I create 6 transformations that will go from the origin to a robot's end effector. If you're at the end effector and want to go back to the origin, you just invert all the matrices and go back to the origin. If you want to know where the end effector is located, you just multiply the transformation stack and you'll end up with a matrix that describes the end effectors location & orientation from the origin.

If you want a skeleton of a robot without using a million sketches, you'll want to use a transformation featurescript to define a robot's structure.

I've been trying to justify why we need a transformation featurescript, thanks for posting this.

37✭✭2,005PROI forgot I wrote this post but I've been thinking about it alot. For me I wanted to create a layout for a scara robot so as the design evolves, you can control it.

Using stickman sketches and surfaces, it's just goofy trying to represent a robot.

I was thinking a feature that'll allows you to translate up, rotate Z, rotate Y1, translate X1 .... something that would allow you to traverse a robot's arm. I'd create all the associated planes along the journey so you can reference them when building joints.

One feature creating all the references for a robot's arm.

If you create a robot, you need fundamental references defining it. If you don't, in 6 months you can't make predictable changes.

Is this what you're thinking?

37✭✭Instead of creating the planes or necessary sketches, I would create the key MateConnectors, representing the key reference frames of my robot. That should give me the basis for everything else. Then I could easily modify the robot's kinematics by editing the relative positions between MC.

Other useful use case could be the opposite. I create two MC from some reference geometry and the FS would give me the transform matrix between them.

Let me know if you have any progress on such FS, I would be very interested!

2,005PROAssemblies stack the transformations up. 3 levels deep in assemblies means you have to transform through the stack to know where you are located from the root. This is more akin to a robot.

You're trying to stack MC and so am I. I probably won't use MC and run the transformations myself. I was thinking of using MC as a visual to display where you are in space, but, constructing red, green, blue construction planes would do the same thing.

It helps to talk about this, thanks. I think we're wanting the same thing. I'm still scratching my head trying to figure this out.