DAS (Design, Analysis and Synthesis) Mechanism Analysis is a fast, robust and scalable kinematic analysis tool for rigid body mechanisms. Capabilities of DASMechanismAnalysis include:
- Design and analyze any single or multiple degree of freedom mechanisms.
- Perform 1,000,000 kinematic analysis operations under 20 seconds.
- Save coupler curves as .png files that can be used for machine learning libraries.
DASOptimization and EJML (Efficient Java Matrix Library) are used in creating this mechanism analysis tool and they are required to be included as libraries in order to run DASMechanismAnalysis Java library.
Kinematic Analysis
First step in creating a mechanism is defining the design work space:
Workspace currentWorkspace = new Workspace( 10, LengthUnit.MILLIMETER, ForceUnit.NEWTON);
Workspace object is only meaningful for user interface and therefore, any arbitrary parameters can be passed when creating this object.
You need to create a list of nodes that define the coordinates of the mechanism links:
double[][] nodeCoordinates = new double[][]{{-30, -10}, {-30, 10}, {15, 25}, {20, -20},{0,30}}; List<Node> nodes = new ArrayList<>(); for (int i = 0; i < nodeCoordinates.length; i++) { nodes.add(new Node(i, nodeCoordinates[i][0], nodeCoordinates[i][1])); } }
when creating a Node object, first parameter is id, second parameter is the x coordinate and the last parameter is the y coordinate.
Next, you need to create a list of Link objects that corresponds to links of the mechanism (you do not need to define ground links):
int[][] connections = new int[][]{{0, 1}, {1, 2}, {2, 3},{1,4}}; List<Link> links = new ArrayList<>(); for (int i = 0; i < connections.length; i++) { links.add(new Link(i, connections[i])); } links.get(1).setGroup(0); links.get(3).setGroup(0);
when you create a Link object, you need to pass an id number and a two element array that defined the node indices of two ends. If you want to rigidly connect two different links (make them move together), you can set their group to the same value.
Final step in designing a mechanism is defining the joint types of the links:
JointType[][] jointList = new JointType[][]{{JointType.GROUNDPIN, JointType.PIN}, {JointType.PIN, JointType.PIN}, {JointType.PIN, JointType.GROUNDPIN}, {JointType.PIN, JointType.PIN}}; for (int i = 0; i < connections.length; i++) { links.get(i).setJoints(jointList[i]); }
when defining the joints, you need to input a two element array that specifies the joint types of the two link ends.
Now we are ready to create a Kinematics object with the Node list, Link list and the work space object as parameters:
Kinematics kinematics = new Kinematics(nodes, links, currentWorkspace);
Before running a kinematic analysis, you need to define inputs to the analysis:
kinematics.addNewInput(0, 0, Math.PI/4.0);
where first input is the index of the link that will be driven, second parameter is the index of the degree of freedom of the link (individual links can have more than one degree of freedom) and the last parameter is the magnitude of the input. Multiple inputs can be added if the mechanism has multiple free degrees of freedom.
Finally, kinematic analysis can be performed on the mechanism with the given inputs:
boolean successful=kinematics.solve();
solve() method will return true if kinematic analysis is successful.
You can print new coordinates of the nodes after the kinematic analysis:
if (successful) { kinematics.getNodes().forEach((node) -> { System.out.println(node.toString() + "x:" + String.valueOf(node.getX()) + "y:" + String.valueOf(node.getY()) + System.lineSeparator()); }); }