Cuts ---- .. container:: c-code .. highlight:: c A cut is used to deal with system containing kinematic loops: the loop is cut to recover a tree-like structure. When inserting a cut in the system, the corresponding algebraic constraint equation and their Jacobian matrix will be generated. Three kinds of cuts are implemented in Robotran: - The rod cut -> it imposes a constant length between two points of the system -> 1 algebraic constraint. - The ball cut -> it imposes that the two connected points are merged -> 3 algebraic constraints. - The solid cut -> it imposes that two bodies are coincident -> 6 algebraic constraints. The rod cut ~~~~~~~~~~~ The rod cut applies to kinematic loops wich contains a connecting rod. .. figure:: figure/cut_potatoes_rod.png :alt: When including a rod cut, a constant distance between the points P and Q is imposed. Illustration of the rod cut concept using a potato multibody diagram - The rod cut imposes one algebraic constraint: the distance between the two connecting point must remain constant and equal to a given value. - In practice, for computation efficiency, the closure condition is writtent using the square of the length:\ :math:`\begin{equation} \begin{split}h(q,t) &\triangleq \frac{1}{2} \parallel x^{PQ}(q,t)\parallel^2 - \frac{l^2}{2} \\ &= \frac{1}{2} x^{PQ}(q,t) \cdot x^{PQ}(q,t) - \frac{l^2}{2}\\ &= 0 \\ \end{split} \end{equation}`\ .. WARNING: The length of the rod specified in MBsysPad can not be null. The ball cut ~~~~~~~~~~~~ The ball cut applies to kinematic loops which contains a ball joint. .. figure:: figure/cut_potatoes_ball.png :alt: When including a ball cut, a coincident position of the points P and Q is imposed. Illustration of the ball cut concept using a potato multibody diagram - The ball joint can be considered as “ideal”: - From geometrical point of view (no backlash); - From dynamic point of view (no torque transmitted). - The ball cut equivalent imposes three position constraints: the position vectors of the two connecting point must coincide at any time: \ :math:`h(q,t) \triangleq x^Q(q,t) - x^P(q,t) = 0`\ - The ball cut imposes: - 3 algebraic constraints for a 3D system; - 2 algebraic constraints for a 2D system (the third one will be automatically removed). .. REMARK: In MBsysPad, it is possible to manually removed one algebraic in one direction. The solid cut ~~~~~~~~~~~~~ The solid cut imposes that two bodies must coincide. .. figure:: figure/cut_potatoes_solid.png :alt: When including a solid cut, a coincident position and rotation of two bodies is imposed. Illustration of the solid cut concept using a potato multibody diagram - The solid cut imposes 6 algebraic constraints: - 3 position constraints imposing that the two bodies have a common point; - 3 orientation constraints expressing that the frames of each body must coincide at any time. Coordinate partitioning ~~~~~~~~~~~~~~~~~~~~~~~ The goal of the coordinate partitioning is to reduce the set of differential-algebraic equations to a set of ordinary differential equations. Stating point: DAEs \ :math:`\boxed{\begin{matrix} M(q)\ddot{q} + c(q, \dot{q}, frc, trq, g) = Q(q, \dot{q}) + J^T\lambda \\ h(q) = 0 \end{matrix}}`\ The joint variables are split into 2 groups: - The independent variable u - The dependent variable v \ :math:`\begin{equation} \boxed{q = \begin{pmatrix}u \\ v \end{pmatrix} ; J = \begin{pmatrix}J_{u} & J_{v} \end{pmatrix}} \end{equation}`\ - and the differential equations can be separated accordingly \ :math:`\begin{equation} \begin{pmatrix} M_{uu} & M_{uv} \\ M_{vu} & M_{vv} \end{pmatrix} \begin{pmatrix}\ddot{u} \\ \ddot{v} \end{pmatrix} + \begin{pmatrix} c_{u} \\ c_{v} \end{pmatrix} = \begin{pmatrix} Q_{u} \\ Q_{v} \end{pmatrix} +\begin{pmatrix}J_{u}^T \\ J_{v}^T \end{pmatrix} \lambda \end{equation}`\ The dependent variables are eliminated from the differential equation by solving the constraint equations at each time step. Solving the constraint equations imply a newton-raphson procedure. It results in a set of ODEs in terms of the independent variables. At the end: ODEs \ :math:`\boxed{\mathcal{M}(u)\ddot{u}+\mathcal{F}(\dot{u},u) = 0}`\ .. REMARK: Refer to `Robotran basics `__ for more details. Independent variables ~~~~~~~~~~~~~~~~~~~~~ - Their position and velocity are fixed by the time integrator - Their acceleration results of the equation of motion - Initial values must be given by the user Dependent variables ~~~~~~~~~~~~~~~~~~~ - Their values depend on the independent (and driven) variables - Their positions, velocities and accelerations are fixed by the constraint equations -> Number of dependent variables = number of independent constraints Example: suspension with superimposed arms .. figure:: figure/cut_suspension.png :alt: Suspension with superimposed arms. Illustration of the suspension with superimposed arms - 5 generalized coordinates - 2 constraints: \ :math:`\begin{matrix} x_A & = & x_B \\ y_A & = & y_B \end{matrix}`\ -> 2 dependent variables to choose \ :math:`x_A = x_B \Rightarrow l_{1}\cos(q_{2}) + l_{2}\sin(q_{2}+q_{3}) - l_{1}\cos(q_{5}) = 0` \ :math:`y_A = y_B \Rightarrow l_{1}\sin(q_{2}) + l_{2}\cos(q_{2}+q_{3}) - l_{1}\sin(q_{5}) - l_{2} = 0`\ Back to the pendulum-spring example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. figure:: figure/cut_example.png :alt: A four bar mechanism is added to the pendulum spring system, a kinematic loop is created Illustration of the modified example with a kinematic loop Add a four bar mechanism with the following additional bodies: - The crank connected to the ground - Mass: 2 kg - Inertia along axis \ :math:`\hat{I}_{2}`\ : 0.1 kg m² - Center of mass: in the middle of the crank - The rod connected to the crank and to the pendulum - Mass: 2 kg - Inertia along axis \ :math:`\hat{I}_{2}`\ : 0.1 kg m² - Center of mass: in the middle of the rod The joint between the pendulum and the blue rod will be replaced by a ball cut. Step 1: Draw your multibody system ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Open the Pendulum Spring model in MBsysPad - Add an anchor point on the base and fill the coordinates - The anchor point on the pendulum has been created `here <./links.html>`__ .. REMARK: A single anchor point can be used for connecting several elements: a joint, a link, a cut … - Add the kinematic chain of the crank and the rod - Add a ball cut between the rod and the pendulum - Click on the Cut button and select ball - Click on the anchor point of the pendulum - Click on the anchor point of the rod - Click on the cut to edit its properties - Change the name of the cut .. figure:: figure/cut_snapshot_cutMenu.png :alt: Menu to create a ball cut Menu to create a ball cut - Set the joint between the base and the crank and the joint between the crank and the rod as dependent variables: - Click on the joint - Click on dependent (see figure below, on the red rectangle) .. REMARK: The initial value of the dependent joint can be arbitrary, the newton-raphson procedure will modify the value in order to close the loop. However, this procedure will choose one solution among the existing solutions. For example the loop closure can be solved with the configuration shown in the previous figure or it can put the crank upward. To drive the newton-raphson procedure toward the solution you want, you have to adjust the initial value of the joints to be close of your loop closure solution. .. figure:: figure/cut_snapshot_jointNature.png :alt: Options to set a joint as dependent Joint nature gui screenshot .. REMARK: You can set or modify the choice of dependent (and independent) variable in the code. This feature is only recommended for advanced users. Warning: any change of joint nature done in MBsysPad will be overwrote by the code! The ID number of the joint is valid for our project, these numbers can differ for your project. See the `Tips and tricks <./tipsAndTrick.html#get-the-id-of-a-specific-joint-body-link-f-sensor-s-sensor>`__ in order to get a strong method of joint ID recovering. Setting joint nature in the code (Optional, for advanced users) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' .. container:: c-code - Open the main.c file - Add ``#include "mbs_set.h"`` at the beginning - Add the following commands - After the project loading (*load()* function) - Before the coordinate partitioning (*Coord_part* function) .. code:: c /*... ########################################################### # REMARK - WARNING # ########################################################### # This code overwrites the modification done in MBsysPad. # # For the next section of the tutorial you have to # # comment these lines or adapt the joint nature for each # # section. # ########################################################### */ int i=0; for(i=1; i<=mbs_data->njoint; i++) { // all variables are set to "independent" mbs_set_qu(mbs_data, i); } mbs_set_qv(mbs_data, 3); mbs_set_qv(mbs_data, 4); // variables 3 and 4 are set to "dependent" //... Step 2: Generate your multibody equations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Click on the menu Tools > Generate Symbolic Files - Follow the procedure as for the previous example Step 3: Write your user function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ No user functions are necessary when using predefined cuts Step 4: Run your simulation ^^^^^^^^^^^^^^^^^^^^^^^^^^^ In case of kinematic loops the coordinate partitioning has to be present in the code. In most template the coordinate partitioning is present. If not you have to modify the script: .. container:: c-code - Open the main.c file and add the following command - After the project loading (*mbs_load()* function) - Before the time integration (*mbs_run_dirdyn()* function) .. code:: c //... // initialisation of structure for the coordinate partitioning mbs_part = mbs_new_part(mbs_data); // options for the coordinate partitioning mbs_part->options->rowperm=1; mbs_part->options->verbose = 1; // compute the coordinate partitioning mbs_run_part(mbs_part, mbs_data); // free the memory mbs_delete_part(mbs_part); //... .. REMARK: Some options are available for the coordinate partitioning process, see the `documentation `__. Check the results ^^^^^^^^^^^^^^^^^ Plot the graph of the joint position (results are available in resultsR/ folder) and check your results with the following graph. .. figure:: figure/cuts_curves_q1q2.png :alt: Plot the time history of the joint position of the pendulum spring example Time history of the joint position