This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

A general framework for modeling and dynamic simulation
of multibody systems using factor graphs

José-Luis Blanco-Claraco [email protected] [ Antonio Leanza Giulio Reina Department of Engineering, University of Almería, CIESOL. Campus de Excelencia Internacional Agroalimentario, ceiA3, 04120 Almería, Spain Department of Innovation Engineering, University of Salento, via Monteroni, 73100, Lecce, Italy Department of Mechanics, Mathematics, and Management, Polytechnic of Bari, via Orabona 4, 70126 Bari, Italy
Abstract

In this paper, we present a novel general framework grounded in the factor graph theory to solve kinematic and dynamic problems for multi-body systems. Although the motion of multi-body systems is considered to be a well-studied problem and various methods have been proposed for its solution, a unified approach providing an intuitive interpretation is still pursued. We describe how to build factor graphs to model and simulate multibody systems using both, independent and dependent coordinates. Then, batch optimization or a fixed-lag-smoother can be applied to solve the underlying optimization problem that results in a highly-sparse nonlinear minimization problem. The proposed framework has been tested in extensive simulations and validated against a commercial multibody software. We release a reference implementation as an open-source C++ library, based on the GTSAM framework, a well-known estimation library. Simulations of forward and inverse dynamics are presented, showing comparable accuracy with classical approaches. The proposed factor graph-based framework has the potential to be integrated into applications related with motion estimation and parameter identification of complex mechanical systems, ranging from mechanisms to vehicles, or robot manipulators.

keywords:
Dynamics of mechanical systems , Multibody systems , Motion state estimation , Factor graph , Nonlinear optimization , Computational mechanics
journal: ..

url]https://w3.ual.es/personal/jlblanco/

List of symbols

𝐪(t),𝐪˙(t),𝐪¨(t){\mathbf{q}}(t),{\dot{\mathbf{q}}}(t),{\ddot{\mathbf{q}}}(t) Vector of generalized dependent coordinates, velocities, and accelerations, respectively.
𝐳(t),𝐳˙(t),𝐳¨(t){\mathbf{z}}(t),{\dot{\mathbf{z}}}(t),{\ddot{\mathbf{z}}}(t) Vector of generalized independent coordinates, velocities, and accelerations, respectively.
𝚽(𝐪,t){\boldsymbol{\Phi}}\left({\mathbf{q}},t\right) Vector of constraint equations.
𝚽𝐪\mathbf{\Phi_{q}} Jacobian matrix of the constraints 𝚽{\boldsymbol{\Phi}}.
𝚽t{\boldsymbol{\Phi}}_{t} Partial derivatives of constraints 𝚽{\boldsymbol{\Phi}} with respect to time tt.
𝚽𝐪𝐪,(𝚽˙𝐪)𝐪\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}},(\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}} Jacobians of 𝚽𝐪\mathbf{\Phi_{q}} and 𝚽˙𝐪\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}} with respect to 𝐪{\mathbf{q}} (third-order tensors).
𝐛\mathbf{b} Constraint velocities.
𝐜\mathbf{c} Constraint acceleration.
𝝀\boldsymbol{\lambda} Vector of Lagrangian multipliers.
CC Active ”branch” or ”configuration” of a mechanism.
𝐐t{\mathbf{Q}}_{t} Generalized forces for time step tt.
𝐌{\mathbf{M}} Mass matrix for a mechanism (dependent coordinates).
𝐐¯\overline{\mathbf{Q}} Reduced generalized forces vector.
𝐌¯\overline{\mathbf{M}} Reduced mass matrix for a mechanism (independent coordinates).
𝐑{\mathbf{R}} The 𝐑{\mathbf{R}} matrix, mapping increments between independent and dependent velocities.
nn Number of dependent coordinates in 𝐪(t){\mathbf{q}}(t).
mm Number of scalar constrain equations in 𝚽{\boldsymbol{\Phi}}.
\mathbb{R} The set of Real numbers.

1 Introduction

Dynamic simulation of multibody systems mainly refer to inverse and forward problems. Inverse dynamics deals with the determination of the driving forces that generate a given motion, as well as the constraint reaction forces. The solution to the inverse dynamics problem can be obtained for example using the Newton-Euler (N-E) method [1], that results in efficient recursive algorithms, e.g., Rigid Body Dynamics Library (RBDL) [2] and similar methods [3]. Conversely, forward dynamics involves the motion estimation of a multi-body system over time under the given applied forces and initial conditions. Therefore, in a direct dynamic problem, the motion is the result of the force system that generates it. From a mathematical perspective, forward dynamics is computationally intensive as it entails the integration of a system of nonlinear ordinary differential equations. The most common formulations that deal with forward dynamic are the Composite-Rigid-Body Algorithm (CRBA) [4] and the Articulated-Body Algorithm (ABA) [5]. However, the above mentioned methods are not suited for systems with closed-loops like parallel robots, for which more complex and expensive procedures are required to solve both inverse and forward dynamics, as described for example in [6].
Therefore, a single algorithm that can solve all types of dynamics problems has not been fully established. One notable effort is the work by Rodriguez [7], who proposed a unified approach based on Kalman filtering and on the concept of smoothing to solve dynamics problems. This approach has been further extended to solve the forward dynamic problem of closed kinematic chains [8]. Another effort in defining a unifying framework has been given by [9], who analyzed various algorithms for serial chain dynamics. In [10], an attempt is proposed to unify the CRBA and ABA derivation as two elimination methods to solve forward dynamics.
To the best of our knowledge, factor graphs have not been applied to solve the general multibody kinematics and dynamics in the existing literature. The closest works are the preprints [11, 12], where factor graphs are indeed employed to solve kinematic and dynamic problems, although their proposed graph structure is applicable to open-loop robot arms only.

The present work advocates factor graphs as a unifying graphical language in which to express the classical kinematics and dynamics algorithms, with the additional potential to develop novel and advanced state estimators. The main contributions of this work are:

  • 1.

    a factor graph-based representation of dynamics problems, which is a insightful visualization of the underlying sparse constraints between all involved variables,

  • 2.

    a unified method, which can solve inverse and forward dynamics for either open or closed kinematic chains,

  • 3.

    a flexible framework that can be expressed and solved for both dependent and independent coordinates.

Also, note that despite the implementation described in this manuscript is focused on planar mechanisms, it is perfectly suitable to spatial systems without changes at the level of factor graphs. Additionally, our approach allows more powerful and flexible schemes for state and parameter estimation to be implemented in contrast with standard methods based on Kalman filtering [13, 14, 15, 16, 17]. However, such applications are left for future extensions of this work to keep the present manuscript focused on the key ideas on how to apply factor graphs to multibody motion problems.

The proposed approach draws on the formalism of graphical models, a powerful tool borrowing concepts from statistics and graph theory [18, 19]. By addressing the multibody simulation problem from the perspective of the variable structure, graphical models allow us creating efficient estimators for any combination of observed and hidden variables, effectively unifying the problems of kinematic and forward dynamic analysis (predicting or estimating the trajectory of a MB system), inverse dynamics, and parameter identification (e.g., inertial properties of the bodies involved, external disturbance forces, friction in the joints, etc.). All those problems end up to be formulated as a sparse nonlinear cost function built from a library of reusable “building blocks” (the factors) on which efficient solvers can then be applied. The framework is suitable for either offline batch analysis or online real-time operation that represents another clear advantage of the proposed approach.

The rest of the paper is structured as follows. Sections 2 and 3 first provide the required background on multibody dynamics and graphical models, respectively. Next, section 4 presents a methodology for the application of Bayesian networks to multibody dynamics problems, whereas section 5 particularizes such networks as factor graphs for a number of practical problems. Individual factors used in those graphs are described in detail in section 6. Numerical examples are provided in section 7, and we end sketching some conclusions in section 8.

2 Review of Multibody Dynamics

In this section, fundamentals of multibody system motion analysis are briefly recalled, whereas the interested reader can refer for more details to the wide related Literature, e.g. [20]. A multibody system is an assembly of two or more bodies (or elements) constrained to each other to fulfill a given motion law. In many practical applications, these elements may be considered rigid and, throughout this paper, we will work under this assumption even though the proposed framework may be further extended to include body flexibility.
One of the key decisions to take when modeling a MBS is selecting the set of generalized coordinates that will be used to represent it. Using independent coordinates 𝐳{\mathbf{z}} allows one to deal with the lowest number of parameters, i.e. the number of DOFs of the system. A second choice is to adopt dependent coordinates 𝐪{\mathbf{q}}, in a number larger than that of DOFs but able to describe all multibody system points univocally. When dependent coordinates are used, the corresponding set of constraint equations must be included as well for a complete system analysis. There are different kinds of dependent coordinates [20]: Relative Coordinates, References Point Coordinates, Natural Coordinates, and a combination of the previous ones (Mixed Coordinates). Natural coordinates, mixed with relative coordinates where needed, will be assumed in this work.

In the remainder of this Section, the MBS motion equations are developed and expressed in terms of both dependent and independent coordinates.

2.1 Dependent coordinates formulation

For any given MBS with ff dofs, the use of nn dependent coordinates expressed by the vector 𝐪{\mathbf{q}} requires m=nfm=n-f constraint equations, which form the following set of equations

𝚽(𝐪(t),t)=𝟎{\boldsymbol{\Phi}}\left({\mathbf{q}}(t),t\right)=\mathbf{0} (1)

Thus, it is assumed that there are at least as many equations as there are unknown coordinates. To solve the kinematic problem, the time derivative of Eq. (1) is required, one time for velocity analysis and two times for acceleration analysis, leading to the following set of equations

𝚽𝐪(𝐪(t),t)𝐪˙=𝚽t𝐛\mathbf{\Phi_{q}}({\mathbf{q}}(t),t)~{}{\dot{\mathbf{q}}}=-{\boldsymbol{\Phi}}_{t}\equiv\mathbf{b} (2)
𝚽𝐪(𝐪(t),t)𝐪¨=𝚽˙t𝚽˙𝐪𝐪˙𝐜\mathbf{\Phi_{q}}({\mathbf{q}}(t),t)~{}{\ddot{\mathbf{q}}}=-\dot{{\boldsymbol{\Phi}}}_{t}-\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}}{\dot{\mathbf{q}}}\equiv\mathbf{c} (3)

where 𝐪˙\dot{\mathbf{q}} is the vector of dependent velocities, 𝚽𝐪m×n\mathbf{\Phi_{q}}\in\mathbb{R}^{m\times n} the Jacobian matrix of Eq. (1) respect to 𝐪{\mathbf{q}}, and 𝚽t{\boldsymbol{\Phi}}_{t} the time derivative of constraint equations that is equal to the null vector for time-independent constraints.
To solve the dynamic problem, external forces and inertia forces need to be considered. From the classical Newton’s law, one obtains the following set of differential equations that expresses the force equilibrium equations

𝐌𝐪¨+𝚽𝐪𝝀=𝐐{\mathbf{M}}{\ddot{\mathbf{q}}}+\mathbf{\Phi_{q}}^{\top}\boldsymbol{\lambda}={\mathbf{Q}} (4)

where 𝝀\boldsymbol{\lambda} is the vector of Lagrange multipliers, 𝐌{\mathbf{M}} is the system mass matrix and vector 𝐐{\mathbf{Q}} contains the generalized external forces. Since Eq. (4) is a system of nn equations in n+mn+m variables, by adding the mm equations (3) one obtains the following system

[𝐌𝚽𝐪𝚽𝐪𝟎][𝐪¨𝝀]=[𝐐𝐜]\begin{bmatrix}\mathbf{M}&&\mathbf{\Phi_{q}}^{\top}\\ \mathbf{\Phi_{q}}&&\mathbf{0}\end{bmatrix}\left[\begin{array}[]{c}{\ddot{\mathbf{q}}}\\ \boldsymbol{\lambda}\end{array}\right]=\left[\begin{array}[]{c}{\mathbf{Q}}\\ \mathbf{c}\end{array}\right] (5)

Normally [20, 21], this equation is solved for the extended vector of unknowns that includes both, 𝐪¨{\ddot{\mathbf{q}}} and 𝝀\boldsymbol{\lambda}. In our framework, we are specifically interested in the generalized accelerations 𝐪¨{\ddot{\mathbf{q}}}. Therefore, by applying the block matrix inversion lemma (see Appendix I. Block matrix inversion lemma) to Eq. (5) and keeping the first row only, it leads to the following equation of motion expressed in terms of dependent coordinates:

𝐪¨=(𝐌1𝐌1𝚽𝐪𝚪1𝚽𝐪𝐌1)𝐐+(𝐌1𝚽𝐪𝚪1)𝐜{\ddot{\mathbf{q}}}=\left({\mathbf{M}}^{-1}-{\mathbf{M}}^{-1}\mathbf{\Phi_{q}}^{\top}\mathbf{\Gamma}^{-1}\mathbf{\Phi_{q}}{\mathbf{M}}^{-1}\right){\mathbf{Q}}+\left({\mathbf{M}}^{-1}\mathbf{\Phi_{q}}^{\top}\mathbf{\Gamma}^{-1}\right)\mathbf{c} (6)

where we defined the auxiliary term 𝚪(𝐪)\mathbf{\Gamma}\left({\mathbf{q}}\right) as the m×mm\times m square symmetric matrix

𝚪=𝚽𝐪𝐌1𝚽𝐪,\mathbf{\Gamma}=\mathbf{\Phi_{q}}{\mathbf{M}}^{-1}\mathbf{\Phi_{q}}^{\top}, (7)

introduced for convenience in subsequent derivations.

2.2 Independent coordinates formulation

Independent coordinates 𝐳{\mathbf{z}}, ensure the minimum number of variables, i.e. the number of DOFs. However, multibody systems can be more difficult to analyze with respect to dependent ones. First, the matrix 𝐑{\mathbf{R}} is introduced as

𝐪˙=d𝐪dt=𝐪𝐳𝐳t=𝐑(𝐪)𝐳˙{\dot{\mathbf{q}}}=\frac{d{\mathbf{q}}}{dt}=\frac{\partial{\mathbf{q}}}{\partial{\mathbf{z}}}\frac{\partial{\mathbf{z}}}{\partial t}=\mathbf{R}({\mathbf{q}}){\dot{\mathbf{z}}} (8)

where the columns of 𝐑{\mathbf{R}} are ff linearly independent vectors that constitute a basis of the nullspace of 𝚽𝐪\mathbf{\Phi_{q}}. Then, we express the independent velocities 𝐳˙{\dot{\mathbf{z}}} as the projection of the dependent velocities 𝐪˙{\dot{\mathbf{q}}} on the rows of a constant matrix 𝐁{\mathbf{B}} that we assume satisfying the condition of having ff rows linearly independent from each other and from the mm rows of 𝚽𝐪\mathbf{\Phi_{q}}

𝐳˙=𝐁𝐪˙{\dot{\mathbf{z}}}={\mathbf{B}}{\dot{\mathbf{q}}} (9)

By combining Eq. (2) with Eq. (9), one obtains

[𝚽𝐪𝐁]𝐪˙=[𝐛𝐳˙]\begin{bmatrix}\mathbf{\Phi_{q}}\\ {\mathbf{B}}\end{bmatrix}{\dot{\mathbf{q}}}=\begin{bmatrix}\mathbf{b}\\ {\dot{\mathbf{z}}}\end{bmatrix} (10)
𝐪˙=[𝚽𝐪𝐁]1[𝐛𝐳˙]=𝐒𝐛+𝐑𝐳˙{\dot{\mathbf{q}}}=\begin{bmatrix}\mathbf{\Phi_{q}}\\ {\mathbf{B}}\end{bmatrix}^{-1}\begin{bmatrix}\mathbf{b}\\ {\dot{\mathbf{z}}}\end{bmatrix}=\mathbf{S}\mathbf{b}+{\mathbf{R}}{\dot{\mathbf{z}}} (11)

The columns of matrix 𝐑{\mathbf{R}} are the partial velocities with respect to the generalized coordinates 𝐳{\mathbf{z}}, and the term 𝐒𝐛\mathbf{Sb} represents the partial velocities with respect to time.

By differentiating Eq. (9) and by taking into account Eq. (3), one gets

[𝐜𝐳¨]=[𝚽𝐪𝐁]𝐪¨𝐪¨=[𝐒𝐑][𝐜𝐳¨]=𝐒𝐜+𝐑𝐳¨\begin{bmatrix}\mathbf{c}\\ {\ddot{\mathbf{z}}}\end{bmatrix}=\begin{bmatrix}\mathbf{\Phi_{q}}\\ {\mathbf{B}}\end{bmatrix}{\ddot{\mathbf{q}}}\Rightarrow{\ddot{\mathbf{q}}}=\left[\mathbf{S}\hskip 8.5359pt{\mathbf{R}}\right]\begin{bmatrix}\mathbf{c}\\ {\ddot{\mathbf{z}}}\end{bmatrix}=\mathbf{S}\mathbf{c}+{\mathbf{R}}{\ddot{\mathbf{z}}} (12)

From Eq. (4), pre-multiplied by 𝐑{\mathbf{R}}^{\top}

𝐑𝐌𝐪¨=𝐑𝐐{\mathbf{R}}^{\top}{\mathbf{M}}{\ddot{\mathbf{q}}}={\mathbf{R}}^{\top}{\mathbf{Q}} (13)

and by substituting 𝐪¨{\ddot{\mathbf{q}}} in Eq. (12)

𝐑𝐌𝐑𝐳¨=𝐑(𝐐𝐌𝐒𝐜){\mathbf{R}}^{\top}{\mathbf{M}}{\mathbf{R}}{\ddot{\mathbf{z}}}={\mathbf{R}}^{\top}\left({\mathbf{Q}}-{\mathbf{M}}\mathbf{Sc}\right) (14)

Introducing the reduced mass matrix 𝐌¯=𝐑𝐌𝐑\overline{\mathbf{M}}={\mathbf{R}}^{\top}{\mathbf{M}}{\mathbf{R}} and force vector 𝐐¯=𝐑(𝐐𝐌𝐒𝐜)\overline{\mathbf{Q}}={\mathbf{R}}^{\top}\left({\mathbf{Q}}-{\mathbf{M}}\mathbf{Sc}\right), the following equation of motion in terms of independent coordinates can be finally obtained

𝐳¨=𝐌¯1𝐐¯{\ddot{\mathbf{z}}}=\overline{\mathbf{M}}^{\hskip 2.84544pt-1}\overline{\mathbf{Q}} (15)

3 Background on graphical models

A factor graph is a particular type of probabilistic graphical model that can be used to describe the structure of an estimation problem [22]. Factor graphs have found applications in many fields, for example in robot perception [23], information theory [24], signal processing [25], and in other areas of robotics, mostly SLAM [26] and computer vision [27], state estimation in legged robots [28], and kinematic motion planning [29].

3.1 Dynamic Bayesian Networks

It is instructive to start our discussion by considering a Dynamic Bayesian Network (DBN), a type of graphical model where variables are represented as nodes and directed edges stand for causal relationships [30, 22]. The existence of directed edges in a DBN allows us to encode an expert’s knowledge in causality relationships between all involved variables in the graph.

The rules to convert a DBN into the kind of graphs we are actually using in this work, factor graphs (FGs), are discussed in section 5. A relevant point regarding such conversion is that one single DBN can be mapped into different FGs depending on which subset of the original DBN variables are known data and which unknowns are required to be found. Let us remark that whereas a DBN displays all variables as nodes, in a FG only unknown variables are variable nodes.

3.2 Factor graphs

Factor graphs (FGs) are bipartite graphs comprising two kinds of nodes: variable nodes, and factor nodes. Variables are the unknown data to be estimated, and factors represent any constraint (a cost function to be minimized) or relationship between variables. A crucial aspect of a FG is its sparsity: each factor node is only connected to the variables that appear in its cost function. Sparse graph optimization algorithms exist with computational cost almost linear with the number of edges in a FG, as opposed to, for example, the cubic cost of a naive implementation of Kalman Filtering [31]. Incremental (e.g. [32]) and sliding-window (e.g. [33]) approaches exist as well, enabling the efficient estimation of problems with thousands to millions of variables [34, 35, 36].

Once a FG is formulated for a given problem, estimating the most-likely value of all the unknowns becomes a numerical nonlinear minimization problem, for which very efficient algorithms exist. As a probabilistic estimator, these optimal values can be assigned an uncertainty. In general, retrieving the covariance 𝚺\boldsymbol{\Sigma} of the estimated variables involves inverting the Hessian of the linearized problem evaluated at the optimal solution, such that 𝚺=(𝐉𝚲𝐉)1\boldsymbol{\Sigma}=(\mathbf{J}^{\top}{\boldsymbol{\Lambda}}\mathbf{J})^{-1} with 𝐉\mathbf{J} the sparse Jacobian of all constraints (factors), and 𝚲{\boldsymbol{\Lambda}} the weight matrix representing our level of certainty about each constraint. The matrix inversion operation is, in general, very costly since it is cubic with the problem dimension. However, optimized methods exist for the kind of sparse problem at hand, see for example, [37, §B.4] or [32].

4 DBN for multibody dynamics

Since DBNs allow a human expert to specify the causality relationships between variables, we propose the two DBNs in Figure 1 as the underlying structure of a generic multi-body system that is the basis for our proposed framework. Note the use of discrete time steps tt, exactly as simulations are commonly done following numerical integration schemes. A set of observations or measurements 𝐨\mathbf{o} are available from sensors installed on the system. Note, however, that the graphical model formalism is flexible enough to allow each sensor to be available at a different or even sampling rate. When using this graphical model to achieve state estimation, sensors may provide partial information on the system dynamics, which will be then fused with the rest of graph constraints over the system trajectory to reach the most-likely values of the estimated variables. In non state-estimation problems, the set of observations 𝐨\mathbf{o} may be empty. Additionally, system parameters such as masses, stiffness or friction coefficients (constant or variable over time) could be added as additional nodes, although this possibility is left out of the scope of this manuscript for the sake of conciseness.

Refer to caption
(a) Model for dependent coordinates formulation
Refer to caption
(b) Model for independent coordinates formulation
Figure 1: Dynamic Bayesian Network (DBN) models representing the causality relationship between the variables involved in general multibody dynamics problems over discrete time steps tt. Notation: 𝐪,𝐪˙,𝐪¨{\mathbf{q}},{\dot{\mathbf{q}}},{\ddot{\mathbf{q}}} are the dependent coordinates, 𝐳,𝐳˙,𝐳¨{\mathbf{z}},{\dot{\mathbf{z}}},{\ddot{\mathbf{z}}} are independent coordinates, 𝐨\mathbf{o} are sensor observations, CC is the active branch of the mechanism, and 𝐐{\mathbf{Q}} the external forces. Dashed boxes represent groups of variables for which input or output directed edges affect all members. See section 3 for a discussion.

From Figure 1, some observations can be drawn:

  • 1.

    A central role in the DBN for independent coordinates (Figure 1(b)) is played by the independent coordinates 𝐳,𝐳˙,𝐳¨{{\mathbf{z}},{\dot{\mathbf{z}}},{\ddot{\mathbf{z}}}} as they represent the degrees of freedom (d.o.f) that govern the evolution of the MBS. This role is assumed by the dependent coordinate variables 𝐪,𝐪˙,𝐪¨{{\mathbf{q}},{\dot{\mathbf{q}}},{\ddot{\mathbf{q}}}} in Figure 1(a).

  • 2.

    The branch variable CC, required uniquely in the independent-coordinate formulation, allows us to disambiguate between, e.g. the two possible configurations for a four-bar linkage if we are only given the information about the crank angle. This variable could be part of the unknowns to be estimated, as already done in [38], although that work did not use the more powerful FG representation proposed here.

  • 3.

    Typically, nodes in a DBN are depicted as shaded or unshaded depending of whether they are “hidden” or “observed” variables, respectively, e.g. see [19, 38]. The former are estimated from the latter. Since this work focuses on FGs instead, where observed variables are subsumed into factor nodes and unknowns become variable nodes [23], different FGs will be generated from the same DBNs in Figure 1 for different multibody simulation problems, hence it is not convenient to establish such a distinction at the DBN level yet.

  • 4.

    Observations 𝐨\mathbf{o} (sensor readings) are a function of (all, or a subset of) dependent coordinates. Typical observations that may be useful in a MBD problem are measurements obtained from gyroscopes, accelerometers, and load cells.

  • 5.

    External forces 𝐐t{\mathbf{Q}}_{t} act by means of modifying accelerations 𝐪¨t{\ddot{\mathbf{q}}}_{t} or 𝐳¨t{\ddot{\mathbf{z}}}_{t}, according to the system dynamics, expressed by Eq. (6) or Eq. (15), respectively.

Once the model of the dynamics MBS has been expressed as a graphical model, the time evolution of the system can be obtained by converting the graph into a maximum-a-posteriori (MAP) estimation problem. To this aim, one could write down the joint probability distribution p(ϕ)p(\phi) of all the involved variables ϕ={𝐪0:t,𝐪˙0:t,𝐪¨0:t,𝐨0:t,𝐐0:t}\phi=\{{\mathbf{q}}_{0:t},{\dot{\mathbf{q}}}_{0:t},{\ddot{\mathbf{q}}}_{0:t},{\mathbf{o}}_{0:t},{\mathbf{Q}}_{0:t}\} for time steps 0 to tt exploiting the conditional probability encoded by the DBN (refer to e.g. [19, 22]), which for dependent coordinates (i.e. Figure 1(a)) becomes:

p(ϕ)=p(𝐪0)p(𝐪˙0)(i=0tp(𝐐i))(i=1tp(𝐨i|𝐪i,𝐪˙i,𝐪¨i)p(𝐪¨i|𝐪i,𝐪˙i,𝐐i)p(𝐪i|𝐪i1,𝐪˙i1)p(𝐪˙i|𝐪¨i1,𝐪˙i1))p(\phi)=p({\mathbf{q}}_{0})p({\dot{\mathbf{q}}}_{0})\left(\prod_{i=0}^{t}p({\mathbf{Q}}_{i})\right)\left(\prod_{i=1}^{t}p({\mathbf{o}}_{i}|{\mathbf{q}}_{i},{\dot{\mathbf{q}}}_{i},{\ddot{\mathbf{q}}}_{i})p({\ddot{\mathbf{q}}}_{i}|{\mathbf{q}}_{i},{\dot{\mathbf{q}}}_{i},{\mathbf{Q}}_{i})p({\mathbf{q}}_{i}|{\mathbf{q}}_{i-1},{\dot{\mathbf{q}}}_{i-1})p({\dot{\mathbf{q}}}_{i}|{\ddot{\mathbf{q}}}_{i-1},{\dot{\mathbf{q}}}_{i-1})\right) (16)

where each conditional probability term in Eq. (16), taking negative logarithms and up to an irrelevant proportionality constant, becomes a factor in this alternative form of an overall cost function c(ϕ)c(\phi) to be minimized:

c(ϕ)=fprior(𝐪0)fprior(𝐪˙0)(i=0tfprior(𝐐i))(i=1tfobs(𝐨i,𝐪i,𝐪˙i,𝐪¨i)fdynd(𝐪¨i,𝐪i,𝐪˙i,𝐐i)fei(𝐪i,𝐪i1,𝐪˙i1)fei(𝐪˙i,𝐪¨i1,𝐪˙i1))c(\phi)=f_{prior}({\mathbf{q}}_{0})f_{prior}({\dot{\mathbf{q}}}_{0})\left(\prod_{i=0}^{t}f_{prior}({\mathbf{Q}}_{i})\right)\left(\prod_{i=1}^{t}f_{obs}({\mathbf{o}}_{i},{\mathbf{q}}_{i},{\dot{\mathbf{q}}}_{i},{\ddot{\mathbf{q}}}_{i})f^{d}_{dyn}({\ddot{\mathbf{q}}}_{i},{\mathbf{q}}_{i},{\dot{\mathbf{q}}}_{i},{\mathbf{Q}}_{i})f_{ei}({\mathbf{q}}_{i},{\mathbf{q}}_{i-1},{\dot{\mathbf{q}}}_{i-1})f_{ei}({\dot{\mathbf{q}}}_{i},{\ddot{\mathbf{q}}}_{i-1},{\dot{\mathbf{q}}}_{i-1})\right) (17)

A fundamental feature of graphical models is how they enable factorizing functions of all problem variables such as c(ϕ)logp(ϕ)c(\phi)\propto-\log p(\phi) into the product of a large number of smaller functions (in terms of the number of variables involved in each expression) called factors in Eq. (17), which are discussed individually in section 6. This is what keeps the estimation problem tractable even for hundreds of thousands of variables, something intractable for estimators in the family of the Kalman filter not exploiting the sparsity of the problem structure. Note that the goal of an estimator is searching for the optimal set of unknowns ϕ\phi^{\star} that maximize the likelihood of all observed data according to the model, that is:

ϕ=argmaxϕp(ϕ)=argminϕc(ϕ)\phi^{\star}=\arg\max_{\phi}p(\phi)=\arg\min_{\phi}c(\phi) (18)

Depending on the division of the DBN variables into observed and unknowns, we would arrive at different factorizations since factors are considered to be functions of the unknowns only. For example, if all variables in one given cost factor in Eq. (17) are known data it just evaluates to a constant which can be absorbed by the proportionality relationship c(ϕ)logp(ϕ)c(\phi)\propto-\log p(\phi) and hence can be ignored. A graphical representation of the remaining relevant factors leads us to factor graphs themselves.

5 Factor graphs for multibody dynamics

The conversion from DBN to FG is known to be achievable as follows, without the need to explicitly writing down probabilistic equations like Eq. (16)–Eq. (17):

Every Bayes net [DBN] node splits in both a variable node and a factor node in the corresponding factor graph. The factor is connected to the variable node, as well as the variable nodes corresponding to the parent nodes in the Bayes net. If some nodes in the Bayes net are evidence nodes, i.e., they are given as known variables, we omit the corresponding variable nodes: the known variable simply becomes a fixed parameter in the corresponding factor. [23, p. 12]

Applying these rules to the DBN reflecting the structure of variables involved in the dynamic simulation of multibody systems with dependent coordinates in Figure 1(a) we derive next the FGs for a couple of practical problems depending on which are the known and unknown variables. Factors will be only briefly discussed here regarding their purpose and meaning, whereas their detailed implementations are described in section 6.

5.1 FG for forward dynamics in dependent coordinates

Refer to caption
Figure 2: Factor graphs for the forward dynamic simulation problem using dependent generalized coordinates. Circle nodes are problem unknowns, solid square nodes are factors. See discussion in section 5.1.

In forward dynamics simulation, we are given a known initial state of a mechanical system (position 𝐪0{\mathbf{q}}_{0} and velocity 𝐪0{\mathbf{q}}_{0}), their geometric and inertial properties, and the external forces that act on it (𝐐i{\mathbf{Q}}_{i}, i=0,,Ni=0,...,N). For simplicity, we assume no sensors are installed in the system since this problem instance does not need them, but predicting sensor outputs could be also possible adding the corresponding nodes and factors.

The resulting FG when using dependent coordinates is shown in Figure 2 and it involves the following factor nodes (or plain factors):

  • 1.

    fpriorf_{prior}: Factors imposing a given a priori knowledge about the attached variables, e.g. initial conditions. Prior factors can be defined for both, position and velocity.

  • 2.

    fpcdf^{d}_{pc}: Factor for position constraints in dependent coordinates. It ensures the fulfillment of mechanical holonomic constraints by keeping the state vector 𝐪{\mathbf{q}} on the manifold 𝚽(𝐪,t)=𝟎{\boldsymbol{\Phi}}({\mathbf{q}},t)=\mathbf{0}, hence this factor is repeated for each position node 𝐪i{\mathbf{q}}_{i}. It could be omitted for 𝐪0{\mathbf{q}}_{0} if the enforced pose imposed by the prior factor is known to be a correct mechanism position complying with 𝚽()=𝟎{\boldsymbol{\Phi}}(\cdot)=\mathbf{0}; alternatively, the prior factor can be made to affect a minimum number of variables in 𝐪0{\mathbf{q}}_{0} (the number of degrees of freedom), leaving fpcdf^{d}_{pc} in charge of recalculating the rest of the generalized coordinates. This factor, on its own, solves the so-called position problem [20] in multibody dynamics.

  • 3.

    fvcdf^{d}_{vc}: Factor for velocity constraints in dependent coordinates, enforcing generalized velocities 𝐪˙{\dot{\mathbf{q}}} to remain on the manifold 𝚽𝐪𝐪˙+𝚽t=𝟎\mathbf{\Phi_{q}}{\dot{\mathbf{q}}}+{\boldsymbol{\Phi}}_{t}=\mathbf{0}.

  • 4.

    fdyndf^{d}_{dyn}: Factor for the dynamics equation of motion: it links external forces (known data in this FG, hence not reflected as variable nodes) with the instantaneous acceleration 𝐪¨{\ddot{\mathbf{q}}}. It also depends on 𝐪{\mathbf{q}} and 𝐪˙{\dot{\mathbf{q}}} since acceleration is always a function of them too. Note in the graph how acceleration for each timestep depends on position and velocity of the same timestep only.

  • 5.

    ftif_{ti}: Trapezoidal numerical integrator factor is used twice per timestep: to integrate velocities into positions, and accelerations into velocities. Implicit integrators as the Trapezoidal one are often employed in MBS simulations for their stability. However, the Euler integrator version is also devised (see section 6), since explicit integrators are commonly used in real-time applications as well.

5.2 FG for forward dynamics in independent coordinates

Refer to caption
Figure 3: Factor graph model for the forward dynamic simulation problem using independent generalized coordinates. Circle nodes are problem unknowns, solid square nodes are factors. See discussion in section 5.2.

Alternatively, one could devise a FG implementation for the forward dynamics problem when using independent coordinates, leading to the graph depicted in Figure 3. In this case, the following factors are used:

  • 1.

    fpriorf_{prior}: In this case, they are used to impose both, an initial known dynamic state (𝐳0{\mathbf{z}}_{0}, 𝐳˙0{\dot{\mathbf{z}}}_{0}) and approximated initial values for the full vector of dependent coordinates 𝐪0{\mathbf{q}}_{0}. The latter may be required to solve ambiguities in closed kinematic topologies, e.g. a four bar linkage, where knowing the minimum set of independent variables still leaves more than one feasible kinematic configuration.

  • 2.

    feqf_{eq}: An equality factor, used to impose a soft constraint between state vectors consecutive in time. The rationale behind this factor is to impose a soft constraint, which can be easily violated (its weight is small in comparison to all other factors) but still provides a solid starting point for nonlinear numerical solvers to exploit the fact that mechanism coordinates cannot vary abruptly between consecutive time steps. This factor is particularly important to solve ambiguities in mechanisms with more than one branch, exactly as argued by the end of the former paragraph.

  • 3.

    fdynif^{i}_{dyn}: The independent-coordinate version of fdyndf^{d}_{dyn} discussed above, it implements the dynamics equation of motion.

  • 4.

    fpcif^{i}_{pc}, fvcif^{i}_{vc}: Like their dependent-coordinate counterparts in the former section, these factors keep the position and velocity vector within their corresponding constraint manifolds. Note how, in this case, the factors not only affect 𝐪{\mathbf{q}} and 𝐪˙{\dot{\mathbf{q}}} coordinates, but their independent-coordinate versions 𝐳{\mathbf{z}} and 𝐳˙{\dot{\mathbf{z}}} too, respectively. These factors actually correspond to the so-called position problem and velocity problem in multibody mechanics [20].

5.3 FG for inverse dynamics in dependent coordinates

Refer to caption
Figure 4: Factor graph for the inverse dynamics problem using dependent generalized coordinates. See discussion in section 5.3.

Another problem that can be formalized as a FG is inverse dynamics, as shown in Figure 4. The problem consists of specifying a desired trajectory over time for the set of degrees of freedom of a mechanism, then solving for the required forces and torques to generate such trajectory. The following factors are used:

  • 1.

    fpriorf_{prior}: Here, different prior factors are used to define initial known values for the dynamic state (𝐪0{\mathbf{q}}_{0}, 𝐪˙0{\dot{\mathbf{q}}}_{0}) and to enforce a value of zero in all components of the generalized force vectors 𝐐i{\mathbf{Q}}_{i} where it is known that no external force is acting. In other words, the latter factors are required to leave only part of 𝐐i{\mathbf{Q}}_{i} as an unknown, e.g. for the degree of freedom where a motor is exerting a torque.

  • 2.

    fidyndf^{d}_{idyn}: Similar to the dynamics equation factor fdyndf^{d}_{dyn} discussed above, but with the force 𝐐i{\mathbf{Q}}_{i} as an additional variable. Note that fdyndf^{d}_{dyn} (see section 5.2) also used a value for 𝐐i{\mathbf{Q}}_{i} but it was treated as a known constant, whereas for fidyndf^{d}_{idyn} the 𝐐i{\mathbf{Q}}_{i} are unknowns and as such the factor provides a Jacobian of the error term with respect to them as well.

From all discussed problems so far, inverse dynamics is the hardest to solve for nonlinear iterative solvers from initial values that are far from the optimum. Therefore, it requires a proper initialization strategy to enable numerical nonlinear solvers to cope with it effectively, as discussed in the experiments section later on.

6 Factors definition

In a factor graph, factors establish the relations between variables. This section provides an insightful practical guide to those factors MBS problems are made of.

Each factor defines an error 𝐞(𝐱)\mathbf{e}(\mathbf{x}) between predicted and measured data. To apply nonlinear optimization algorithms (e.g. Gauss-Newton or Levenberg-Marquardt), the Jacobian of such error with respect to all involved variables 𝐱\mathbf{x} is required. DBN variables whose values are known do not become FG nodes and hence are constant parameters of factors. The goal of the optimization is to search for the best values of all variables 𝐱\mathbf{x}^{\star} taking the weighted sum of error functions (one per factor) as close to zero as possible:

𝐱=argmin𝐱i𝐞i(𝐱)𝚺2\mathbf{x}^{\star}=\arg\min_{\mathbf{x}}\sum_{i}\left\lVert\mathbf{e}_{i}(\mathbf{x})\right\rVert^{2}_{\boldsymbol{\Sigma}} (19)

where 𝐞i(𝐱)𝚺2\left\lVert\mathbf{e}_{i}(\mathbf{x})\right\rVert^{2}_{\boldsymbol{\Sigma}} is a form of whitening already integrating the probabilistic noise model (or weight) of each factor. The most common model, used in the present work, is the assumption of additive zero mean Gaussian noise 𝐧𝒩(0,𝚺)\mathbf{n}\sim\mathcal{N}(\textbf{0},\boldsymbol{\Sigma}) with covariance matrix 𝚺\boldsymbol{\Sigma}. Taking the negative logarithm of the corresponding probability density can be shown to give us the nonlinear least-squares problem in Eq.(19), where

𝐞(𝐱)𝚺2=12𝐞(𝐱)𝚲𝐞(𝐱)\left\lVert\mathbf{e}(\mathbf{x})\right\rVert^{2}_{\boldsymbol{\Sigma}}=\frac{1}{2}\mathbf{e}(\mathbf{x})^{\top}\boldsymbol{\Lambda}\mathbf{e}(\mathbf{x}) (20)

with information matrix 𝚲=𝚺1\boldsymbol{\Lambda}=\boldsymbol{\Sigma}^{-1}. Larger information values in 𝚲\boldsymbol{\Lambda} (or smaller variances in 𝚺\boldsymbol{\Sigma}) imply that the factor must be considered with a higher weight during the optimization in comparison to other factors with smaller information values (or larger variances). Note that each component of multidimensional 𝐱\mathbf{x} vectors may have a different weight for a given single factor, e.g. as proposed in the priors over external forces in section 5.3. The interested reader is deferred to [23] for a more in-depth discussion on this topic.

In the following, note the use of the superscripts fdf^{d}_{\cdot} and fif^{i}_{\cdot} for factors with differentiated implementations for dependent and independent-coordinates, respectively.

6.1 fpriorf_{prior}: Prior factor

Prior factors fprior(𝐱)f_{prior}(\mathbf{x}) over a variable 𝐱\mathbf{x} are the only unary factor used in our proposed graphs. They represent a priori belief (hence the name) about the state of a given variable.

Since the problems addressed in this manuscript use variables that are either (a) state vectors with generalized coordinates of planar mechanisms, or (b) their velocities or (c) their accelerations, all variables can be treated as vectors in the group of real numbers, hence the error function 𝐞()\mathbf{e}(\cdot) of this factor for a vector of dimensionality dd has a simple form:

fprior error function:&𝐞(𝐱)=𝐱𝐱0Variables:𝐱Fixed parameters:𝐱0Jacobian:𝐞𝐱=𝐈d\text{$f_{prior}$ error function:}&\mathbf{e}(\mathbf{x})=\mathbf{x}-\mathbf{x}_{0}\\ \text{Variables:}\mathbf{x}\\ \text{Fixed parameters:}\mathbf{x}_{0}\\ \text{Jacobian:}\dfrac{\partial\mathbf{e}}{\partial\mathbf{x}}=\mathbf{I}_{d} (21)

where 𝐱0\mathbf{x}_{0} is the “desired” value for the variable 𝐱\mathbf{x}.

Refer to caption
(a) Euler integration.
Refer to caption
(b) Trapezoidal integration.
Refer to caption
(c) Position constraints
Refer to caption
(d) Velocity constraints
Figure 5: (a)–(b) Numerical integration factors discussed in sections 6.2-6.3. Factors used to enforce 𝐪{\mathbf{q}} and 𝐪˙{\dot{\mathbf{q}}} to remain within their corresponding manifolds: (c) holonomic position constraints, (b) velocity constraints (see sections 6.4-6.5).

6.2 feif_{ei}: Euler integrator factor

The graphs proposed in former sections work over temporal sequences of variables, sampled at a fixed sample rate fs=1/Δtf_{s}=1/\Delta t. Imposing the continuity of ordinary differential equations in discrete time can be done by means of numerical integration, of which the Euler integrator is the simplest instance.

Given two consecutive samples for time steps tt and t+1t+1 of a given variable 𝐱\mathbf{x} and its time derivative 𝐱˙\dot{\mathbf{x}} at time tt, the Euler integrator factor feif_{ei} (shown in Figure 5(a)) can be defined as:

fei error function:&𝐞(𝐱t,𝐱t+1,𝐱˙t)=𝐱t+1𝐱tΔt𝐱˙tVariables:𝐱t,𝐱t+1,𝐱˙tFixed parameters:ΔtJacobians:𝐞𝐱t=𝐈d𝐞𝐱t+1=𝐈d𝐞𝐱˙t=Δt𝐈d\text{$f_{ei}$ error function:}&\mathbf{e}(\mathbf{x}_{t},\mathbf{x}_{t+1},\dot{\mathbf{x}}_{t})=\mathbf{x}_{t+1}-\mathbf{x}_{t}-\Delta t\dot{\mathbf{x}}_{t}\\ \text{Variables:}\mathbf{x}_{t},\mathbf{x}_{t+1},\dot{\mathbf{x}}_{t}\\ \text{Fixed parameters:}\Delta t\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial\mathbf{x}_{t}}=-\mathbf{I}_{d}\quad\dfrac{\partial\mathbf{e}}{\partial\mathbf{x}_{t+1}}=\mathbf{I}_{d}\quad\dfrac{\partial\mathbf{e}}{\partial\dot{\mathbf{x}}_{t}}=-\Delta t\mathbf{I}_{d} (22)

where the state space is assumed to be d\mathbb{R}^{d}.

6.3 ftif_{ti}: Trapezoidal integrator factor

Another well-known numerical integration scheme follows the Trapezoidal Rule. Given two consecutive samples for time steps tt and t+1t+1, both for a given variable 𝐱\mathbf{x} and its time derivative 𝐱˙\dot{\mathbf{x}}, the Trapezoidal integrator factor ftif_{ti}, shown in Figure 5(b), can be defined as:

fti error function:&𝐞(𝐱t,𝐱t+1,𝐱˙t,𝐱˙t+1)=𝐱t+1𝐱tΔt2𝐱˙tΔt2𝐱˙t+1Variables:𝐱t,𝐱t+1,𝐱˙t,𝐱˙t+1Fixed parameters:ΔtJacobians:𝐞𝐱t=𝐈d𝐞𝐱t+1=𝐈d𝐞𝐱˙t=Δt2𝐈d𝐞𝐱˙t+1=Δt2𝐈d\text{$f_{ti}$ error function:}&\mathbf{e}(\mathbf{x}_{t},\mathbf{x}_{t+1},\dot{\mathbf{x}}_{t},\dot{\mathbf{x}}_{t+1})=\mathbf{x}_{t+1}-\mathbf{x}_{t}-\dfrac{\Delta t}{2}\dot{\mathbf{x}}_{t}-\dfrac{\Delta t}{2}\dot{\mathbf{x}}_{t+1}\\ \text{Variables:}\mathbf{x}_{t},\mathbf{x}_{t+1},\dot{\mathbf{x}}_{t},\dot{\mathbf{x}}_{t+1}\\ \text{Fixed parameters:}\Delta t\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial\mathbf{x}_{t}}=-\mathbf{I}_{d}\quad\dfrac{\partial\mathbf{e}}{\partial\mathbf{x}_{t+1}}=\mathbf{I}_{d}\quad\dfrac{\partial\mathbf{e}}{\partial\dot{\mathbf{x}}_{t}}=-\dfrac{\Delta t}{2}\mathbf{I}_{d}\quad\dfrac{\partial\mathbf{e}}{\partial\dot{\mathbf{x}}_{t+1}}=-\dfrac{\Delta t}{2}\mathbf{I}_{d} (23)

As mentioned in section 5.1, this integrator is preferred for its better accuracy in comparison to the Euler method.

6.4 fpcdf^{d}_{pc}: Factor for position constraints in dependent coordinates

This factor, depicted in Figure 5(c), ensures the fulfillment of mechanical holonomic constraints of Eq. (1). As explained in Section 2.1, modeling a mechanism in dependent coordinates leads to a number of constraint equations largest or equal to the number of generalized coordinates.

This factor has the following general form:

fpcd error function:&𝐞(𝐪t)=𝚽(𝐪t)Variables:𝐪tFixed parameters:(constant distances, angles, etc.)
Jacobians:
𝐞𝐪t
=𝚽𝐪(𝐪t)
\text{$f^{d}_{pc}$ error function:}&\mathbf{e}({\mathbf{q}}_{t})={\boldsymbol{\Phi}}({\mathbf{q}}_{t})\\ \text{Variables:}{\mathbf{q}}_{t}\\ \text{Fixed parameters:}\text{(constant distances, angles, etc.)}\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\mathbf{\Phi_{q}}\left({\mathbf{q}}_{t}\right)
(24)

where both 𝚽{\boldsymbol{\Phi}} and 𝚽𝐪\mathbf{\Phi_{q}} can be automatically built out of pre-designed blocks (see Appendix III), according to a formal description of the topology of the mechanical system and the specific joints connecting each pair of adjacent bodies. In particular, since each physical constraint becomes one or more entries in the 𝚽(𝐪){\boldsymbol{\Phi}}({\mathbf{q}}) vector, each such constraint fully determines the corresponding rows in the Jacobian 𝚽𝐪(𝐪)\mathbf{\Phi_{q}}({\mathbf{q}}), easing its automated construction from the elemental expressions exposed in Appendix III.

6.5 fvcdf^{d}_{vc}: Factor for velocity constraints in dependent coordinates

Velocity constraint factors further improve the quality of MBS simulation. These kind of factors are modeled by Eq. (2) and depend on both, 𝐪{\mathbf{q}} and 𝐪˙{\dot{\mathbf{q}}}, as illustrated Figure 5(d). Its definition is as follows:

fvcd error function:&𝐞(𝐪t,𝐪˙t)=𝚽𝐪(𝐪t)𝐪˙tΦt(𝐪t)0=𝚽𝐪(𝐪t)𝐪˙tVariables:𝐪t,𝐪˙tFixed parameters:(constant distances, angles, etc.)
Jacobians:
𝐞𝐪t
=𝚽𝐪(𝐪t)𝐪˙t𝐪t
𝐞𝐪˙t=𝚽𝐪(𝐪t)
\text{$f^{d}_{vc}$ error function:}&\mathbf{e}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t})=\mathbf{\Phi_{q}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}-\cancelto{0}{\Phi_{t}({\mathbf{q}}_{t})}=\mathbf{\Phi_{q}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}\\ \text{Variables:}{\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t}\\ \text{Fixed parameters:}\text{(constant distances, angles, etc.)}\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\dfrac{\partial\mathbf{\Phi_{q}}\left({\mathbf{q}}_{t}\right){\dot{\mathbf{q}}}_{t}}{\partial{\mathbf{q}}_{t}}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{q}}}_{t}}=\mathbf{\Phi_{q}}({\mathbf{q}}_{t})
(25)

where we assumed that no constraint depends explicitly on time, hence 𝚽t(𝐪t){\boldsymbol{\Phi}}_{t}({\mathbf{q}}_{t}) can be safely neglected. Again, each row in the Jacobians comes from exactly one constraint in the definition of the mechanical system, with most common cases described in Appendix III.

6.6 fdyndf^{d}_{dyn}, fidyndf^{d}_{idyn} and fdynif^{i}_{dyn}, fidynif^{i}_{idyn}: Factors for dynamics

These factors minimize the error between the actual acceleration estimates (𝐪¨{\ddot{\mathbf{q}}} and 𝐳¨{\ddot{\mathbf{z}}}) and the corresponding equations of motion Eq. (6) and Eq. (15) for dependent and independent coordinates, respectively. To deal both forward and inverse dynamics, this factor connects the generalized positions, velocities, and accelerations with the forces (𝐐t{\mathbf{Q}}_{t}) for each single time step tt. In the case of forward dynamics, both the variable 𝐐t{\mathbf{Q}}_{t} and the edge connecting it to the factor are dropped, becoming 𝐐t{\mathbf{Q}}_{t} an internal known parameter to the factor. For this reason, two factors for forward and inverse dynamics must be defined independently:

  • 1.

    Forward dynamics

    For dependent coordinates:

    fdynd error function:&𝐞(𝐪t,𝐪˙t,𝐪¨t)=𝐪¨(𝐪t,𝐪˙t)𝐪¨tVariables:𝐪t,𝐪˙t,𝐪¨tFixed parameters:(masses, external forces)Jacobians:𝐞𝐪t=𝐪¨(𝐪t,𝐪˙t)𝐪t𝐞𝐪˙t=𝐪¨(𝐪t,𝐪˙t)𝐪˙t𝐞𝐪¨t=𝐈\text{$f^{d}_{dyn}$ error function:}&\mathbf{e}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\ddot{\mathbf{q}}}_{t})={\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t})-{\ddot{\mathbf{q}}}_{t}\\ \text{Variables:}{\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\ddot{\mathbf{q}}}_{t}\\ \text{Fixed parameters:}(\text{masses, external forces})\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\dfrac{\partial{\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t})}{\partial{\mathbf{q}}_{t}}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{q}}}_{t}}=\dfrac{\partial{\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t})}{\partial{\dot{\mathbf{q}}}_{t}}\quad\quad\dfrac{\partial\mathbf{e}}{\partial{\ddot{\mathbf{q}}}_{t}}=-\mathbf{I} (26)

    and for independent coordinates:

    fdyni error function:&𝐞(𝐳t,𝐳˙t,𝐳¨t)=𝐳¨(𝐳t,𝐳˙t)𝐳¨tVariables:𝐳t,𝐳˙t,𝐳¨tFixed parameters:(masses, external forces)Jacobians:𝐞𝐳t=𝐳¨(𝐳t,𝐳˙t)𝐳t𝐞𝐳˙t=𝐳¨(𝐳t,𝐳˙t)𝐳˙t𝐞𝐳¨t=𝐈\text{$f^{i}_{dyn}$ error function:}&\mathbf{e}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\ddot{\mathbf{z}}}_{t})={\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t})-{\ddot{\mathbf{z}}}_{t}\\ \text{Variables:}{\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\ddot{\mathbf{z}}}_{t}\\ \text{Fixed parameters:}(\text{masses, external forces})\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{z}}_{t}}=\dfrac{\partial{\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t})}{\partial{\mathbf{z}}_{t}}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{z}}}_{t}}=\dfrac{\partial{\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t})}{\partial{\dot{\mathbf{z}}}_{t}}\quad\quad\dfrac{\partial\mathbf{e}}{\partial{\ddot{\mathbf{z}}}_{t}}=-\mathbf{I} (27)
  • 2.

    Inverse dynamics

    For dependent coordinates:

    fdynd error function:&𝐞(𝐪t,𝐪˙t,𝐪¨t,𝐐t)=𝐪¨(𝐪t,𝐪˙t,𝐐t)𝐪¨tVariables:𝐪t,𝐪˙t,𝐪¨t,𝐐tFixed parameters:(masses)Jacobians:𝐞𝐪t=𝐪¨(𝐪t,𝐪˙t,𝐐t)𝐪t𝐞𝐪˙t=𝐪¨(𝐪t,𝐪˙t,𝐐t)𝐪˙t𝐞𝐪¨t=𝐈𝐞𝐐t=𝐪¨(𝐪t,𝐪˙t,𝐐t)𝐐t\text{$f^{d}_{dyn}$ error function:}&\mathbf{e}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\ddot{\mathbf{q}}}_{t},{\mathbf{Q}}_{t})={\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\mathbf{Q}}_{t})-{\ddot{\mathbf{q}}}_{t}\\ \text{Variables:}{\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\ddot{\mathbf{q}}}_{t},{\mathbf{Q}}_{t}\\ \text{Fixed parameters:}(\text{masses})\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\dfrac{\partial{\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\mathbf{Q}}_{t})}{\partial{\mathbf{q}}_{t}}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{q}}}_{t}}=\dfrac{\partial{\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\mathbf{Q}}_{t})}{\partial{\dot{\mathbf{q}}}_{t}}\\ \dfrac{\partial\mathbf{e}}{\partial{\ddot{\mathbf{q}}}_{t}}=-\mathbf{I}\quad\dfrac{\partial\mathbf{e}}{\partial{\mathbf{Q}}_{t}}=\dfrac{\partial{\ddot{\mathbf{q}}}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\mathbf{Q}}_{t})}{\partial{\mathbf{Q}}_{t}} (28)

    and for independent coordinates:

    fdyni error function:&𝐞(𝐳t,𝐳˙t,𝐳¨t,𝐐t)=𝐳¨(𝐳t,𝐳˙t,𝐐t)𝐳¨tVariables:𝐳t,𝐳˙t,𝐳¨t,𝐐tFixed parameters:(masses)Jacobians:𝐞𝐳t=𝐳¨(𝐳t,𝐳˙t,𝐐t)𝐳t𝐞𝐳˙t=𝐳¨(𝐳t,𝐳˙t,𝐐t)𝐳˙t𝐞𝐳¨t=𝐈𝐞𝐐t=𝐳¨(𝐳t,𝐳˙t,𝐐t)𝐐t\text{$f^{i}_{dyn}$ error function:}&\mathbf{e}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\ddot{\mathbf{z}}}_{t},{\mathbf{Q}}_{t})={\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\mathbf{Q}}_{t})-{\ddot{\mathbf{z}}}_{t}\\ \text{Variables:}{\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\ddot{\mathbf{z}}}_{t},{\mathbf{Q}}_{t}\\ \text{Fixed parameters:}(\text{masses})\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{z}}_{t}}=\dfrac{\partial{\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\mathbf{Q}}_{t})}{\partial{\mathbf{z}}_{t}}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{z}}}_{t}}=\dfrac{\partial{\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\mathbf{Q}}_{t})}{\partial{\dot{\mathbf{z}}}_{t}}\\ \dfrac{\partial\mathbf{e}}{\partial{\ddot{\mathbf{z}}}_{t}}=-\mathbf{I}\quad\dfrac{\partial\mathbf{e}}{\partial{\mathbf{Q}}_{t}}=\dfrac{\partial{\ddot{\mathbf{z}}}({\mathbf{z}}_{t},{\dot{\mathbf{z}}}_{t},{\mathbf{Q}}_{t})}{\partial{\mathbf{Q}}_{t}} (29)

Refer to Eq. (6) and Eq. (15) for the evaluation of the error functions above. Numerical Jacobians have been used in our implementation for Eq. (28) and Eq. (29), since exact closed-form Jacobians are so complex than the computational advantage of having closed-form expressions. In this particular case is not clear and deserves future analysis.

6.7 fpcif^{i}_{pc}: Factor for position constraints in independent coordinates

Figure 3 shows three sets of factors linking dependent coordinates (position, velocities, and accelerations) with their corresponding degrees of freedom, that is, with their counterparts in independent coordinates. The first one of these factor is fpcif^{i}_{pc}, in charge of imposing the simultaneous fulfillment of: (a) position constraints in 𝚽(𝐪){\boldsymbol{\Phi}}({\mathbf{q}}), and (b) that independent coordinates 𝐳{\mathbf{z}} are integrated into its corresponding positions within 𝐪{\mathbf{q}}. Therefore, its error function and Jacobians read:

fpci error function:&𝐞(𝐪t,𝐳t)=[𝚽(𝐪t)𝐪t({idxs})𝐳t](m+d)×1Variables:𝐪t,𝐳tFixed parameters:{idxs}, constant distances, angles, etc.
Jacobians:
𝐞𝐪t
=[𝚽𝐪(𝐪t)𝐈idxs](m+d)×n
𝐞𝐳t=[𝟎m×d𝐈d](m+d)×d
\text{$f^{i}_{pc}$ error function:}&\mathbf{e}({\mathbf{q}}_{t},{\mathbf{z}}_{t})=\begin{bmatrix}{\boldsymbol{\Phi}}({\mathbf{q}}_{t})\\ {\mathbf{q}}_{t}(\{idxs\})-{\mathbf{z}}_{t}\end{bmatrix}_{(m+d)\times 1}\\ \text{Variables:}{\mathbf{q}}_{t},{\mathbf{z}}_{t}\\ \text{Fixed parameters:}\{idxs\}\text{, constant distances, angles, etc.}\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\begin{bmatrix}\mathbf{\Phi_{q}}\left({\mathbf{q}}_{t}\right)\\ \mathbf{I}_{idxs}\end{bmatrix}_{(m+d)\times n}\quad\dfrac{\partial\mathbf{e}}{\partial{\mathbf{z}}_{t}}=\begin{bmatrix}\mathbf{0}_{m\times d}\\ -\mathbf{I}_{d}\\ \end{bmatrix}_{(m+d)\times d}
(30)

where {idxs}={y1,y2,,yd}\{idxs\}=\{y_{1},y_{2},...,y_{d}\} stands for the fixed sequence of indices of each 𝐳{\mathbf{z}} coordinate inside the nn-vector 𝐪{\mathbf{q}}, and the coefficients Ii,jI_{i,j} of the binary matrix 𝐈idxs\mathbf{I}_{idxs} are defined as 11 if j=yij=y_{i}, or as 0 otherwise, where i=1,,di={1,...,d} and j=1,,nj={1,...,n}.

6.8 fvcif^{i}_{vc}: Factor for velocity constraints in independent coordinates

This factor ensures the fulfillment of the velocity constraints for independent coordinates:

fvci error function:&𝐞(𝐪t,𝐪˙t,𝐳˙t)=[𝚽𝐪(𝐪t)𝐪˙t𝐪˙t({idxs})𝐳˙t](m+d)×1Variables:𝐪t,𝐪˙t,𝐳˙tFixed parameters:{idxs}, constant distances, angles, etc.
Jacobians:
𝐞𝐪t
=[𝚽𝐪𝐪(𝐪t)𝐪˙t𝟎d×n](m+d)×n
𝐞𝐪˙t=[𝚽𝐪(𝐪t)𝐈idx](m+d)×n𝐞𝐳˙t=[𝟎m×d𝐈d](m+d)×d
\text{$f^{i}_{vc}$ error function:}&\mathbf{e}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\dot{\mathbf{z}}}_{t})=\begin{bmatrix}\mathbf{\Phi_{q}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}\\ {\dot{\mathbf{q}}}_{t}(\{idxs\})-{\dot{\mathbf{z}}}_{t}\end{bmatrix}_{(m+d)\times 1}\\ \text{Variables:}{\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\dot{\mathbf{z}}}_{t}\\ \text{Fixed parameters:}\{idxs\}\text{, constant distances, angles, etc.}\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\begin{bmatrix}\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}\\ \mathbf{0}_{d\times n}\end{bmatrix}_{(m+d)\times n}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{q}}}_{t}}=\begin{bmatrix}\mathbf{\Phi_{q}}({\mathbf{q}}_{t})\\ \mathbf{I}_{idx}\end{bmatrix}_{(m+d)\times n}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{z}}}_{t}}=\begin{bmatrix}\mathbf{0}_{m\times d}\\ -\mathbf{I}_{d}\\ \end{bmatrix}_{(m+d)\times d}
(31)

where the tensor-vector product 𝚽𝐪𝐪𝐪˙t\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}{\dot{\mathbf{q}}}_{t} results in the 2-D matrix 𝚽˙𝐪\dot{{\boldsymbol{\Phi}}}_{\mathbf{q}} (see Eq. (42)) which can be systematically built row by row from a description of the mechanism from the building blocks described in Appendix III.

6.9 facif^{i}_{ac}: Factor for acceleration constraints in independent coordinates

This factor ensures the fulfillment of the acceleration constraints for independent coordinates:

fvci error function:&𝐞(𝐪t,𝐪˙t,𝐪¨t,𝐳¨t)=[𝚽˙𝐪(𝐪t)𝐪˙t+𝚽𝐪(𝐪t)𝐪¨t𝐪¨t({idxs})𝐳¨t](m+d)×1Variables:𝐪t,𝐪˙t,𝐪¨t,𝐳¨tFixed parameters:(constant distances, angles, etc.)
Jacobians:
𝐞𝐪t
=[(𝚽˙𝐪)𝐪(𝐪t)𝐪˙t+𝚽𝐪𝐪(𝐪t)𝐪¨t𝟎d×n](m+d)×n
𝐞𝐪˙t=[2𝚽𝐪𝐪(𝐪t)𝐪˙t𝟎d×n](m+d)×n𝐞𝐪¨t=[𝚽𝐪(𝐪t)𝐈idx](m+d)×n
𝐞𝐳¨t=[𝟎m×d𝐈d](m+d)×d
\text{$f^{i}_{vc}$ error function:}&\mathbf{e}({\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\ddot{\mathbf{q}}}_{t},{\ddot{\mathbf{z}}}_{t})=\begin{bmatrix}\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}+\mathbf{\Phi_{q}}({\mathbf{q}}_{t}){\ddot{\mathbf{q}}}_{t}\\ {\ddot{\mathbf{q}}}_{t}(\{idxs\})-{\ddot{\mathbf{z}}}_{t}\end{bmatrix}_{(m+d)\times 1}\\ \text{Variables:}{\mathbf{q}}_{t},{\dot{\mathbf{q}}}_{t},{\ddot{\mathbf{q}}}_{t},{\ddot{\mathbf{z}}}_{t}\\ \text{Fixed parameters:}\text{(constant distances, angles, etc.)}\\ \text{Jacobians:}\dfrac{\partial\mathbf{e}}{\partial{\mathbf{q}}_{t}}=\begin{bmatrix}(\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}+\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}({\mathbf{q}}_{t}){\ddot{\mathbf{q}}}_{t}\\ \mathbf{0}_{d\times n}\end{bmatrix}_{(m+d)\times n}\quad\dfrac{\partial\mathbf{e}}{\partial{\dot{\mathbf{q}}}_{t}}=\begin{bmatrix}2\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}\\ \mathbf{0}_{d\times n}\end{bmatrix}_{(m+d)\times n}\\ \dfrac{\partial\mathbf{e}}{\partial{\ddot{\mathbf{q}}}_{t}}=\begin{bmatrix}\mathbf{\Phi_{q}}({\mathbf{q}}_{t})\\ \mathbf{I}_{idx}\end{bmatrix}_{(m+d)\times n}\quad\dfrac{\partial\mathbf{e}}{\partial{\ddot{\mathbf{z}}}_{t}}=\begin{bmatrix}\mathbf{0}_{m\times d}\\ -\mathbf{I}_{d}\\ \end{bmatrix}_{(m+d)\times d}
(32)

where the tensor-vector products (𝚽˙𝐪)𝐪(𝐪t)𝐪˙t(\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}({\mathbf{q}}_{t}){\dot{\mathbf{q}}}_{t}, 𝚽𝐪𝐪𝐪¨t\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}{\ddot{\mathbf{q}}}_{t}, and 2𝚽𝐪𝐪𝐪˙t=2𝚽˙𝐪2\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}{\dot{\mathbf{q}}}_{t}=2\dot{{\boldsymbol{\Phi}}}_{\mathbf{q}} can be systematically built as described in Appendix III.

7 Test case validation

A four-bar linkage is employed to exemplify the implementation and the performance of the proposed FG-based framework. A scheme of the mechanism is shown in Figure 6(a), where the two revolute joints, P1P_{1} and P2P_{2}, can move in the motion plane, whereas AA and DD are fixed. Geometric and inertial properties are summarized in Figure 6(b). The motion of the mechanism has been simulated using the commercial MBS environment Adams/View from MSC.Software with a fixed-step integrator at 1/101/10 of the time step used in the factor graph, hence its results can be considered the ground-truth for comparison purposes.

A companion open-source reference C++ implementation111In https://github.com/MBDS/multibody-state-estimation of the proposed factor graph approach has been released along with the paper. Note that all factor closed-form Jacobians have been thoroughly validated by means of unit tests against numerical finite differences.

Refer to caption
(a)
L1L_{1} 1.0 [m]
L2L_{2} 2.0 [m]
L3L_{3} 13\sqrt{13} [m]
m1m_{1} 1.0 [kg]
m2m_{2} 2.0 [kg]
m3m_{3} 4.0 [kg]
Ii,gI_{i,g} 112miLi2\frac{1}{12}m_{i}L_{i}^{2} [kg m2\text{m}^{2}]
(b)
Figure 6: (a) The planar mechanism used in the numeric simulations described in section 7. (b) Table of mechanism properties (length and mass) for each link. Inertias IiI_{i} are given with respect to the center of mass of each link, placed at its center.
Refer to caption
(a) Comparison of 𝐪{\mathbf{q}} series.
Refer to caption
(b) Comparison of 𝐪˙{\dot{\mathbf{q}}} series.
Refer to caption
(c) Error in 𝐪{\mathbf{q}}.
Refer to caption
(d) Error in 𝐪˙{\dot{\mathbf{q}}}.
Figure 7: Simulation-based validation of the proposed FG approach to forward dynamics for a four-bar linkage under the effects of gravity. Generalized coordinates (a) and velocities (b) are shown for our approach (using a fixed-lag smoother with Nw=2N_{w}=2, time step of 1 ms) and for MSC.ADAMS as ground truth. (c) and (d) show the error as the difference between ground truth and the output of the proposed FG-based method. Overall RMSE for this case are 0.0024\approx 0.0024 m and 0.021\approx 0.021 m/s for 𝐪{\mathbf{q}} and 𝐪˙{\dot{\mathbf{q}}}, respectively. See discussion in section 7.1.

7.1 Forward dynamic simulation

Free motion of the four-bar mechanism under the sole effect of gravity (g=9.8m/s2g=9.8~{}\text{m}/\text{s}^{2}) has been simulated, with an initial crank angle θ\theta (refer to Figure 6(a)) of zero and null initial velocities.

The FG in Figure 2 using dependent coordinates has been implemented, and then solved numerically in an incremental fashion using a fixed-lag smoother, when only the factors of the last NwN_{w} time steps (the window length) up to time tt are considered, with discrete time tt ranging from 0 up to 55 seconds with steps of dt=1msdt=1~{}\text{ms}. A Levenberg-Marquardt nonlinear iterative solver algorithm has been selected for these runs, with a maximum number of iterations of 15. Note, however, that virtually all calls to the optimizer required only 3 to 5 iterations until convergence.

Figure 7(a)–(b) show the time history of the dependent generalized coordinates of points P1P_{1} and P2P_{2}, and their corresponding velocities, respectively, obtained from both, the proposed FG-based approach and from MSC Adams. Both series accurately coincide, hence a more detailed comparison is in order in Figure 7(c)–(d), where the differences in 𝐪{\mathbf{q}} and 𝐪˙{\dot{\mathbf{q}}} are reported between the proposed FG-based method and the ground truth. Similar good agreement (omitted for brevity’s sake) is obtained when adopting the independent coordinates FG, as explained in Figure 3, thus verifying our two proposed schemes. The noise models used in all factors involved are summarized in Table 2. Covariance absolute values are not relevant, only their relative weights with respect to each other.

In order to quantify the accuracy of both schemes (dependent and independent-based FGs) and to explore the effect of the fixed-lag window length parameter NwN_{w}, the root mean square error (RMSE) of the overall 𝐪{\mathbf{q}} trajectories are shown in Table 1 for window size varying from 22 to 1010 time steps. Two main conclusions can be drawn from these data: (a) the dependent-coordinates scheme seems to provide a higher accuracy, and (b) using window lengths larger than a few (3–4) time steps do not further increase the accuracy of the estimation. This latter point can be explained by the fact that the present simulations focus on forward dynamics only, not estimation from noisy sensor measurements, a case where it should be expected that larger windows lead to better results. This topic, however, falls out of the scope of the present paper and it should be studied in the future.

NwN_{w} DC FG IC FG
(timesteps)(timesteps) RMSE (m) RMSE (m)
2 0.002361 0.023834
3 0.002356 0.019645
4 0.002352 0.020019
5 0.002348 0.016647
6 0.002344 0.016677
7 0.002341 0.016677
8 0.002338 0.016677
9 0.002335 0.017056
10 0.002332 0.016677
Table 1: RMSE for 𝐪{\mathbf{q}} trajectories estimated by the dependent coordinates (DC) and independent coordinates (IC) factor graphs (FG) for the simulation described in the text, with respect to ground-truth, for different window lengths of the fixed-lag smoother estimator.
Factor Noise model
fprior(𝐪0)f_{prior}({\mathbf{q}}_{0}) 𝟎n×n\mathbf{0}_{n\times n}
fprior(𝐪0)f_{prior}({\mathbf{q}}_{0}) diag({103 if q(i)𝐳,1 otherwise}diag(\{10^{-3}\text{ if }q(i)\in{\mathbf{z}},~{}1\text{ otherwise}\}
ftif_{ti} 102𝐈n10^{-2}~{}\mathbf{I}_{n}
fdynd,fdynif^{d}_{dyn},f^{i}_{dyn} 104𝐈n10^{-4}~{}\mathbf{I}_{n}
fpcd,fvcdf^{d}_{pc},f^{d}_{vc} 𝟎m×m\mathbf{0}_{m\times m}
fpci,fvcif^{i}_{pc},f^{i}_{vc} 𝟎(m+d)×(m+d)\mathbf{0}_{(m+d)\times(m+d)}
feqf_{eq} 102𝐈n10^{2}~{}\mathbf{I}_{n}
Table 2: Noise models (covariance matrices) employed in the forward dynamics simulations. Most covariances represent isotropic models (those including the identity matrix 𝐈\mathbf{I}, or 𝟎\mathbf{0} for perfectly-known values), with only a few of them having different weights for different coordinates (those defined with a diag()diag(\cdots), a diagonal matrix with the given diagonal values).

7.2 Inverse dynamic simulation

Next, the FG proposed in Figure 4 for inverse dynamic calculation is put at test with the same four-bar mechanism described above. Here, the crank angle θ\theta trajectory over time is specified as an arbitrary smooth curve, and the goal is to solve for the unknown torque at the crank (point AA) that would be required to balance gravity and inertial forces as accurately following the prescribed path.

In this case, we use a Levenberg-Marquardt nonlinear solver on the FG in Figure 4 in batch mode, as opposite to filtering or fixed-lag smoother mode. However, the position-problem is strongly nonlinear, preventing solvers to find the global optimal of the whole FG in Figure 4 for arbitrary initial values for all variables. Instead, we propose attacking the inverse dynamics FG in the following four stages (running the batch optimizer once after each stage), which ensure that the global optimum is always easy to find by the nonlinear solver:

  • 1.

    Stage 1: Include 𝐪{\mathbf{q}} variables, prior factors for the desired trajectory (fpriorf_{prior}), position-constraint factors (fpcdf^{d}_{pc}), and soft equality factors (feqf_{eq}).

  • 2.

    Stage 2: Add variables 𝐪˙{\dot{\mathbf{q}}}, 𝐪¨{\ddot{\mathbf{q}}}, and numerical integration factors ftif_{ti}.

  • 3.

    Stage 3: Add velocity-constraint factors (fvcdf^{d}_{vc}).

  • 4.

    Stage 4: Add generalized force variables 𝐐{\mathbf{Q}} and inverse dynamics factors (fidyndf^{d}_{idyn}).

Numerical results for this approach are shown in Figure 8, where the trajectories prescribed and actually-followed by the mechanism crank are depicted in Figure 8(a) for both the proposed approach and the commercial software MSC ADAMS. Both methods successfully solve the inverse dynamics problem by finding the torque sequence in Figure 8(b). In this case, our method leads to an excellent stable following error (less than 1 milliradian), whereas MSC’s error seems to slowly grow over time, as shown in Figure 8(c).

Refer to caption
(a) Crank angle reference and simulated trajectories.
Refer to caption
(b) Computed actuator torque.
Refer to caption
(c) Tracking error of the crank angle.
Figure 8: Evaluation of the inverse dynamics test with a four-bar mechanism controlled with a torque at the input crank. Refer to discussion in section 7.2.

8 Conclusions and future works

This work has settled the theoretical bases for formulating kinematics and dynamics problems from computational mechanics in the form of factor graphs, and demonstrated the validity of our reference open-source implementation. The results showed the practical feasibility of the proposed approach and its accuracy in comparison with a commercial MBS software based on classical approaches. One additional advantage of our formalism lies at its excellent suitability to design state observers and parameter identification systems for arbitrary mechanical systems, ranging from robots to vehicles. This aspect will be part of future works.

Appendix I. Block matrix inversion lemma

This lemma implies that:

[𝐀𝐁𝐂𝐃]1=[𝐀1+𝐀1𝐁(𝐃𝐂𝐀1𝐁)1𝐂𝐀1𝐀1𝐁(𝐃𝐂𝐀1𝐁)1(𝐃𝐂𝐀1𝐁)1𝐂𝐀1(𝐃𝐂𝐀1𝐁)1]\begin{bmatrix}\mathbf{A}&&\mathbf{B}\\ \mathbf{C}&&\mathbf{D}\end{bmatrix}^{-1}=\begin{bmatrix}\mathbf{A}^{-1}+\mathbf{A}^{-1}\mathbf{B}\left(\mathbf{D}-\mathbf{C}\mathbf{A}^{-1}\mathbf{B}\right)^{-1}\mathbf{C}\mathbf{A}^{-1}&&-\mathbf{A}^{-1}\mathbf{B}\left(\mathbf{D}-\mathbf{C}\mathbf{A}^{-1}\mathbf{B}\right)^{-1}\\ -\left(\mathbf{D}-\mathbf{C}\mathbf{A}^{-1}\mathbf{B}\right)^{-1}\mathbf{C}\mathbf{A}^{-1}&&\left(\mathbf{D}-\mathbf{C}\mathbf{A}^{-1}\mathbf{B}\right)^{-1}\end{bmatrix} (33)

Appendix II. Tensor notation definitions and useful expressions

Order of a tensor: Number of indices to index all its components, i.e. Scalars, vectors, and matrices are 0th, 1st, and 2nd-order tensors, respectively.

Einstein convention: Superscript indices imply reading elements up-down, subscript indices imply reading left-right. Summation works over the repeated index or indices. Example with a common matrix product:

𝐂=𝐀𝐁{Conventional notation:Cik=jAijBjkEinstein convention:Ci=kAiBjjk\displaystyle\mathbf{C}=\mathbf{AB}\Rightarrow\left\{\begin{array}[]{lc}\text{Conventional notation:}&C_{ik}=\sum_{j}A_{ij}B_{jk}\\ \text{Einstein convention:}&C^{i}{}_{k}=A^{i}{}_{j}B^{j}{}_{k}\end{array}\right. (36)

Transpose rule: We have that Ai=j(A)jiA^{i}{}_{j}=(A^{\top})^{j}{}_{i}.

Jacobian: 𝐱𝐲\frac{\partial\mathbf{x}}{\partial\mathbf{y}}, assuming 𝐱\mathbf{x} and 𝐲\mathbf{y} are a row and a column vector, respectively, becomes:

𝐱𝐲=xiyj=Δij\displaystyle\frac{\partial\mathbf{x}}{\partial\mathbf{y}}=\frac{\partial x_{i}}{\partial y_{j}}=\Delta_{i}{}^{j} (37)

The standard derivative chain rule: Applied to vector variables 𝐱\mathbf{x} and 𝐳\mathbf{z}, using an intermediary variable 𝐲\mathbf{y}, can be put in tensor notation as:

𝐱𝐲=xizk|ni×nk=xiyjyjzk=Δijni×njΔjknj×nkjxiyjyjzk\displaystyle\frac{\partial\mathbf{x}}{\partial\mathbf{y}}=\left.\frac{\partial x_{i}}{\partial z_{k}}\right|_{n_{i}\times n_{k}}=\frac{\partial x_{i}}{\partial y_{j}}\frac{\partial y_{j}}{\partial z_{k}}=\underbrace{\Delta^{i}{}_{j}}_{n_{i}\times n_{j}}\underbrace{\Delta^{j}{}_{k}}_{n_{j}\times n_{k}}\equiv\sum_{j}\frac{\partial x_{i}}{\partial y_{j}}\frac{\partial y_{j}}{\partial z_{k}} (38)

Chain rule for derivatives of matrices with respect to a vector: It gives us the third-order tensor:

𝐀𝐳\displaystyle\frac{\partial\mathbf{A}}{\partial\mathbf{z}} =\displaystyle= Aijzkni×nj×nk=Aijylni×nj×nlylzknl×nk\displaystyle\underbrace{\frac{\partial A^{i}{}_{j}}{\partial z_{k}}}_{n_{i}\times n_{j}\times n_{k}}=\underbrace{\frac{\partial A^{i}{}_{j}}{\partial y_{l}}}_{n_{i}\times n_{j}\times n_{l}}\underbrace{\frac{\partial y_{l}}{\partial z_{k}}}_{n_{l}\times n_{k}} (39)

where it becomes clear that we must sum over the ll indices, that is, converting the Einstein notation above into a conventional summation:

𝐀𝐳\displaystyle\frac{\partial\mathbf{A}}{\partial\mathbf{z}} =\displaystyle= l𝐀ylni×nj×nlyl𝐳nl×nk\displaystyle\sum_{l}\underbrace{\frac{\partial\mathbf{A}}{\partial y_{l}}}_{n_{i}\times n_{j}\times n_{l}}\underbrace{\frac{\partial y_{l}}{\partial\mathbf{z}}}_{n_{l}\times n_{k}} (40)

Product of a third-order tensor and a vector: Given a third-order tensor 𝐓=Tijk\mathbf{T}=T^{i}_{j}{~{}}^{k} and a vector 𝐯=vk\mathbf{v}=v_{k}, its product reads:

𝐓𝐯=Tijkvk=kTjivkk\mathbf{T}\mathbf{v}=T^{i}_{j}{~{}}^{k}~{}v_{k}=\sum_{k}T^{i}_{j}{}^{k}v_{k} (41)

Appendix III. Equations for planar multibody systems

In the following, we summarize the equations implemented in our open-source library to model typical mechanical constraints of planar mechanisms. These equations are the building blocks of the errors and Jacobian matrices associated with the factors described in sections 6.4-6.5. An open-source implementation of all these equations is provided in the C++ toolkit mentioned in section 7.

Since each constraint contributes only a few scalar components to 𝚽{\boldsymbol{\Phi}} (typically only one for planar mechanisms), the following uses the superscript 𝚽k{\boldsymbol{\Phi}}^{k} to reflect the kk-th row in the corresponding vector or matrix, with kk being arbitrarily determined by the order in which constraints are enumerated when defining a mechanism. Furthermore, for the sake of notation clarity, 𝐪{\mathbf{q}} should be understood in the following sets of equations as the subset of the actual 𝐪{\mathbf{q}} that contains only those generalized coordinates that are directly involved in the constraint, i.e. the provided Jacobians should be expanded with columns of zeros as needed at the position of non-relevant coordinates.

In addition to the specific formulas for each constraint, the following terms appear in factor Jacobians but are generic so they apply to all constraints:

𝚽˙𝐪k(𝐪)&=d𝚽𝐪k(𝐪)dt=𝚽𝐪k𝐪𝐪˙+𝚽t0=𝚽𝐪𝐪k𝐪˙𝚽˙𝐪k(𝐪)𝐪˙=𝚽𝐪𝐪k(From Eq. (42))
(𝚽𝐪k(𝐪)𝐪˙)𝐪
=𝚽𝐪𝐪k𝐪˙=𝚽˙𝐪k(𝐪)(𝚽𝐪k(𝐪)𝐪˙)𝐪˙=𝚽𝐪k
\dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})&=\dfrac{d\mathbf{\Phi_{q}}^{k}({\mathbf{q}})}{dt}\hskip 5.69046pt=\hskip 5.69046pt\dfrac{\partial\mathbf{\Phi_{q}}^{k}}{\partial{\mathbf{q}}}{\dot{\mathbf{q}}}+\cancelto{0}{{\boldsymbol{\Phi}}_{t}}\hskip 5.69046pt=\hskip 5.69046pt\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}{\dot{\mathbf{q}}}\\ \frac{\partial\dot{{\boldsymbol{\Phi}}}^{k}_{{\mathbf{q}}}({\mathbf{q}})}{\partial{\dot{\mathbf{q}}}}=\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}\quad\text{(From Eq.~{}(\ref{eq:apx.common.mbs.a}))}\\ \dfrac{\partial\left(\mathbf{\Phi_{q}}^{k}\left({\mathbf{q}}\right){\dot{\mathbf{q}}}\right)}{\partial{\mathbf{q}}}=\mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}~{}{\dot{\mathbf{q}}}\hskip 5.69046pt=\dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})\\ \dfrac{\partial\left(\mathbf{\Phi_{q}}^{k}\left({\mathbf{q}}\right){\dot{\mathbf{q}}}\right)}{\partial{\dot{\mathbf{q}}}}=\mathbf{\Phi_{q}}^{k}
(42)

Constant distance

This constraint is typically used to model rigid solids. Given the coordinates of any pair of points ii and jj of a rigid body, such that (xi,yi)𝐪(x_{i},y_{i})\in{\mathbf{q}} and (xj,yj)𝐪(x_{j},y_{j})\in{\mathbf{q}}, this constraint ensures a fixed distance LL between them. Each such constraint contributes with the following rows in the different vectors and matrices defining the multibody system:

𝚽k(𝐪)&=(xjxi)2+(yjyi)2L2=0𝚽𝐪k(𝐪)=[2(xixj)2(yiyj)2(xjxi)2(yjyi)]𝚽˙𝐪k(𝐪)=[2(x˙ix˙j)2(y˙iy˙j)2(x˙jx˙i)2(y˙jy˙i)]𝚽𝐪𝐪k(𝐪)=𝚽𝐪k𝐪=[𝚽𝐪kx1𝚽𝐪ky1𝚽𝐪kx2𝚽𝐪ky2]={blockarray}cccccxiyixjyj{block}[cccc]c2020𝚽𝐪1k0202𝚽𝐪2k2020𝚽𝐪3k0202𝚽𝐪4k(𝚽˙𝐪)𝐪k(𝐪)=𝟎4×4𝚽𝐪𝐪k(𝐪)𝐪¨=[2(x¨ix¨j)2(y¨iy¨j)2(x¨jx¨i)2(y¨jy¨i)]{\boldsymbol{\Phi}}^{k}({\mathbf{q}})&=\left(x_{j}-x_{i}\right)^{2}+\left(y_{j}-y_{i}\right)^{2}-L^{2}=0\\ \mathbf{\Phi_{q}}^{k}({\mathbf{q}})=\left[2\left(x_{i}-x_{j}\right)\hskip 8.5359pt2\left(y_{i}-y_{j}\right)\hskip 8.5359pt2\left(x_{j}-x_{i}\right)\hskip 8.5359pt2\left(y_{j}-y_{i}\right)\right]\\ \dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})=\left[2\left(\dot{x}_{i}-\dot{x}_{j}\right)\hskip 8.5359pt2\left(\dot{y}_{i}-\dot{y}_{j}\right)\hskip 8.5359pt2\left(\dot{x}_{j}-\dot{x}_{i}\right)\hskip 8.5359pt2\left(\dot{y}_{j}-\dot{y}_{i}\right)\right]\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}})=\dfrac{\partial\mathbf{\Phi_{q}}^{k}}{\partial{\mathbf{q}}}=\left[\dfrac{\partial\mathbf{\Phi_{q}}^{k}}{\partial x_{1}}\hskip 8.5359pt\dfrac{\partial\mathbf{\Phi_{q}}^{k}}{\partial y_{1}}\hskip 8.5359pt\dfrac{\partial\mathbf{\Phi_{q}}^{k}}{\partial x_{2}}\hskip 8.5359pt\dfrac{\partial\mathbf{\Phi_{q}}^{k}}{\partial y_{2}}\right]=\blockarray{ccccc}x_{i}y_{i}x_{j}y_{j}\\ \block{[cccc]c}20-20\mathbf{\Phi_{q}}_{1}^{k}\\ 020-2\mathbf{\Phi_{q}}_{2}^{k}\\ -2020\mathbf{\Phi_{q}}_{3}^{k}\\ 0-202\mathbf{\Phi_{q}}_{4}^{k}\\ \\ (\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}^{k}({\mathbf{q}})=\mathbf{0}_{4\times 4}\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}}){\ddot{\mathbf{q}}}=\left[2\left(\ddot{x}_{i}-\ddot{x}_{j}\right)\hskip 8.5359pt2\left(\ddot{y}_{i}-\ddot{y}_{j}\right)\hskip 8.5359pt2\left(\ddot{x}_{j}-\ddot{x}_{i}\right)\hskip 8.5359pt2\left(\ddot{y}_{j}-\ddot{y}_{i}\right)\right] (43)

Fixed pinned slider constraint

This constraints model a point P(x,y)P(x,y) enforced to move along a line defined by two fixed points A(xA,yA)A(x_{A},y_{A}) and B(xB,yB)B(x_{B},y_{B}). By exploiting the properties of the similar triangles, one obtains:

𝚽k(𝐪)&=(xBxA)(yyA)(yByA)(xxA)𝚽𝐪k(𝐪)=[(yByA)(xBxA)]𝚽˙𝐪k(𝐪)=𝟎1×2𝚽𝐪𝐪k(𝐪)=𝟎2×2{\boldsymbol{\Phi}}^{k}({\mathbf{q}})&=(x_{B}-x_{A})\left(y-y_{A}\right)-(y_{B}-y_{A})\left(x-x_{A}\right)\\ \mathbf{\Phi_{q}}^{k}({\mathbf{q}})=\left[-(y_{B}-y_{A})\hskip 9.95863pt(x_{B}-x_{A})\right]\\ \dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})=\mathbf{0}_{1\times 2}\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}})=\mathbf{0}_{2\times 2} (44)

Mobile pinned slider constraint

A more general version of the former constraint, where the point P(x,y)(x,y) is a now moving along a line defined by two mobile points A(xi,yi)(x_{i},y_{i}) and B(xj,yj)(x_{j},y_{j}). In this case:

𝚽k(𝐪)&=(xjxi)(yyi)(yjyi)(xxi)𝚽𝐪k(𝐪)=[yiyjxjxiyjyxxjyyixix]𝚽˙𝐪k(𝐪)=[y˙iy˙jx˙jx˙iy˙jy˙x˙x˙jy˙y˙ix˙ix˙]𝚽𝐪𝐪k(𝐪)={blockarray}7cxyxiyixjyj{block}[cccccc]c000101𝚽𝐪1k001010𝚽𝐪2k010001𝚽𝐪3k100010𝚽𝐪4k010100𝚽𝐪5k101000𝚽𝐪6k(𝚽˙𝐪)𝐪k(𝐪)=𝟎6×6𝚽𝐪𝐪k(𝐪)𝐪¨=[y¨iy¨jx¨jx¨iy¨jy¨x¨x¨jy¨y¨ix¨ix¨]{\boldsymbol{\Phi}}^{k}({\mathbf{q}})&=(x_{j}-x_{i})(y-y_{i})-(y_{j}-y_{i})(x-x_{i})\\ \mathbf{\Phi_{q}}^{k}({\mathbf{q}})=\left[y_{i}-y_{j}\hskip 8.5359ptx_{j}-x_{i}\hskip 8.5359pty_{j}-y\hskip 8.5359ptx-x_{j}\hskip 8.5359pty-y_{i}\hskip 8.5359ptx_{i}-x\right]\\ \dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})=\left[\dot{y}_{i}-\dot{y}_{j}\hskip 8.5359pt\dot{x}_{j}-\dot{x}_{i}\hskip 8.5359pt\dot{y}_{j}-\dot{y}\hskip 8.5359pt\dot{x}-\dot{x}_{j}\hskip 8.5359pt\dot{y}-\dot{y}_{i}\hskip 8.5359pt\dot{x}_{i}-\dot{x}\right]\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}})=\blockarray{*{7}{c}}xyx_{i}y_{i}x_{j}y_{j}\\ \block{[cccccc]c}00010-1\mathbf{\Phi_{q}}_{1}^{k}\\ 00-1010\mathbf{\Phi_{q}}_{2}^{k}\\ 0-10001\mathbf{\Phi_{q}}_{3}^{k}\\ 1000-10\mathbf{\Phi_{q}}_{4}^{k}\\ 010-100\mathbf{\Phi_{q}}_{5}^{k}\\ -101000\mathbf{\Phi_{q}}_{6}^{k}\\ \\ (\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}^{k}({\mathbf{q}})=\mathbf{0}_{6\times 6}\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}}){\ddot{\mathbf{q}}}=\left[\ddot{y}_{i}-\ddot{y}_{j}\hskip 8.5359pt\ddot{x}_{j}-\ddot{x}_{i}\hskip 8.5359pt\ddot{y}_{j}-\ddot{y}\hskip 8.5359pt\ddot{x}-\ddot{x}_{j}\hskip 8.5359pt\ddot{y}-\ddot{y}_{i}\hskip 8.5359pt\ddot{x}_{i}-\ddot{x}\right] (45)

Absolute orientation of planar link

Another special kind of constraints is that one needed when defining relative coordinates, such as the absolute angle of a link, e.g. a mechanism input crank, or a vehicle wheel position. The relative angle discussed in this section is called absolute since it is defined as the angle θ\theta between a body comprising a pair of points (xi,yi)(x_{i},y_{i})(xj,yj)(x_{j},y_{j}), at a fixed distance LL, and the horizontal axis of the global frame of reference.

For this constraint, with the ordering of relevant coordinates being 𝐪=[xiyixjyjθ]{\mathbf{q}}=[x_{i}~{}y_{i}~{}x_{j}~{}y_{j}~{}\theta]^{\top}, two sets of equations exist to avoid degeneracy. The first ones are used when |sin(θ)|>1/2|\sin(\theta)|>1/\sqrt{2}:

𝚽k(𝐪)&=xjxiLcos(θ)=0𝚽𝐪k(𝐪)=[1010Lsin(θ)]𝚽˙𝐪k(𝐪)=[0000Lθ˙cos(θ)]𝚽𝐪𝐪k(𝐪)={blockarray}6cxiyixjyjθ{block}[ccccc]c00000𝚽𝐪1k00000𝚽𝐪2k00000𝚽𝐪3k00000𝚽𝐪4k0000Lcos(θ)𝚽𝐪5k(𝚽˙𝐪)𝐪k(𝐪)={blockarray}6cxiyixjyjθ{block}[ccccc]c00000𝚽˙𝐪1k00000𝚽˙𝐪2k00000𝚽˙𝐪3k00000𝚽˙𝐪4k0000Lθ˙sin(θ)𝚽˙𝐪5k𝚽𝐪𝐪k(𝐪)𝐪¨=[0000Lθ¨cos(θ)](𝚽˙𝐪)𝐪k(𝐪)𝐪˙=[0000Lθ˙2sin(θ)]{\boldsymbol{\Phi}}^{k}({\mathbf{q}})&=x_{j}-x_{i}-L\cos(\theta)=0\\ \mathbf{\Phi_{q}}^{k}({\mathbf{q}})=\left[-1\hskip 5.69046pt0\hskip 5.69046pt1\hskip 5.69046pt0\hskip 5.69046ptL\sin(\theta)\right]\\ \dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})=\hskip 5.69046pt\left[0\hskip 5.69046pt0\hskip 5.69046pt0\hskip 5.69046pt0\hskip 5.69046ptL\dot{\theta}\cos(\theta)\right]\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}})=\blockarray{*{6}{c}}x_{i}y_{i}x_{j}y_{j}\theta\\ \block{[ccccc]c}00000\mathbf{\Phi_{q}}_{1}^{k}\\ 00000\mathbf{\Phi_{q}}_{2}^{k}\\ 00000\mathbf{\Phi_{q}}_{3}^{k}\\ 00000\mathbf{\Phi_{q}}_{4}^{k}\\ 0000L\cos\left(\theta\right)\mathbf{\Phi_{q}}_{5}^{k}\\ \\ (\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}^{k}({\mathbf{q}})=\blockarray{*{6}{c}}x_{i}y_{i}x_{j}y_{j}\theta\\ \block{[ccccc]c}00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}1}^{k}\\ 00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}2}^{k}\\ 00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}3}^{k}\\ 00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}4}^{k}\\ 0000-L\dot{\theta}\sin\left(\theta\right)\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}5}^{k}\\ \\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}}){\ddot{\mathbf{q}}}=\left[0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359ptL\ddot{\theta}\cos\left(\theta\right)\right]\\ (\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}^{k}({\mathbf{q}}){\dot{\mathbf{q}}}=\left[0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359pt-L\dot{\theta}^{2}\sin\left(\theta\right)\right] (46)

and the following alternative ones are used otherwise:

𝚽k(𝐪)&=yjyiLsin(θ)=0𝚽𝐪k(𝐪)=[0101Lcos(θ)]𝚽˙𝐪k(𝐪)=[0000Lθ˙sin(θ)]𝚽𝐪𝐪k(𝐪)={blockarray}6cxiyixjyjθ{block}[ccccc]c00000𝚽𝐪1k00000𝚽𝐪2k00000𝚽𝐪3k00000𝚽𝐪4k0000Lsin(θ)𝚽𝐪5k(𝚽˙𝐪)𝐪k(𝐪)={blockarray}6cxiyixjyjθ{block}[ccccc]c00000𝚽˙𝐪1k00000𝚽˙𝐪2k00000𝚽˙𝐪3k00000𝚽˙𝐪4k0000Lθ˙cos(θ)𝚽˙𝐪5k𝚽𝐪𝐪k(𝐪)𝐪¨=[0000Lθ¨sin(θ)](𝚽˙𝐪)𝐪k(𝐪)𝐪˙=[0000Lθ˙2cos(θ)]{\boldsymbol{\Phi}}^{k}({\mathbf{q}})&=y_{j}-y_{i}-L\sin(\theta)=0\\ \mathbf{\Phi_{q}}^{k}({\mathbf{q}})=\left[0\hskip 5.69046pt-1\hskip 5.69046pt0\hskip 5.69046pt1\hskip 5.69046pt-L\cos(\theta)\right]\\ \dot{{\boldsymbol{\Phi}}}_{\mathbf{q}}^{k}({\mathbf{q}})=\hskip 5.69046pt\left[0\hskip 5.69046pt0\hskip 5.69046pt0\hskip 5.69046pt0\hskip 5.69046ptL\dot{\theta}\sin(\theta)\right]\\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}})=\blockarray{*{6}{c}}x_{i}y_{i}x_{j}y_{j}\theta\\ \block{[ccccc]c}00000\mathbf{\Phi_{q}}_{1}^{k}\\ 00000\mathbf{\Phi_{q}}_{2}^{k}\\ 00000\mathbf{\Phi_{q}}_{3}^{k}\\ 00000\mathbf{\Phi_{q}}_{4}^{k}\\ 0000L\sin\left(\theta\right)\mathbf{\Phi_{q}}_{5}^{k}\\ \\ (\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}^{k}({\mathbf{q}})=\blockarray{*{6}{c}}x_{i}y_{i}x_{j}y_{j}\theta\\ \block{[ccccc]c}00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}1}^{k}\\ 00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}2}^{k}\\ 00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}3}^{k}\\ 00000\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}4}^{k}\\ 0000L\dot{\theta}\cos\left(\theta\right)\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}5}^{k}\\ \\ \mathbf{\Phi_{{\mathbf{q}}{\mathbf{q}}}}^{k}({\mathbf{q}}){\ddot{\mathbf{q}}}=\left[0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359ptL\ddot{\theta}\sin\left(\theta\right)\right]\\ (\dot{{\boldsymbol{\Phi}}}_{{\mathbf{q}}})_{{\mathbf{q}}}^{k}({\mathbf{q}}){\dot{\mathbf{q}}}=\left[0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359pt0\hskip 8.5359ptL\dot{\theta}^{2}\cos\left(\theta\right)\right] (47)

References

  • [1] B. Siciliano, L. Sciavicco, L. Villani, G. Oriolo, Robotics, Springer, 2009.
  • [2] M. L. Felis, Rbdl: An efficient rigid-body dynamics library using recursive algorithms, Autonomous Robots 41 (2) (2017) 495–511.
  • [3] D. E. Orin, R. McGhee, M. Vukobratovi, , G. Hartoch, Kinematic and kinetic analysis of open-chain linkages utilizing newton-euler methods, Mathematical Biosciences 43 (1-2) (1979) 107–130.
  • [4] M. W. Walker, D. E. Orin, Efficient Dynamic Computer Simulation of Robotic Mechanisms, Journal of Dynamic Systems, Measurement, and Control 104 (3) (1982) 205–211, publisher: American Society of Mechanical Engineers Digital Collection. doi:10.1115/1.3139699.
    URL https://asmedigitalcollection.asme.org/dynamicsystems/article/104/3/205/428542/Efficient-Dynamic-Computer-Simulation-of-Robotic
  • [5] R. Featherstone, D. Orin, Robot dynamics: equations and algorithms, in: Proceedings 2000 ICRA. Millennium Conference. IEEE International Conference on Robotics and Automation. Symposia Proceedings (Cat. No.00CH37065), Vol. 1, 2000, pp. 826–834 vol.1, iSSN: 1050-4729. doi:10.1109/ROBOT.2000.844153.
  • [6] J. Wang, G. C.M., A new approach for the dynamic analysis of parallel manipulators, A new approach for the dynamic analysis of parallel manipulators 2 (3) (1998) 317–334.
  • [7] G. Rodriguez, Kalman filtering, smoothing, and recursive robot arm forward and inverse dynamics, IEEE Journal on Robotics and Automation 3 (6) (1987) 624–639.
  • [8] G. Rodriguez, Recursive forward dynamics for multiple robot arms moving a common task object, IEEE Transactions on Robotics and Automation 5 (4) (1989) 510–521.
  • [9] A. Jain, Unified formulation of dynamics for serial rigid multibody systems, Journal of Guidance, Control, and Dynamics 14 (3) (1991) 531–542.
  • [10] U. M. Ascher, P. K. Dinesh, B. P. Cloutier, Forward dynamics, elimination methods, and formulation stiffness in robot simulation, The International Journal of Robotics Research 16 (6) (1997) 749–758.
  • [11] M. Xie, F. Dellaert, Batch and Incremental Kinodynamic Motion Planning using Dynamic Factor Graphs, arXiv:2005.12514 [cs]ArXiv: 2005.12514.
    URL http://arxiv.org/abs/2005.12514
  • [12] M. Xie, F. Dellaert, A Unified Method for Solving Inverse, Forward, and Hybrid Manipulator Dynamics using Factor Graphs, arXiv:1911.10065 [cs]ArXiv: 1911.10065.
    URL http://arxiv.org/abs/1911.10065
  • [13] J. Cuadrado, D. Dopico, A. Barreiro, E. Delgado, Real-time state observers based on multibody models and the extended kalman filter, Journal of mechanical science and technology 23 (4) (2009) 894–900.
  • [14] R. Pastorino, D. Richiedei, J. Cuadrado, A. Trevisani, State estimation using multibody models and nonlinear kalman filters, International Journal of Non-Linear Mechanics.
  • [15] F. Naets, R. Pastorino, J. Cuadrado, W. Desmet, Online state and input force estimation for multibody models employing extended kalman filtering, Multibody System Dynamics 32 (3) (2014) 317–336.
  • [16] E. Sanjurjo, M. Á. Naya, J. L. Blanco-Claraco, J. L. Torres-Moreno, A. Giménez-Fernández, Accuracy and efficiency comparison of various nonlinear kalman filters applied to multibody models, Nonlinear Dynamics 88 (3) (2017) 1935–1951.
  • [17] G. Reina, M. Paiano, J. Blanco-Claraco, Vehicle parameter estimation using a model-based estimator, Mechanical Systems and Signal Processing 87 (4) (2017) 227–241.
  • [18] H.-A. Loeliger, An introduction to factor graphs, IEEE Signal Processing Magazine 21 (1) (2004) 28–41.
  • [19] C. Bishop, Pattern recognition and machine learning, Springer New York, 2006.
  • [20] J. García de Jalón, E. Bayo, Kinematic and dynamic simulation of multibody systems: The real time challenge, Springer-Verlag, 1994.
  • [21] A. A. Shabana, Dynamics of multibody systems, Cambridge university press, 2005.
  • [22] D. Koller, N. Friedman, Probabilistic graphical models: principles and techniques, MIT press, 2009.
  • [23] F. Dellaert, M. Kaess, Factor graphs for robot perception, Foundations and Trends® in Robotics 6 (1-2) (2017) 1–139.
  • [24] A. P. Worthen, W. E. Stark, Unified design of iterative receivers using factor graphs, IEEE Transactions on Information Theory 47 (2) (2001) 843–849.
  • [25] H.-A. Loeliger, J. Dauwels, J. Hu, S. Korl, L. Ping, F. R. Kschischang, The factor graph approach to model-based signal processing, Proceedings of the IEEE 95 (6) (2007) 1295–1322.
  • [26] G. Grisetti, R. Kümmerle, C. Stachniss, W. Burgard, A tutorial on graph-based slam, IEEE Intelligent Transportation Systems Magazine 2 (4) (2010) 31–43.
  • [27] C. Forster, L. Carlone, F. Dellaert, D. Scaramuzza, Imu preintegration on manifold for efficient visual-inertial maximum-a-posteriori estimation, in: Proceedings of Robotics: Science and Systems, Rome, Italy, 2015. doi:10.15607/RSS.2015.XI.006.
  • [28] R. Hartley, J. Mangelson, L. Gan, M. G. Jadidi, J. M. Walls, R. M. Eustice, J. W. Grizzle, Legged robot state-estimation through combined forward kinematic and preintegrated contact factors, in: 2018 IEEE International Conference on Robotics and Automation (ICRA), IEEE, 2018, pp. 1–8.
  • [29] I. Sugiarto, J. Conradt, Discrete belief propagation network using population coding and factor graph for kinematic control of a mobile robot, in: 2013 IEEE International Conference on Computational Intelligence and Cybernetics (CYBERNETICSCOM), IEEE, 2013, pp. 136–140.
  • [30] F. V. Jensen, An introduction to Bayesian networks, Vol. 74, UCL press London, 1996.
  • [31] M. Raitoharju, R. Piché, On computational complexity reduction methods for kalman filter extensions, IEEE Aerospace and Electronic Systems Magazine 34 (10) (2019) 2–19.
  • [32] M. Kaess, H. Johannsson, R. Roberts, V. Ila, J. J. Leonard, F. Dellaert, isam2: Incremental smoothing and mapping using the bayes tree, The International Journal of Robotics Research 31 (2) (2012) 216–235.
  • [33] H. Strasdat, A. J. Davison, J. M. Montiel, K. Konolige, Double window optimisation for constant time visual slam, in: 2011 international conference on computer vision, IEEE, 2011, pp. 2352–2359.
  • [34] S. Leutenegger, S. Lynen, M. Bosse, R. Siegwart, P. Furgale, Keyframe-based visual–inertial odometry using nonlinear optimization, The International Journal of Robotics Research 34 (3) (2015) 314–334.
  • [35] T. Qin, P. Li, S. Shen, Vins-mono: A robust and versatile monocular visual-inertial state estimator, IEEE Transactions on Robotics 34 (4) (2018) 1004–1020.
  • [36] S. Agarwal, Y. Furukawa, N. Snavely, I. Simon, B. Curless, S. M. Seitz, R. Szeliski, Building rome in a day, Communications of the ACM 54 (10) (2011) 105–112.
  • [37] B. Triggs, P. F. McLauchlan, R. I. Hartley, A. W. Fitzgibbon, Bundle adjustment—a modern synthesis, in: Vision algorithms: theory and practice, Springer, 2000, pp. 298–372.
  • [38] J.-L. Blanco, J.-L. Torres-Moreno, A. Giménez-Fernández, Multibody dynamic systems as bayesian networks: applications to robust state estimation of mechanisms, Multibody System Dynamics 34 (2015) 103–128.