# Error in simmechanics matlab while doing inverse dynamics using custom joint

I am doing inverse dynamics in Matlab simmechanics in which position and orientation will be input to the end effector. But it shows error as below.

Error originates in Mechanical block rob33/Subsystem2/Subsystem1/Custom Joint. The coordinate systems attached to this joint must lie on the prismatic axis (for 1 axis) or in the plane of the prismatic axes (for 2 axes). If joint has no prismatic axes, the attached coordinate systems must be collocated, within tolerances.

Model is given below.

In subsystem1, I used custom joint to give orientaion input. Susystem1 model and custom joint block parameters is given below figure.

Parameters of link1-1 and parallel constaints is given in below figure.

How do I correct this error?

I solved this problem by seeing below image from internet. This image explain the constraints in coordinate system in simulink.

R = revolute ; S = spherical; W = weld; P = prisimatic

As I have custom joint (in between ground and link 1-1) with R1R2R3 joints so body1 CS and body2 CS should coincident.

To do this, I copy CS3 of link1-1 and paste it into CS of ground.

SimMechanics isn't an "inverse dynamics" engine, it's not an inverse kinematics engine, it's a "forward dynamics" or just "dynamics" engine. You provide link dimensions, inertias, and joint constraints. Then you provide either an applied force or an applied motion, SimMechanics propagates those forces (or equivalent forces, in the even of applied motions) through your model, and you get an output that shows what your system does in the presence of those forces.

I don't know what you think your Subsystem1 is supposed to be doing, but it's not doing it. Here is what is actually happening:

1. Each joint or link has an input location ("Base") and an output locations ("Follower"). Links have inertias and fixed transforms between base and follower, joints have no inertias and obviously have variable transforms between base and follower.
2. Each system has one and only one ground. This provides your zero-reference.
3. So, reading your first diagram from left to right, you have a "Root Ground", a welded base, then you start building your robot with joint, link, joint, link, etc.
4. Eventually you get to "Link 4-1", which I'm assuming is supposed to be an end effector.
5. Here's where you get into trouble - you tie some coordinate frame from the end effector to "Subsystem1" by attaching it to the follower (output) of a pair of parallel constraints.
6. Those parallel constraints are attached to the follower of a link, which is the follower of a custom joint, which is attached to ground!

You have made a closed loop, starting and ending at a ground connection.

The problem with this is that SimMechanics seems to be especially terrible at solving for initial conditions. If your starting/default orientation for the revolute joints and those linkages doesn't result in an end effector pose that exactly matches the starting/default orientation for the custom joint and the subsystem1 link, then you get this error because the difference in pose matching results in a separated joint somewhere - typically where you tie back to ground. This is in Subsystem, where the ground connection attaches to custom joint 1, which is where you're getting the error.

It looks like maybe you're trying to do inverse kinematics by creating a "puppet" - you provide a position and an orientation and rely on the SimMechanics solver to find the joint angles that allow the arm to reach that pose. Again, the problem here is if you start with a set of initial conditions where your initial input pose doesn't correspond to your initial robot pose.

You could also get this error if you use your input pose to drive the arm to an unreachable subspace. At that point, the arm "locks up," the input continues to move, and in one time step a joint separates somewhere and you hit a "not coincident" error like this again.

My suggestion would be to check the default orientation of the arm by commenting out the input subsystem1 code (highlight, right click, and choose "comment out). Then uncomment the input, comment out the robot arm (except the end effector, of course), and see if the end effector is in the same position. If it's not, there's your problem. Adjust your default input/robot joint angles as required to get the two to mesh.

• Thanks @Chuck for reply. I want to mention here that I wrote above inverse kinematics because I'm interested in joint's torque. I know that it is closed loop so in machine environment I choose analysis mode as "kinematics". I am referring below paper to do this. intechopen.com/books/… As you suggest me I comment out subsystem1 but it show error .....please look 2nd comment............ Mar 30, 2017 at 12:37
• ........from previous comment.......Mechanical model motion is not completely specified when running in kinematics mode. To be legal in kinematics mode, all independent degrees of freedom must be kinematically actuated. Check joints, constraints, drivers, actuators, and DoFs. CAn you suggest me how to get joints torque by giving x,y,z and orientation input same as I tried above. Thanks Mar 30, 2017 at 12:38