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

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_2javl0p_2 Member Posts: 37 ✭✭
I'm working inside an Assembly. I have two mates 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.


Answers

  • S1monS1mon Member Posts: 2,243 PRO
    That sounds like a great idea. There are a few improvement requests which are related that you might want to vote on, but you should write up one specifically on measuring the transforms.

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

  • javl0p_2javl0p_2 Member Posts: 37 ✭✭
    Thanks, I created an IR myself expressing this need. Vote it up if you like it!

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

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,005 PRO
    edited March 2023
    I've been working on a transformation featurescript to create 3D trajectories through space and I'm finding the following to be true.

    A 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 Matrix
    In 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 Matrix 
    M1.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.


  • javl0p_2javl0p_2 Member Posts: 37 ✭✭
    Thanks Billy2 for this post. I see your point and I am really looking forward to test that Transformation FeatureScript you are working on! I keep on stumbling on the same problem and don't yet have a solution when trying to get transform matrices between MC.
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,005 PRO
    edited June 2023
    @javl0p_2

    I 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?


  • javl0p_2javl0p_2 Member Posts: 37 ✭✭
    That'd be one powerful use case, definetively!

    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!
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,005 PRO
    I was thinking of mate connectors also to describe a robot's end points. But as you know, MC are relative to the root which isn't robotics. You want to chain MC relative to another MC. Most things in a studio are relative to the root. Sketches go to the root. If you look in FS there's from world to sketch and sketch to world, but there's no from this to that.

    Assemblies 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.


Sign In or Register to comment.