1 Introduction

A tensegrity system is an arrangement of axially-loaded elements (no element bends, even though the overall structure bends), that we loosely characterize as a network of bars and cables. The bars take compressive axial loads and the cables handle tensile loads. Since failure due to axial stresses happens at higher loads than at bending, a tensegrity structure has a higher strength-to-weight ratio. Famous architect Buckminster Fuller in the 60s coined the term tensegrity, combining the words tensile and integrity. Since then, tensegrity principles have found applications in diverse domains. Tensegrity systems have been widely adopted in architecture. Ingber [20] explained the behavior of cells by modeling them as tensegrity structures. He further showed that tensegrity structures exist at all detectable scales of the human body. Tensegrity icosahedrons are used to model biologic organisms from viruses to vertebrates, their cells, systems, and subsystems. Biotensegrity [10, 26, 27, 41] is quite an active area of research. Beyond architecture and biology, tensegrity principles are gaining popularity in robotics. NASA is considering a new terrestrial robot design based on tensegrity principles [1]. Tensegrity structures, through use of pre-stresses in the bars and cables, can also achieve controlled stiffness in the structure, which makes it attractive in applications such as soft-robotics [39], robotic locomotion [38, 44], and prosthetics [40]. In essence, tensegrity principles can be applied in the design of any structure where mass is premium, a high strength-to-weight ratio is critical, and structural stiffness needs to be tailored in both space and time. These include several applications from various engineering sectors such as aerospace (morphing airframes), energy (wind turbine blades, off-shore structures) as well as biomedical engineering (stents, minimally invasive surgical tools) and many more. Clearly, a framework is required that can efficiently model the dynamics of tensegrity structures directly from the topology of bars and cables.

The dynamics of tensegrity systems is governed by multi-body dynamics, given by a set of ordinary differential equations. This paper develops a Lagrangian formulation for deriving these differential equations directly from the given topology of members (bars and strings), and their mass and geometric properties. Three key features of classical tensegrity systems are: a) actuations only occur via cables (though this assumption can be relaxed through the introduction of soft, compressible bars which can actuate through axial deformation), b) bar-to-bar connections are pin joints, and c) the bars do not spin about their respective longitudinal axes. These properties are exploited to simplify the equations of motion. However, the Lagrangian framework presented here is general enough to allow modeling of general multi-body systems with actuated joints.

The demand for more accurate simulating tools for multi-body dynamics is being challenged quite positively by the open-source community. Physics engines such as Bullet [8] and the Open Dynamics Engine (ODE) [46] have become common in robotics applications. NASA’s Tensegrity Robotics Toolkit (NTRT) [32] is based on the Bullet engine. They rely on non-minimal coordinate descriptions, while other popular engines, e.g. Simscape Multibody [31], MuJoCo [49], DART [25] and Simbody [43] favor using generalized coordinates for describing the kinematics of bodies. This is because they mostly focus on robotics applications, where the configuration space is naturally reduced in the presence of joints and other constraints [13]. However, we have opted to use the Cartesian coordinate system to describe the motion of bodies, most notably, for two reasons. Skelton observed [45] that in three dimensions, a minimal coordinates approach is prone to singularities developed in the mass matrix, and therefore, the dynamics necessitates an excess coordinates description. Additionally, non-minimal descriptions of vector kinematics allows us to write elegant differential-algebraic equations (DAE), free of trigonometric terms.

To fully express a rigid body motion in Cartesian coordinates, equations describing constraints are written at the acceleration level and augmented to the equations of motion to develop a mass-descriptor form of a set of index-1 DAEs. Since only acceleration level constraints are tackled in the equations, position and velocity level constraints are violated due to errors from numerical integration. Numerous advances have been made in the past few decades addressing this very issue. A prominent method is that of generalized coordinates partitioning [19, 50] in which, utilizing Gauss-Jordan reduction, independent variables are identified and integrated numerically while dependent variables are preserved through the constraint equations. Baumgarte [4], on the other hand, instead of bypassing the problem, introduced two extra terms to the constraint equations so that the violations can be stabilized in the sense of Lyapunov. This method has been studied in different frameworks, such as in adaptive mechanisms [7], optimal sense [3], and digital control theory [28]. Stabilization allows for greater computational speed whereas coordinate partitioning is known for its superior error control characteristics, and methods that combine these two techniques [36, 37] to tap into these advantages have been developed as well.

However, parameter selection in the Baumgarte technique is a challenging task [2, 14], as systems implemented with the wrong feedback parameters have been found to become unstable. Coordinate partitioning was also shown to be superior to Baumgarte’s method in stabilizing constraint violations during kinematic analyses [34]. Therefore, other methods were looked into, the most common being one in which constraint violation is eliminated directly by adding appropriate correction terms to the generalized coordinates after each numerical integration. Using geometric and energy conservation constraints, Yoon et al. chose corrected positions (constrained through geometry) and velocities (constrained through energy) to be linear in the Jacobian of the constraints [53]. Yu and Chen developed an algorithm to obtain the corrected terms with the constraints at position and velocity level (both constrained through geometry) by using the Moore–Penrose inverse [54]. Citing inconsistency of units and dimensions in generalized coordinates, Blajer added an inverse of the mass matrix to the corrections of [53] as a weight matrix [5]. However, Zhang et al. compared the above two formulations in benchmark examples showing that the violation of constraints performed in the same order [55].

Furthermore, compared with the Baumgarte technique, the applied direct correction method performs more efficiently in the context of constraint violations at the position and velocity level [15, 30, 55]. However, the extent of inaccuracy in the motion, which can be determined from the violations of the energy constraints is still unclear [5, 6, 53]. Therefore, inspired by [30, 54], one of the contributions of this paper is to present a novel methodology that attains explicit elimination of not only position and velocity constraints, i.e. holonomic constraints, but also energy variations, i.e. nonholonomic constraints. The Lagrangian formulation lends itself favorably to an equilibrium analysis of the motion and any corresponding violations in energy conservation. Instead of considering corrected terms of position and velocity separately, we formulate a set of equations linear in these variables with energy constraints and solve the variables simultaneously in the sense of minimal norm.

Additionally, we have extended the formulation to support modeling of compressible bars in a tensegrity structure, i.e, the constraints on bar lengths have been relaxed to allow longitudinal deformation, and in conjunction, a transverse change. This further means that the velocity of a compressible bar would no longer have to be perpendicular to the vector along its length. Accordingly, the kinetic energy has been amended to account for the change in bar lengths and a potential energy term has been added to account for the hitherto insignificant elasticity in the bar. This extension for compressible bars would prove tremendously useful when analysing pneumatic tensegrity systems, like the self-deploying inflatable compression struts introduced in [9], or for examining compliant multistable tensegrity structures like in [47]. Further, the axial elasticity of the bars could provide a passive actuation mechanism as an alternative to the conventional prestressing and pulling of cables, and therefore warrants a framework that could facilitate the dynamics analysis of such systems.

Recently, Goyal and Skelton [18] developed a dynamics formulation for tensegrity systems using Newton and Euler’s laws, in which the cables are treated as a finite number of point masses connected with massless strings. Instead of introducing Lagrange multipliers, they combine the bar length constraints with rotational dynamics by implementing the pseudo-inverse technique. Additionally, a reduced order model has been derived through an intricate use of the singular value decomposition, which avoids other geometrical constraints. Furthermore, a new algorithm has been introduced to tackle bar length correction, which enforces the length of the bars in the structure to be fixed and its velocity vector to be orthogonal to the bar vector. However, in our paper, we treat all physical limits as constraints and correct the violations simultaneously.

The contributions of this paper are presented as follows. Firstly, a Lagrangian formulation based on Cartesian coordinates is used for deriving DAEs of the governing equations of motion in a tensegrity framework for both rigid and elastic bars. In addition, a general approach for linearization of the equations is determined analytically. Further, a novel technique for improving the accuracy of the simulation is developed to ensure that the errors in states arising from numerical integration are corrected on the position and velocity levels according to both geometric and energy constraints. Finally, the formulation has been extended to tensegrity systems featuring compressible bars, thereby allowing a deeper analysis into the kinds of materials that could be substituted in place of conventional metallic bars.

The following sections describe the formulation in much greater detail: the nomenclature used in developing the equations, the Lagrangian method for deriving the governing DAEs in the presence of constraints, an elaborate description of the holonomic constraint equations, the direct correction method deployed to ensure that these constraints are not violated at any given time, the proposed energy correction algorithm to nullify energy gain/loss occurring numerically, linearization of the governing equations to facilitate work in control, and finally, the modifications required for tensegrity structures with compressible bars. A summary has been provided at the end of each of Sects. 2 and 3 to assist in grasping the salient details of the formulation. The results for several examples are compared with those from Simscape Multibody (MATLAB’s multi-body package) and presented at the end to discuss the validity of the formulation and the benefits of the approaches proposed in the paper.

2 Derivation of tensegrity dynamics

2.1 Nomenclature

The notations used in the derivation of the tensegrity dynamics are defined as follows, first introduced in [17, 21].

  1. 1.

    Let \(\varvec{n}_i\in \mathbb {R}^{3\times 1}\) be the position of the ith node.

  2. 2.

    Let \(\varvec{N}\in \mathbb {R}^{3 \times n}\) be the nodal matrix defined by

    $$\begin{aligned} \varvec{N}:= \begin{bmatrix}\varvec{n}_1&\varvec{n}_2&\cdots&\varvec{n}_n\end{bmatrix}, \end{aligned}$$

    where n is the number of nodes in the tensegrity system.

  3. 3.

    Let \(\varvec{C} \in \mathbb {R}^{m\times n}\) be the connectivity matrix that defines the tensegrity system, where m members are defined by connecting n nodes. Specifically, if the \(k{\text {th}}\) member is defined by connecting nodes \(\varvec{n}_i\) and \(\varvec{n}_j\), then \(C(k,i) = -1,\; C(k,j) = 1,\; \text { and } C(k,\cdot ) = 0\) otherwise. Moreover, we can partition the m members to bars and strings, resulting in a partitioned connectivity matrix

    $$\begin{aligned} \varvec{C}:=\begin{bmatrix}\varvec{C}_b\\ \varvec{C}_s\end{bmatrix}, \end{aligned}$$

    where \(\varvec{C}_b\in \mathbb {R}^{n_b\times n}\) defines the \(n_b\) bar connections and \(\varvec{C}_s\in \mathbb {R}^{n_s\times n}\) defines the \(n_s\) string connections.

    Observing the connectivity matrix \(\varvec{C}_b\), we derive a matrix \(\varvec{L}_{p_m}\in \mathbb {R}^{n_{p_m}\times n}\) describing locations of \(n_{p_m}\) point masses. These masses are placed at nodes where only strings connect. Specifically, if the \(k{\text {th}}\) point mass is positioned at the node \(\varvec{n}_i\), then

    $$\begin{aligned} L_{p_m}(k,i) = 1, \text { and } L_{p_m}(k,\cdot ) = 0\text { otherwise}. \end{aligned}$$
  4. 4.

    The bars, strings and point masses are then defined as

    $$\begin{aligned}&\varvec{B}:= \varvec{N}\varvec{C}^T_b\in \mathbb {R}^{3\times n_b},\\&\varvec{S} := \varvec{N}\varvec{C}_s^T\in \mathbb {R}^{3\times n_s},\\&\varvec{P} := \varvec{N}\varvec{L}_{p_m}^T\in \mathbb {R}^{3\times n_{p_m}}. \end{aligned}$$

    The \(k{\text {th}}\) column of \(\varvec{B}\) represents the \(k{\text {th}}\) bar, denoted by \(\varvec{b}_k\). Similarly, the \(k{\text {th}}\) column of \(\varvec{S}\) represents the \(k{\text {th}}\) string, denoted by \(\varvec{s}_k\), and the \(k{\text {th}}\) column of \(\varvec{P}\) represents the \(k{\text {th}}\) point mass, denoted by \(\varvec{p}_k\). Let \(\varvec{\theta }_k\), \(\varvec{\eta }_k\), and \(\varvec{\phi }_k\) be vectors in \(\mathbb {R}^{n_b}\), \(\mathbb {R}^{n_s}\), and \(\mathbb {R}^{n_{p_m}}\) respectively with the kth elements equal to one and the rest zero. Therefore, we can compactly write

    $$\begin{aligned} \left. \begin{aligned} \varvec{b}_k&:= \varvec{N}\varvec{C}_b^T\varvec{\theta }_k = \varvec{X}_k\varvec{q},\\ \bar{\varvec{b}}_k&:= \bar{\varvec{X}}_k\varvec{q},\\ \varvec{s}_k&:= \varvec{N}\varvec{C}_s^T\varvec{\eta }_k = \varvec{Y}_k\varvec{q},\\ \varvec{p}_k&:= \varvec{N}\varvec{L}_{p_m}^T\varvec{\phi }_k = \varvec{P}_k\varvec{q}, \end{aligned}\right\} \end{aligned}$$
    (1)

    where

    $$\begin{aligned} \varvec{X}_k&:= \left( (\varvec{\theta }_k^T\varvec{C}_b)\otimes \varvec{I}_3\right) , \end{aligned}$$
    (2)
    $$\begin{aligned} \bar{\varvec{X}}_k&:= \frac{1}{2} \left( (\varvec{\theta }_k^T|\varvec{C}_b|)\otimes \varvec{I}_3\right) ,\end{aligned}$$
    (3)
    $$\begin{aligned} \varvec{Y}_k&:= \left( (\varvec{\eta }_k^T\varvec{C}_s)\otimes \varvec{I}_3\right) ,\end{aligned}$$
    (4)
    $$\begin{aligned} \varvec{P}_k&:= \left( (\varvec{\phi }_k^T\varvec{L}_{p_m})\otimes \varvec{I}_3\right) , \end{aligned}$$
    (5)

    and \(\varvec{q}:=\mathbf {vec}(\varvec{N})\) represents the Cartesian coordinates and \(\otimes \) denotes the Kronecker product.

  5. 5.

    Let \(\varvec{F}\in \mathbb {R}^{3\times n}\) be the non-conservative force matrix defined by

    $$\begin{aligned} \varvec{F}:= \begin{bmatrix}\varvec{f}_1&\varvec{f}_2&\cdots&\varvec{f}_n\end{bmatrix}, \end{aligned}$$

    where \(\varvec{f}_i\in \mathbb {R}^{3}\) is the total force acting on the \(i{\text {th}}\) node, and accordingly, the force matrix can be vectorized as \(\varvec{f}:=\varvec{\mathsf {vec}}\left( {\varvec{F}}\right) \in \mathbb {R}^{3n}\). Here we assume a general condition where all the nodes have external forces acting on them. In practice, all nodes may not be loaded. We can set those \(f_i\) to zero in the above expression. These external forces can be used to model disturbances and other loads acting on the tensegrity structure.

2.2 Kinematics

Consider the motion of \(k{\text {th}}\) bar defined by nodes \(\varvec{b}_k:=\varvec{n}_{j_k}-\varvec{n}_{i_k}\). The center of mass of the bar is given by

$$\begin{aligned} \bar{\varvec{b}}_k:= \frac{\varvec{n}_{j_k}+\varvec{n}_{i_k}}{2}, \end{aligned}$$
(6)

and its velocity is given by

$$\begin{aligned} \dot{\bar{\varvec{b}}}_k:= \frac{\dot{\varvec{N}}_{j_k}+\dot{\varvec{N}}_{i_k}}{2}. \end{aligned}$$
(7)

To determine the angular velocity of the bar we first relate the velocities of \(\varvec{n}_{j_k}\) and \(\varvec{n}_{i_k}\) using

$$\begin{aligned} \dot{\varvec{n}}_{j_k} = \dot{\varvec{n}}_{i_k} + \varvec{\omega }_k \times \varvec{b}_k, \end{aligned}$$

or

$$\begin{aligned} \dot{\varvec{b}}_k:= \dot{\varvec{n}}_{j_k} - \dot{\varvec{n}}_{i_k} = \varvec{\omega }_k \times \varvec{b}_k. \end{aligned}$$

Taking cross product with \(\varvec{b}_k\) on both sides we get

$$\begin{aligned} \varvec{b}_k\times \dot{\varvec{b}}_k= \varvec{b}_k\times (\varvec{\omega }_k \times \varvec{b}_k). \end{aligned}$$

Using the result from triple cross product

$$\begin{aligned} \varvec{a}\times (\varvec{b}\times \varvec{c}) = \varvec{b}(\varvec{a} \cdot \varvec{c}) - \varvec{c}(\varvec{a} \cdot \varvec{b}), \end{aligned}$$

we get

$$\begin{aligned} \varvec{b}_k\times \dot{\varvec{b}}_k= \varvec{\omega }_k (\varvec{b}_k\cdot \varvec{b}_k) - \varvec{b}_k(\varvec{\omega }_k \cdot \varvec{b}_k). \end{aligned}$$
(8)

For tensegrity systems, \(\varvec{\omega }_k \cdot \varvec{b}_k= 0\), i.e. the bar does not spin about its body axis. This is an important difference between tensegrity systems and general multi-body systems.

Therefore, for tensegrity systems, we can write the expression for angular velocity

$$\begin{aligned} \varvec{\omega }_k = \frac{\varvec{b}_k\times \dot{\varvec{b}}_k}{\varvec{b}_k^T\varvec{b}_k}. \end{aligned}$$

Noting that \(\varvec{b}_k^T\varvec{b}_k= l_{\varvec{b}_k}^2\), where \(l_{\varvec{b}_k}\) is the length of the bar and is a constant, we can write

$$\begin{aligned} \varvec{\omega }_k = \frac{\varvec{b}_k\times \dot{\varvec{b}}_k}{l_{\varvec{b}_k}^2}. \end{aligned}$$

Let the body axis be defined by \((\varvec{\hat{b}}_k, \, \varvec{\hat{b}}_2,\, \varvec{\hat{b}}_3)\). We can then write the angular velocity in terms of the body axis of the bar as \(\varvec{\omega }_k := \omega _2 \varvec{\hat{b}}_2 + \omega _3 \varvec{\hat{b}}_3\) where \(\omega _2\), \(\omega _3\) are respective components.

Assuming, the bar to be a cylinder with radius \(r_k\) and length \(l_{\varvec{b}_k}\), the moment of inertia of the rod in this body-fixed principal frame is

$$\begin{aligned} \varvec{I}_{\varvec{b}_k} := \mathbf{diag} \begin{bmatrix} \frac{m_{\varvec{b}_k} r^2}{2}&\frac{m_{\varvec{b}_k}}{12}(3r_k^2+l_{\varvec{b}_k}^2)&\frac{m_{\varvec{b}_k}}{12}(3r_k^2+l_{\varvec{b}_k}^2) \end{bmatrix}. \end{aligned}$$

The angular momentum \(h_k\) of the bar is therefore

$$\begin{aligned} \varvec{h}_k&:= \varvec{I}_{\varvec{b}_k} \begin{bmatrix} 0&\omega _2&\omega _3 \end{bmatrix}^T\\&= \frac{m_{\varvec{b}_k}}{12}(3r_k^2+l_{\varvec{b}_k}^2)( \omega _2 \hat{\varvec{b}}_2 \ +\omega _3 \hat{\varvec{b}}_3)\\&= \frac{m_{\varvec{b}_k}}{12}(3r_k^2+l_{\varvec{b}_k}^2)\;\varvec{\omega }_k,\\&= \frac{(3r_k^2+l_{\varvec{b}_k}^2)m_{\varvec{b}_k}}{12 l_{\varvec{b}_k}^2}\,\varvec{b}_k\times \dot{\varvec{b}}_k. \end{aligned}$$

If \(\varvec{r}_k\) can be ignored, then \(\varvec{h}_k \approx \frac{m_{\varvec{b}_k}}{12}\,\varvec{b}_k\times \dot{\varvec{b}}_k.\) Often, hollow cylinders are used. In that case, we can substitute the appropriate inertia matrix in the expression for angular momentum.

The inertial position coordinates of \(k{\text {th}}\) point mass are given by \(\varvec{p}_k := \varvec{n}_{i_k}\) and its velocity given by \(\dot{\varvec{p}_k} := \dot{\varvec{n}}_{i_k}\).

2.3 Dynamics using Lagrangian approach

Let \(\mathcal {L}:=T-V\) be the Lagrangian, defined over coordinates \(\varvec{q}\), with components \(q_i\). The equations of motion are then given by

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial \mathcal {L}}{\partial \dot{q}_i}\right) - \frac{\partial \mathcal {L}}{\partial q_i} - \varvec{\lambda }^T(t) \frac{\partial \varvec{R}(\varvec{q})}{\partial q_i} = \varvec{f}^T \frac{\partial \varvec{q}}{\partial q_i} \end{aligned}$$

where \(\varvec{R}(\varvec{q}): \mathbb {R}^{3n}\mapsto \mathbb {R}^m =\varvec{0}\) depict ideal constraints that satisfy the principle of D’Alembert, first stated by Lagrange [22]. On the right, \(\varvec{f}\) is the non conservative force acting on the system such as externally applied forces, damper forces or disturbances. From the definition of the coordinate \(\varvec{q}\), one can notice that \(\frac{\partial \varvec{q}}{\partial q_i}\) is the \(i{\text {th}}\) column of an identity matrix \(\varvec{I}_{3n}\). We can therefore write the equation of motion as

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial \mathcal {L}}{\partial \dot{q}_i}\right) - \frac{\partial \mathcal {L}}{\partial q_i} - \varvec{\lambda }^T(t) \frac{\partial \varvec{R}(\varvec{q})}{\partial q_i} = f_i, \end{aligned}$$

where \(f_i\) is the \(i{\text {th}}\) element of \(\varvec{f}\).

Substituting \(\mathcal {L}:=T-V\), we get the equations of motion

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial T}{\partial \dot{q}_i}\right) + \frac{\partial }{\partial q_i}\left( V - \varvec{\lambda }^T\varvec{R}(\varvec{q})\right) = f_i, \end{aligned}$$

for \(i=1,\cdots ,3n\); or in terms of \(\varvec{q}\) as

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial T}{\partial \dot{\varvec{q}}}\right) + \frac{\partial }{\partial \varvec{q}}\left( V - \varvec{\lambda }^T\varvec{R}(\varvec{q})\right) = \varvec{f}^T. \end{aligned}$$
(9)

2.3.1 Total kinetic energy

Total kinetic energy of the system is

$$\begin{aligned} T :=&\sum _{k=1}^{n_b}\left( \frac{1}{2}m_{\varvec{b}_k}\dot{\bar{\varvec{b}}}_k\cdot \dot{\bar{\varvec{b}}}_k+ \frac{1}{2} \varvec{h}_k \cdot \varvec{\omega }_k\right) \\&+ \sum _{k=1}^{n_{p_m}}\left( \frac{1}{2}m_{\varvec{p}_k} \dot{\varvec{p_k}} \cdot \dot{\varvec{p_k}}\right) \end{aligned}$$

The kinetic energy of the \(k\text {th}\) bar is

$$\begin{aligned} T_{\varvec{b}_k}&= \frac{1}{2}\left( m_{\varvec{b}_k} \dot{\bar{\varvec{b}}}_k^T\dot{\bar{\varvec{b}}}_k+ \frac{I_{\varvec{b}_k}}{l_k^4}(\varvec{b}_k\times \dot{\varvec{b}}_k)\cdot (\varvec{b}_k\times \dot{\varvec{b}}_k)\right) , \end{aligned}$$

where \(I_{\varvec{b}_k}:=\frac{m_{\varvec{b}_k}}{12}(3r_k^2+l_{\varvec{b}_k}^2)\). Simplifying

$$\begin{aligned} (\varvec{b}_k\times \dot{\varvec{b}}_k)\cdot (\varvec{b}_k\times \dot{\varvec{b}}_k) =&(\varvec{b}_k\cdot \varvec{b}_k)(\dot{\varvec{b}}_k\cdot \dot{\varvec{b}}_k)\\&- (\varvec{b}_k\cdot \dot{\varvec{b}}_k)(\dot{\varvec{b}}_k\cdot \varvec{b}_k)\\ =&l_{\varvec{b}_k}^2(\dot{\varvec{b}}_k\cdot \dot{\varvec{b}}_k), \end{aligned}$$

we get

$$\begin{aligned} T_{\varvec{b}_k} = \frac{1}{2}\left( m_{\varvec{b}_k} \dot{\bar{\varvec{b}}}_k\cdot \dot{\bar{\varvec{b}}}_k+ \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2}\dot{\varvec{b}}_k\cdot \dot{\varvec{b}}_k\right) . \end{aligned}$$

Using (1), we can write \(T_{\varvec{b}_k}\) in terms of \(\dot{\varvec{q}}\) as

$$\begin{aligned} T_{\varvec{b}_k}&= \frac{1}{2}\dot{\varvec{q}}^T\underbrace{\left[ m_{\varvec{b}_k}\bar{\varvec{X}}_k^T\bar{\varvec{X}_k} + \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2}\varvec{X}_k^T\varvec{X}_k\right] }_{:=\varvec{M}_{\varvec{b}_k}}\dot{\varvec{q}} = \frac{1}{2}\dot{\varvec{q}}^T\varvec{M}_{\varvec{b}_k}\dot{\varvec{q}}. \end{aligned}$$

The kinetic energy of the \(k\text {th}\) point mass is

$$\begin{aligned} T_{\varvec{p}_k} = \frac{1}{2}\left( m_{\varvec{p}_k} \dot{\varvec{p_k}} \cdot \dot{\varvec{p_k}}\right) \end{aligned}$$

Using (1), we can write \(T_{\varvec{p}_k}\), in terms of \(\dot{\varvec{q}}\) as

$$\begin{aligned} T_{\varvec{p}_k}&= \frac{1}{2}\dot{\varvec{q}}^T\underbrace{\left[ m_{\varvec{p}_k}{\varvec{P}}_k^T{\varvec{P}_k} \right] }_{:=\varvec{M}_{\varvec{p}_k}}\dot{\varvec{q}} = \frac{1}{2}\dot{\varvec{q}}^T\varvec{M}_{\varvec{p}_k}\dot{\varvec{q}}\nonumber \\ \implies T&= \sum _{k=1}^{n_b} T_{\varvec{b}_k} + \sum _{k=1}^{n_{p_m}} T_{\varvec{p}_k} \nonumber \\&= \frac{1}{2}\dot{\varvec{q}}^T \underbrace{\left( \sum _{k=1}^{n_b}\varvec{M}_{\varvec{b}_k}\right) }_{:=\varvec{M_b}}\dot{\varvec{q}} + \frac{1}{2}\dot{\varvec{q}}^T\underbrace{\left( \sum _{k=1}^{n_{p_m}} \varvec{M}_{\varvec{p}_k}\right) }_{:=\varvec{M_p}}\dot{\varvec{q}} \nonumber \\&= \frac{1}{2}\dot{\varvec{q}}^T\underbrace{\left( \varvec{M_b}+\varvec{M_p}\right) }_{:=\varvec{M}}\dot{\varvec{q}} \nonumber \\&=\frac{1}{2}\dot{\varvec{q}}^T\varvec{M}\dot{\varvec{q}}. \end{aligned}$$
(10)

2.3.2 Gravity potential energy

Total gravitational potential energy of the system is

$$\begin{aligned} V_g&:= -\sum _{k=1}^{n_b} m_{\varvec{b}_k} (\varvec{g} \cdot \bar{\varvec{b}}_k) - \sum _{k=1}^{n_{p_m}} m_{\varvec{p}_k} (\varvec{g} \cdot \varvec{p}_k)\nonumber \\&= -\underbrace{\varvec{g}^T\left( \sum _{k=1}^{n_b}m_{\varvec{b}_k}\bar{\varvec{X}}_k + \sum _{k=1}^{n_{p_m}}m_{\varvec{p}_k} \varvec{P}_k\right) }_{:= \varvec{G}^T}\varvec{q} = -\varvec{G}^T\varvec{q}, \end{aligned}$$
(11)

where \(\varvec{g}:=\begin{bmatrix}0&0&-9.806\end{bmatrix}^T\) is the gravity vector.

2.3.3 Potential energy of strings modeled as springs

We can model the strings as springs. In this case, the spring energy is

$$\begin{aligned} V_s&:= \frac{1}{2} \sum _{k=1}^{n_s} K_k \left( \Vert \varvec{s}_k\Vert - l_{s_k}\right) ^2, \end{aligned}$$
(12)

adds to the potential energy of the system. In this case, \(l_{s_k}\) is the natural length of the spring and \(K_k\) is the spring constant. In this formulation, we have to be mindful about \(\Vert \varvec{s}_k\Vert - l_{s_k} \ge 0\), because the strings can only exert tensile force (unidirectional), unlike regular springs. Force density \(\sigma _k\), is defined as

$$\begin{aligned} \sigma _k := K_k\left( 1- \frac{l_{s_k} }{\Vert \varvec{s}_k\Vert }\right) , \end{aligned}$$
(13)

which is the control variable. In the implementation, if the condition \(\Vert \varvec{s}_k\Vert - l_{s_k} \ge 0\) is violated for any string at any point in time, the corresponding force density is set to zero at that instant.

The spring energy in terms of \(\sigma _k\) can be written as

$$\begin{aligned} V_s :&= \frac{1}{2} \sum _{k=1}^{n_s}\left( \frac{\sigma _k^2}{K_k}\right) \Vert \varvec{s}_k\Vert ^2\nonumber \\&= \frac{1}{2} \sum _{k=1}^{n_s}\left( \frac{\sigma _k^2}{K_k}\right) \varvec{s}_k^T\varvec{s}_k\nonumber \\&= \frac{1}{2} \varvec{q}^T\left( \sum _{k=1}^{n_s} \frac{\sigma _k^2}{K_k}\varvec{Y}_k^T\varvec{Y}_k\right) \varvec{q}\nonumber \\&= \frac{1}{2} \varvec{q}^T\left( \underbrace{\begin{bmatrix}\varvec{Y}_1^T\varvec{Y}_1&\cdots&\varvec{Y}_{n_s}^T\varvec{Y}_{n_s}\end{bmatrix}}_{:=\varvec{Y}}\left( \frac{\varvec{\sigma }^2}{\varvec{K}} \otimes \varvec{I}_{3n} \right) \right) \varvec{q},\nonumber \\&= \frac{1}{2} \varvec{q}^T \varvec{Y}\left( \frac{\varvec{\sigma }^2}{\varvec{K}} \otimes \varvec{I}_{3n} \right) \varvec{q} \end{aligned}$$
(14)

where \(\varvec{\sigma }^2 := \begin{bmatrix}\sigma _1^2&\cdots&\sigma _{n_s}^2\end{bmatrix}^T\), \(\varvec{K}:=\begin{bmatrix} K_1&\cdots&K_{n_s} \end{bmatrix}\).

2.3.4 Damper force

We assume a damper force between two nodes where the string/spring exists and the force is proportional to the changing rate of the string/spring length. Thus the kth damper can be modeled as

$$\begin{aligned} \varvec{f}_{d,k}&=-c\frac{d\Vert \varvec{s}_k\Vert }{dt}\frac{\varvec{s}_k}{\Vert \varvec{s}_k\Vert }, \end{aligned}$$
(15)
$$\begin{aligned}&=-c\frac{\varvec{s}_k^T\dot{\varvec{s}}_k}{\Vert \varvec{s}_k\Vert }\frac{\varvec{s}_k}{\Vert \varvec{s}_k\Vert },\end{aligned}$$
(16)
$$\begin{aligned}&=-c\frac{(\dot{\varvec{s}}_k^T\varvec{s}_k)\varvec{s}_k}{\varvec{s}_k^T\varvec{s}_k} \end{aligned}$$
(17)

where c is the damping coefficient and the direction of the force is always parallel to the string/spring. One should notice that the damper force disappears whenever the string is slack, that is \(\varvec{f}_{d,k}=0\) if \(\Vert \varvec{s}_k\Vert - l_{s_k} \le 0\), but the damper force always exists in the spring. To represent the total damper force acting on a node, one can utilize (4) and obtain \(\varvec{f}_d=\sum _{k=1}^{n_s}\varvec{Y}_k^T\varvec{f}_{d,k}\). Considering damper force as one of the members in external force, it can be added to \(\varvec{f}\) in (9).

2.3.5 Equations of motion

We are now ready to derive the equations of motion. From (10), we have

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial T}{\partial \dot{\varvec{q}}}\right) = \ddot{\varvec{q}}^T\varvec{M}, \end{aligned}$$

from (11), we have

$$\begin{aligned} \frac{\partial V_g}{\partial \varvec{q}} = -\varvec{G}^T, \end{aligned}$$

and finally from (14), we have

$$\begin{aligned} \frac{\partial V_s}{\partial \varvec{q}}&= \frac{\partial }{\partial \varvec{q}}\left( \frac{1}{2} \sum _{k=1}^{n_s} \frac{\sigma _k^2}{K_k}\varvec{s}_k^T\varvec{s}_k\right) \nonumber \\&= \frac{1}{2} \sum _{k=1}^{n_s}\left( \frac{\partial }{\partial \varvec{q}}\left( \frac{\sigma _k^2}{K_k} \right) \varvec{s}_k^T\varvec{s}_k+2\frac{{\sigma _k}^2}{K_k}\varvec{s}_k^T\frac{\partial \varvec{s}_k}{\partial \varvec{q}} \right) \nonumber \\&= \frac{1}{2} \sum _{k=1}^{n_s}\left( 2l_{s_k}\sigma _k\frac{\varvec{s}_k^T}{\Vert \varvec{s}_k\Vert ^3}\varvec{Y}_k\Vert \varvec{s}_k\Vert ^2+2\frac{{\sigma _k}^2}{K_k}\varvec{s}_k^T\frac{\partial \varvec{s}_k}{\partial \varvec{q}} \right) \nonumber \\&= \sum _{k=1}^{n_s}\left( l_{s_k}\sigma _k\frac{\varvec{s}_k^T}{\Vert \varvec{s}_k\Vert }\varvec{Y}_k+\frac{{\sigma _k}^2}{K_k}\varvec{s}_k^T\frac{\partial \varvec{s}_k}{\partial \varvec{q}} \right) \nonumber \\&= \sum _{k=1}^{n_s} \sigma _k \left( l_{s_k}\frac{\varvec{s}_k^T}{\Vert \varvec{s}_k\Vert }+\left( 1-\frac{l_{s_k}}{\Vert \varvec{s}_k\Vert }\right) \varvec{s}_k^T \right) \varvec{Y}_k\nonumber \\&= \sum _{k=1}^{n_s} \sigma _k\varvec{q}^T\varvec{Y}_k^T\varvec{Y}_k\nonumber \\&= \varvec{q}^T\varvec{Y}\left( \varvec{\sigma } \otimes \varvec{I}_{3n} \right) \end{aligned}$$
(18)

Therefore, the equations of motion are given by

$$\begin{aligned} \ddot{\varvec{q}}^T\varvec{M} -\varvec{G}^T + \varvec{q}^T\varvec{Y}(\varvec{\sigma } \otimes \varvec{I}_{3n} ) - \varvec{\lambda }^T\frac{\partial \varvec{R}}{\partial \varvec{q}} = \varvec{f}^T, \end{aligned}$$

or with transpose

$$\begin{aligned} \varvec{M}\ddot{\varvec{q}} - \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) ^T\varvec{\lambda } = - (\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\varvec{q} + \varvec{G} + \varvec{f}. \end{aligned}$$
(19)

We next look at the constraint equation \(\varvec{R}(\varvec{q}) = \varvec{0}\), and compute

$$\begin{aligned} \frac{d^2\varvec{R}(\varvec{q})}{dt^2}&= \frac{d}{dt}\left( \frac{d\varvec{R}(\varvec{q})}{dt}\right) ,\\&= \frac{d}{dt} \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\dot{\varvec{q}}\right) ,\\&= \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) \ddot{\varvec{q}} + \begin{bmatrix} \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_1}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \\ \vdots \\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_m}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \end{bmatrix}, \end{aligned}$$

where \(\left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) \) is a Jacobian of \(\varvec{R}(\varvec{q})\) and \(\left( \frac{\partial ^2 R_i}{\partial \varvec{q}^2}\right) \) is the Hessian of \(R_i(\varvec{q})\). Therefore, \(\frac{d^2\varvec{R}(\varvec{q})}{dt^2} = 0\) implies

$$\begin{aligned} -\left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) \ddot{\varvec{q}}&= \begin{bmatrix} \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_1}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \\ \vdots \\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_m}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \end{bmatrix}. \end{aligned}$$
(20)

Combining (19) and (20), we get the final equation

$$\begin{aligned} \begin{bmatrix} \varvec{M} &{} - \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) ^T \\ -\left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) &{} \varvec{0} \end{bmatrix}&\begin{pmatrix}\ddot{\varvec{q}} \\ \varvec{\lambda }\end{pmatrix} =\nonumber \\&\begin{bmatrix} -(\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\varvec{q} + \varvec{G} + \varvec{f}\\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_1}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \\ \vdots \\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_m}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \end{bmatrix}. \end{aligned}$$
(21)

Defining,

$$\begin{aligned} \varvec{R}_{\varvec{q}}&:= \frac{\partial \varvec{R}}{\partial \varvec{q}},\\ \varvec{\xi }_1&:= -(\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\varvec{q} + \varvec{G} + \varvec{f},\\ \varvec{\xi }_2&:= \begin{bmatrix} \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_1}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \\ \vdots \\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_m}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \end{bmatrix}, \end{aligned}$$

we can analytically express \(\ddot{\varvec{q}}\) and \(\varvec{\lambda }\) as

$$\begin{aligned} \ddot{\varvec{q}}&= \varvec{M}^{-1}\left[ \varvec{\xi }_1-\varvec{R}_{\varvec{q}}^T\left( \varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{R}_{\varvec{q}}^T\right) ^{-1}\right. \nonumber \\&\qquad \qquad \qquad \qquad \qquad \qquad \qquad \left. \left( \varvec{\xi }_2+\varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{\xi }_1\right) \right] \nonumber \\&=\varvec{\xi }(\varvec{q},\dot{\varvec{q}},\varvec{\sigma },\varvec{f}), \nonumber \\ \varvec{\lambda }&= -\left( \varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{R}_{\varvec{q}}^T\right) ^{-1}\left( \varvec{\xi }_2+\varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{\xi }_1\right) . \end{aligned}$$
(22)

In this formulation, numerical difficulties may occur when solving the above equations of motion. Here we assume that the mass matrix \(\varvec{M}\) is invertible since the kinetic energy is always positive. Small inertia can also cause numerical ill conditioning. In addition, redundant constraints can also cause singularity in \(\varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{R}_{\varvec{q}}^T\). Such constraints can further lead to non-uniqueness of computed reaction forces and accelerations. These results may be unit-sensitive as well [51]. In such cases, a weighted Moore–Penrose generalized inverse may be used in a meaningful manner to derive the force distribution on the constrained structure [29].

2.3.6 Ideal constraints

Ideal constraints, as stated earlier, are those that satisfy D’Alembert’s principle. In the current derivation, we only consider holonomic constraints, that is, they reduce the dimension of the space of accessible configurations, but do not restrict motion and paths within the reduced dimension [35]. Mathematically, the constraint equations can be expressed as \(\varvec{R}(\varvec{q}) = \varvec{0}\), where \(\varvec{q}\) is a function of time. Commonly constraints will include bar-length constraints that are quadratic in \(\varvec{q}\), and boundary conditions on \(\varvec{q}\) that will be linear in \(\varvec{q}\). Bar length constraints are of the type \(\varvec{b}_k^T\varvec{b}_k-l_{\varvec{b}_k}^2 = 0\), which in terms of \(\varvec{q}\) are \(\varvec{q}^T\varvec{X}_k^T\varvec{X}_k\varvec{q} - l_{\varvec{b}_k}^2 = 0\).

Therefore, for these two cases

$$\begin{aligned}&\varvec{R}(\varvec{q}) := \begin{bmatrix}\varvec{A}\varvec{q}-\varvec{b} \\ \varvec{q}^T\varvec{X}_1^T\varvec{X}_1\varvec{q} - l_{b_1}^2\\ \vdots \\ \varvec{q}^T\varvec{X}_{n_b}^T\varvec{X}_{n_b}\varvec{q}-l_{b_{n_b}}^2 \end{bmatrix} = 0. \end{aligned}$$
(23)

Therefore,

$$\begin{aligned} \varvec{R}_{\varvec{q}}:= \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) = \begin{bmatrix} \varvec{A} \\ 2\varvec{q}^T\varvec{X}_1^T\varvec{X}_1 \\ \vdots \\ 2\varvec{q}^T\varvec{X}_{n_b}^T\varvec{X}_{n_b} \end{bmatrix}, \end{aligned}$$
(24)

and

$$\begin{aligned} \begin{bmatrix} \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_1}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \\ \vdots \\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_m}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \end{bmatrix} = \begin{bmatrix} \varvec{0}\\ 2\dot{\varvec{q}}^T \varvec{X}_1^T\varvec{X}_1\dot{\varvec{q}} \\ \vdots \\ 2\dot{\varvec{q}}^T \varvec{X}_{n_b}^T\varvec{X}_{n_b}\dot{\varvec{q}} \end{bmatrix}. \end{aligned}$$

2.4 DAE correction

The holonomic constraints are converted to differential equations by differentiating them twice. This results in constraints on acceleration, which are satisfied exactly. However, the position and velocity constraints get violated due to errors in numerical integration. In addition to the constraints, numerical errors also violate energy conservation. For this reason, inspired by the direct correction approach in [30, 54], we use the idea of constraint variations and derive a system of linear equations to correct for errors in numerical integration. To account for energy conservation, we also include variation in the total system energy in the formulation.

Considering the vector of coordinates and its time derivative that need to be corrected for the original constraints,

$$\begin{aligned} \varvec{q}^c = \varvec{q}^u + \delta \varvec{q}, \end{aligned}$$
(25)

where \(\varvec{q}^u\) denotes the uncorrected position, obtained from numerical integration, \(\varvec{q}^c\) the corrected position, and \(\delta \varvec{q}\) is the correction required to satisfy the constraint. Therefore

$$\begin{aligned} \varvec{R}(\varvec{q}^c) = \varvec{R}(\varvec{q}^u + \delta \varvec{q}) = \varvec{R}(\varvec{q}^u) + \varvec{R}_{\varvec{q}}\delta \varvec{q}= \varvec{0}, \end{aligned}$$
(26)

where \(\varvec{R}_{\varvec{q}}\) is a Jacobian matrix defined in (24).

Similarly, the time derivative of the holonomic constraint should satisfy

$$\begin{aligned} \frac{d\varvec{R}}{dt}=\frac{\partial \varvec{R}}{\partial \varvec{q}}\dot{\varvec{q}}=\varvec{0}. \end{aligned}$$
(27)

With

$$\begin{aligned} \dot{\varvec{q}}^c=\dot{\varvec{q}}^u+\delta \dot{\varvec{q}}, \end{aligned}$$
(28)

we get

$$\begin{aligned} \left[ \varvec{R}_{q}(\varvec{q}^u)+\frac{\partial \varvec{R}_{\varvec{q}}}{\partial \varvec{q}}\delta \varvec{q}\right] \left( \dot{\varvec{q}}^u+\delta \dot{\varvec{q}}\right) =\varvec{0}, \end{aligned}$$
(29)

where \(\frac{\partial \varvec{R}_{\varvec{q}}}{\partial \varvec{q}}\) is a third-order tensor and can be represented in a matrix form

$$\begin{aligned} \frac{\partial \varvec{R}_{\varvec{q}}}{\partial \varvec{q}}\delta \varvec{q}=\left[ \frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_1}\delta \varvec{q}\quad \cdots \quad \frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_{3n}}\delta \varvec{q}\right] . \end{aligned}$$

Ignoring higher order terms in (29), we get

$$\begin{aligned} \varvec{R}_{\varvec{q}}\dot{\varvec{q}}^u+\varvec{R}_{\varvec{q}}\delta \dot{\varvec{q}}+\left( \frac{\partial \varvec{R}_{\varvec{q}}}{\partial \varvec{q}}\delta \varvec{q}\right) \dot{\varvec{q}}^u=\varvec{0}, \end{aligned}$$
(30)

where the third term can be reformulated as

$$\begin{aligned} \left( \frac{\partial \varvec{R}_{\varvec{q}}}{\partial \varvec{q}}\delta \varvec{q}\right) \dot{\varvec{q}}^u&=\left[ \frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_1}\delta \varvec{q}\quad \cdots \quad \frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_{3n}}\delta \varvec{q}\right] \dot{\varvec{q}}^u,\\&= \sum _{i=1}^{3n}\frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_i}\dot{q}^u_i\delta \varvec{q},\\&=\left( \sum _{i=1}^{3n}\frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_i}\dot{\varvec{q}}^u\varvec{\alpha }_i\right) \delta \varvec{q},\\&=\varvec{Q}\delta \varvec{q}, \end{aligned}$$

where \(\varvec{Q} := \left( \sum _{i=1}^{3n}\frac{\partial \varvec{R}_{\varvec{q}}}{\partial q_i}\dot{\varvec{q}}^u\varvec{\alpha }_i\right) \), and \(\varvec{\alpha }_i\) is the \(i{\text {th}}\) column of the identity matrix \(\varvec{I}_{3n}\).

Then (30) becomes

$$\begin{aligned} \varvec{R}_{\varvec{q}}\dot{\varvec{q}}^u+\varvec{R}_{\varvec{q}}\delta \dot{\varvec{q}}+\varvec{Q}\delta \varvec{q}=\varvec{0}. \end{aligned}$$
(31)

Combining (26) and (31), we obtain the following system of linear equations

$$\begin{aligned} \begin{bmatrix} \varvec{R}_{\varvec{q}}&{} \varvec{0}\\ \varvec{Q} &{} \varvec{R}_{\varvec{q}}\end{bmatrix} \begin{bmatrix} \delta \varvec{q}\\ \delta \dot{\varvec{q}} \end{bmatrix} = \begin{bmatrix} -\varvec{R}\\ -\varvec{R}_{\varvec{q}}\dot{\varvec{q}}^u \end{bmatrix}. \end{aligned}$$
(32)

Since the matrix in (32) has fewer rows than columns (\(2m < 6n\)), it doesn’t have full column rank and there exist infinite solutions. In [30], the author applied Moore–Penrose inverse to minimize the 2-norm of the solution. However, the corrections in \(\delta \varvec{q}\) and \(\delta \dot{\varvec{q}}\) from such a formulation, modifies the potential and kinetic energy of the system and violates the conservation of mechanical energy. In this work, we extend the work in [30], by explicitly constraining the energy change, due to \(\delta \varvec{q}\) and \(\delta \dot{\varvec{q}}\), to be zero. This will result in an additional linear equation in \(\delta \varvec{q}\) and \(\delta \dot{\varvec{q}}\). The derivation of that constraint equation is as follows. We consider a general formulation, where the work done by external forces are accounted for.

The total energy of the system is defined as

$$\begin{aligned} E(\varvec{q},\dot{\varvec{q}}) := T(\dot{\varvec{q}}) + V_s(\varvec{q}) + V_g(\varvec{q}), \end{aligned}$$
(33)

and energy conservation states that the total energy at any time t is the sum of the total energy at initial time and the work done by non conservative forces, i.e.

$$\begin{aligned} E(\varvec{q},\dot{\varvec{q}}) = E(\varvec{q}_0,\dot{\varvec{q}}_0) + \int _{ C }\varvec{f}\cdot d\varvec{q}, \end{aligned}$$
(34)

where \((\varvec{q}_0,\dot{\varvec{q}}_0)\) is the initial condition, \(\varvec{f}\) is the external force, which can be either state or time dependent, and the integration is done over path C connecting \(\varvec{q}_0\) to \(\varvec{q}\).

Let the work done by force \(\varvec{f}\) be \(W_{\varvec{f}}\), i.e.

$$\begin{aligned} W_{\varvec{f}}&=\int _{ C }\varvec{f}\cdot d\varvec{q}\nonumber ,\\&=\int _{t_0}^{t}\varvec{f}^T\frac{d\varvec{q}(\tau )}{d\tau }d\tau . \end{aligned}$$
(35)

Here we treat \(W_{\varvec{f}}\) as an additional state variable, and augment the state-dynamics in (22), with

$$\begin{aligned} \dot{W_{\varvec{f}}} = \varvec{f}^T\dot{\varvec{q}(t)}. \end{aligned}$$
(36)

Integration of (36) results in the time evolution of \(W_{\varvec{f}}\), which will also incur errors due to numerical integration, and hence must be corrected like \(\varvec{q}\), and \(\dot{\varvec{q}}\). Similar to the correction for \(\varvec{q}\) and \(\dot{\varvec{q}}\), we consider

$$\begin{aligned} W_{\varvec{f}}^c=W_{\varvec{f}}^u+\delta W_{\varvec{f}}. \end{aligned}$$
(37)

Due to numerical errors in integration of dynamics and (35), (34) will not be satisfied. Therefore, the corrections \(\delta \varvec{q}\), \(\delta \dot{\varvec{q}}\), and \(\delta W_{\varvec{f}}\) must be such that (34) is satisfied with the corrected quantities \(\varvec{q}^c\), \(\dot{\varvec{q}}^c\), and \(W_{\varvec{f}^c}\), i.e,

$$\begin{aligned} E(\varvec{q}^c,\dot{\varvec{q}}^c) = E(\varvec{q}_0,\dot{\varvec{q}}_0) + W_{\varvec{f}}^c. \end{aligned}$$
(38)

Substituting \(\varvec{q}^c\), \(\dot{\varvec{q}}^c\), in \(T(\dot{\varvec{q}}^c)\), \(V_g(\varvec{q}^c)\), \(V_s(\varvec{q}^c)\), and retaining linear terms only, we get

$$\begin{aligned} T(\dot{\varvec{q}}^c) = T(\dot{\varvec{q}}^u+\delta \dot{\varvec{q}})&\approx T(\dot{\varvec{q}}^u) + \left. \frac{\partial T}{\partial \dot{\varvec{q}}}\right| _{\dot{\varvec{q}}^u}\delta \dot{\varvec{q}} \end{aligned}$$
(39)
$$\begin{aligned} V_g(\varvec{q}^c) = V_g(\varvec{q}^u + \delta \varvec{q})&\approx V_g(\varvec{q}^u) + \left. \frac{\partial V_g}{\partial \varvec{q}}\right| _{\varvec{q}^u}\delta \varvec{q}, \end{aligned}$$
(40)
$$\begin{aligned} V_s(\varvec{q}^c) = V_s(\varvec{q}^u+\delta \varvec{q})&\approx V_s(\varvec{q}^u) + \left. \frac{\partial V_s }{\partial \varvec{q}}\right| _{\varvec{q}^u}\delta \varvec{q}. \end{aligned}$$
(41)

Therefore, (38) becomes

$$\begin{aligned}&\begin{bmatrix} \left( \left. \frac{\partial V_g}{\partial \varvec{q}}\right| _{\varvec{q}^u} + \left. \frac{\partial V_s}{\partial \varvec{q}}\right| _{\varvec{q}^u}\right)&\left. \frac{\partial T}{\partial \dot{\varvec{q}}}\right| _{\dot{\varvec{q}}^u}&-1 \end{bmatrix}\begin{pmatrix}\delta \varvec{q}\\ \delta \dot{\varvec{q}}\\ \delta W_{\varvec{f}} \end{pmatrix} \nonumber \\&\quad = E(\varvec{q}_0,\dot{\varvec{q}}_0) - E(\varvec{q}^u,\dot{\varvec{q}}^u) + W^u_{\varvec{f}}. \end{aligned}$$
(42)

Combining (32) and (42), we arrive at a final linear system of equations

$$\begin{aligned}&\underbrace{\begin{bmatrix} \varvec{R}_{\varvec{q}}&{} \varvec{0} &{} 0\\ \varvec{Q} &{} \varvec{R}_{\varvec{q}}&{} 0\\ \left( \left. \frac{\partial V_g}{\partial \varvec{q}}\right| _{\varvec{q}^u} + \left. \frac{\partial V_s}{\partial \varvec{q}}\right| _{\varvec{q}^u}\right) &{}\left. \frac{\partial T}{\partial \dot{\varvec{q}}}\right| _{\dot{\varvec{q}}^u} &{} -1 \end{bmatrix}}_{:=\varvec{A}_c} \begin{bmatrix} \delta \varvec{q}\\ \delta \dot{\varvec{q}}\\ \delta W_{\varvec{f}} \end{bmatrix}\nonumber \\&= \underbrace{\begin{bmatrix} -\varvec{R}\\ Rq\dot{\varvec{q}}^u\\ E(\varvec{q}_0,\dot{\varvec{q}}_0) - E(\varvec{q}^u,\dot{\varvec{q}}^u) + W^u_{\varvec{f}} \end{bmatrix}}_{:=\varvec{b}_c}, \end{aligned}$$
(43)

and the minimum norm corrections \(\delta \varvec{q}\), \(\delta \dot{\varvec{q}}\), and \(\delta W_{\varvec{f}}\) are determined using pseudoinverse of \(\varvec{A}_c\), i.e.

$$\begin{aligned} \begin{bmatrix} \delta \varvec{q}\\ \delta \dot{\varvec{q}}\\ \delta W_{\varvec{f}} \end{bmatrix} = \varvec{A}_c^T(\varvec{A}_c\varvec{A}_c^T)^{-1}\varvec{b}_c. \end{aligned}$$
(44)

These corrections are done after every integration in each time step once the 2-norm of the constraints violations or the energy violation is greater than a given threshold \(\gamma \). Further, since the constraints and energy equation are approximated through linearization, the solution to (43) does not fully satisfy the nonlinear equations (23) and (34) depending on the error coming from the integration. So, an iteration method presented in Algorithm 1 is used to ensure the performance of the corrections.

figure a

2.5 Linearization

The nonlinear dynamics of the system can be written as

$$\begin{aligned} \ddot{\varvec{q}} = \varvec{\xi }(\varvec{q},\dot{\varvec{q}},\varvec{\sigma },\varvec{f}), \end{aligned}$$
(45)

where \(\varvec{q},\dot{\varvec{q}}\) are the states, \(\varvec{\sigma }\) is control, and \(\varvec{f}\) is external force (or disturbance). Let \(\varvec{q}_0, \dot{\varvec{q}}_0, \varvec{\sigma }_0\) and \(\varvec{f}_0\) be the state, control, and external loading about which linearization is desired. The linear system is therefore

$$\begin{aligned} \delta \ddot{\varvec{q}}=&\frac{\partial \varvec{\xi } }{ \partial \varvec{q}}|_{\varvec{q}_0,\dot{\varvec{q}}_0, \varvec{\sigma }_0,\varvec{f}_0}\delta \varvec{q}+ \frac{\partial \varvec{\xi }}{\partial \dot{\varvec{q}}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0}\delta \dot{\varvec{q}}\nonumber \\&+ \frac{\partial \varvec{\xi }}{\partial \varvec{\sigma }}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0}\delta \varvec{\sigma } + \frac{\partial \varvec{\xi }}{\partial \varvec{f}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0}\delta \varvec{f}. \end{aligned}$$
(46)

From (22) the first term in (46) is represented by

$$\begin{aligned} \frac{\partial \varvec{\xi }}{\partial \varvec{q}}= \varvec{M}^{-1}\left[ \frac{\partial \varvec{\xi }_1}{\partial \varvec{q}}-\frac{\partial \varvec{R}_{\varvec{q}}^T}{\partial \varvec{q}}\tilde{\varvec{M}}\tilde{\varvec{\xi }}\right. \left. -~\varvec{R}_{\varvec{q}}^T\right.&\frac{\partial \tilde{\varvec{M}}}{\partial \varvec{q}}\tilde{\varvec{\xi }}\\&\left. -~\varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\frac{\partial \tilde{\varvec{\xi }}}{\partial \varvec{q}} \right] , \end{aligned}$$

where

$$\begin{aligned}&\tilde{\varvec{M}}=(\varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{R}_{\varvec{q}}^T)^{-1}\\&\tilde{\varvec{\xi }}=(\varvec{\xi }_2+\varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{\xi }_1)\\&\frac{\partial \varvec{R}_{\varvec{q}}^T}{\partial \varvec{q}}\tilde{\varvec{M}}\tilde{\varvec{\xi }}=\left[ \frac{\partial \varvec{R}_{\varvec{q}}^T}{\partial q_1}\tilde{\varvec{M}}\tilde{\varvec{\xi }} \quad \cdots \quad \frac{\partial \varvec{R}_{\varvec{q}}^T}{\partial q_{3n}}\tilde{\varvec{M}}\tilde{\varvec{\xi }} \right] ,\\&\varvec{R}_{\varvec{q}}^T\frac{\partial \tilde{\varvec{M}}}{\partial \varvec{q}}\tilde{\varvec{\xi }}=\left[ \varvec{R}_{\varvec{q}}^T\frac{\partial }{\partial q_{1}}\tilde{\varvec{M}}\tilde{\varvec{\xi }}\quad \cdots \quad \varvec{R}_{\varvec{q}}^T\frac{\partial }{\partial q_{3n}}\tilde{\varvec{M}}\tilde{\varvec{\xi }} \right] ,\\&\varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\frac{\partial \tilde{\varvec{\xi }}}{\partial \varvec{q}}=\left[ \varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\frac{\partial }{\partial q_1}\tilde{\varvec{\xi }} \quad \cdots \quad \varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\frac{\partial }{\partial q_{3n}}\tilde{\varvec{\xi }} \right] ,\\&\frac{\partial \tilde{\varvec{M}}}{\partial q_i} = -~\tilde{\varvec{M}}\frac{\partial \left( \varvec{R}_{\varvec{q}}\varvec{M}^{-1}\varvec{R}_{\varvec{q}}^T\right) }{\partial q_i}\tilde{\varvec{M}}. \end{aligned}$$

Since only \(\varvec{\xi }_2\) is dependent on \(\dot{\varvec{q}}\), the second term in (46) is

$$\begin{aligned} \frac{\partial \varvec{\xi }}{\partial \dot{\varvec{q}}}&= - \varvec{M}^{-1}\varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\frac{\partial \varvec{\xi }_2}{\partial \dot{\varvec{q}}}. \end{aligned}$$

Finally, \(\varvec{\xi }_1\) depends on the control \(\varvec{\sigma }\) and external force \(\varvec{f}\), the third term and fourth term in (46) are

$$\begin{aligned} \frac{\partial \varvec{\xi }}{\partial \varvec{\sigma }}=\varvec{M}^{-1}\left[ \frac{\partial \varvec{\xi }_1}{\partial \varvec{\sigma }}-\varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\varvec{R}_{\varvec{q}}\varvec{M}^{-1} \frac{\partial \varvec{\xi }_1}{\partial \varvec{\sigma }} \right] \end{aligned}$$

and

$$\begin{aligned} \frac{\partial \varvec{\xi }}{\partial \varvec{f}}=\varvec{M}^{-1}\left[ \varvec{I}-\varvec{R}_{\varvec{q}}^T\tilde{\varvec{M}}\varvec{R}_{\varvec{q}}\varvec{M}^{-1}\right] . \end{aligned}$$

To determine \(\frac{\partial \varvec{\xi }_1}{\partial \varvec{\sigma }}\), using the Kronecker identity

$$\begin{aligned} (\varvec{B}^T\otimes \varvec{A})\varvec{\mathsf {vec}}\left( {\varvec{C}}\right) = \varvec{\mathsf {vec}}\left( {\varvec{A}\varvec{C}\varvec{B}}\right) \end{aligned}$$

we write

$$\begin{aligned} (\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\varvec{q}&= (\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{\mathsf {vec}}\left( {\hat{\varvec{Y}}}\right) \\&= \varvec{\mathsf {vec}}\left( {\hat{\varvec{Y}}\varvec{\sigma }}\right) \\&= \hat{\varvec{Y}}\varvec{\sigma }, \end{aligned}$$

where \(\hat{\varvec{Y}}\in \mathbb {R}^{3n\times n_u}\) such that \(\varvec{\mathsf {vec}}\left( {\hat{\varvec{Y}}}\right) = \varvec{Y}^T\varvec{q}\), which is a rearrangement of the elements of column vector \(\varvec{Y}^T\varvec{q}\) into a matrix of dimension \(3n\times n_u\). Therefore,

$$\begin{aligned} \frac{\partial \varvec{\xi }_1}{\partial \varvec{\sigma }}&= \frac{\partial }{\partial \varvec{\sigma }}(-(\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\varvec{q} ) = -\frac{\partial }{\partial \varvec{\sigma }}\left( \hat{\varvec{Y}}\varvec{\sigma }\right) = -\hat{\varvec{Y}}. \end{aligned}$$
(47)

Defining,

$$\begin{aligned} \varvec{A}&:= \begin{bmatrix} \varvec{0}&{}\varvec{I}\\ \frac{\partial \varvec{\xi }}{\partial \varvec{q}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0}&{} \frac{\partial \varvec{\xi }}{\partial \dot{q}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0} \end{bmatrix}, \end{aligned}$$
(48)
$$\begin{aligned} \varvec{B_{\varvec{\sigma }}}&:=\begin{bmatrix} \varvec{0}\\ \frac{\partial \varvec{\xi }}{ \partial \varvec{\sigma }}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0} \end{bmatrix}, \end{aligned}$$
(49)
$$\begin{aligned} \varvec{B_f}&:= \begin{bmatrix} \varvec{0}\\ \frac{\partial \varvec{\xi }}{\partial \varvec{f}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{f}_0} \end{bmatrix}, \end{aligned}$$
(50)

we can write the linear system as

$$\begin{aligned} \dot{\varvec{x}} = \varvec{A} \varvec{x} + \varvec{B_\sigma }\delta \varvec{\sigma } + \varvec{B_f}\delta \varvec{f}, \end{aligned}$$
(51)

where

$$\begin{aligned} \varvec{x} :=\begin{bmatrix}\delta \varvec{\varvec{q}} \\ \delta \dot{\varvec{q}}\end{bmatrix}. \end{aligned}$$

The linear system in (51) is not a minimum realization, due to the algebraic constraints on \(\delta \varvec{q}\). Controlling tensegrity systems using modern control theory, requires minimum realization. The system can be transformed to a minimum realization using standard techniques [16, 23, 24, 33].

2.6 Summary

Section 2 presented a detailed description of the derivations required to arrive at the final set of equations governing the dynamics of our multibody tensegrity system in the Lagrangian framework. A gist of the approach is presented as follows.

  1. 1.

    Input: For the tensegrity system under analysis, provide material, geometric, and connectivity properties that would fully describe the structure under stasis.

  2. 2.

    Structure Generation: Construct a tensegrity structure with the following matrices: \(\varvec{N}\), \(\varvec{C}\), \(\varvec{X}\), \(\varvec{Y}\), \(\varvec{P}\) which describe the nodal configuration and the appropriately defined connectivity matrices for bars, strings, and the point masses.

  3. 3.

    Lagrangian Dynamics: Compute the following quantities in order: total kinetic energy, total potential energy, constraint equations, and non-conservative forces.

    $$\begin{aligned} {T}&= \frac{1}{2}\dot{\varvec{q}}^T \varvec{M} \dot{\varvec{q}}\\ V&= V_g + V_s \\&= -\varvec{G}^T \varvec{q}+ \frac{1}{2} \varvec{q}^T \varvec{Y} \left( \frac{\varvec{\sigma ^2}}{\varvec{K}} \otimes \varvec{I}_{3n}\right) \varvec{q}\\ \varvec{R}(\varvec{q})&= \begin{bmatrix}\varvec{A}\varvec{q}-\varvec{b} \\ \varvec{q}^T\varvec{X}_1^T\varvec{X}_1\varvec{q} - l_{b_1}^2\\ \vdots \\ \varvec{q}^T\varvec{X}_{n_b}^T\varvec{X}_{n_b}\varvec{q}-l_{b_{n_b}}^2 \end{bmatrix} = 0. \\ \varvec{f}&= \varvec{f}_{\text {ext}} + \varvec{f}_d \\ \end{aligned}$$
  4. 4.

    Equations of Motion: The first equation describes the governing equations of motion while the second one describes the additional constraint equations.

    $$\begin{aligned} \varvec{M}\ddot{\varvec{q}} - \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) ^T\varvec{\lambda } = - (\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\varvec{q} + \varvec{G} + \varvec{f}. \end{aligned}$$
    $$\begin{aligned} -\left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) \ddot{\varvec{q}} = \begin{bmatrix} \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_1}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \\ \vdots \\ \dot{\varvec{q}}^T \left( \frac{\partial ^2 R_m}{\partial \varvec{q}^2}\right) \dot{\varvec{q}} \end{bmatrix} \end{aligned}$$
  5. 5.

    Correction: Correcting for position,

    $$\begin{aligned} \varvec{R}(\varvec{q}^c) = \varvec{R}(\varvec{q}^u) + \varvec{R}_{\varvec{q}}\delta \varvec{q}= \varvec{0}, \end{aligned}$$

    Correcting for velocity,

    $$\begin{aligned} \varvec{R}_{\varvec{q}}\dot{\varvec{q}}^u+\varvec{R}_{\varvec{q}}\delta \dot{\varvec{q}}+\left( \frac{\partial \varvec{R}_{\varvec{q}}}{\partial \varvec{q}}\delta \varvec{q}\right) \dot{\varvec{q}}^u=\varvec{0}, \end{aligned}$$

    Correcting for energy,

    $$\begin{aligned} E(\varvec{q}^c,\dot{\varvec{q}}^c) = E(\varvec{q}_0,\dot{\varvec{q}}_0) + W_{\varvec{f}}^c \end{aligned}$$
  6. 6.

    Linearization: The nonlinear dynamics given by:

    $$\begin{aligned} \ddot{\varvec{q}} = \varvec{\xi }(\varvec{q},\dot{\varvec{q}},\varvec{\sigma },\varvec{f}), \end{aligned}$$

    can be linearized into:

    $$\begin{aligned} \dot{\varvec{x}} = \varvec{A} \varvec{x} + \varvec{B_\sigma }\delta \varvec{\sigma } + \varvec{B_f}\delta \varvec{f} \end{aligned}$$

    where

    $$\begin{aligned} \varvec{x} := \begin{bmatrix} \delta \varvec{q}\\ \delta \dot{\varvec{q}}\end{bmatrix} \end{aligned}$$

3 Tensegrity systems with compressible bars

3.1 Dynamics

Since bars are assumed to be rigid, the holonomic constraint \(\varvec{R}\) is a must to ensure that the bar lengths stay fixed during simulation. However, in reality, the bar is not perfectly rigid but compressible with a large Young’s modulus, which allows us to release the constraints and treat the bar as an elastic body. In this section, we allow for bars to deform longitudinally and, in accordance with the Poisson effect, transversely as well, i.e., \(\dot{r}_k=-\nu _k r_k\frac{\dot{l}_{\varvec{b}_k}}{l_{\varvec{b}_k}}\), where \(r_k\) and \(l_{\varvec{b}_k}\) are the radius and length of \(k{\text {th}}\) bar respectively, and \(\nu _k\) is Poisson’s ratio. It must be stated that this elasticity does not allow for bending of the bar in any case.

One should note that \(\dot{l}_{\varvec{b}_k}\) is no longer zero due to the flexibility of the bar. Specifically, \(\dot{l}_{\varvec{b}_k}=\frac{\varvec{b}_k^T\dot{\varvec{b}}_k}{l_{\varvec{b}_k}}\), which implies that the velocity vector of the bar is not perpendicular to the bar vector and yields that

$$\begin{aligned} \dot{\varvec{b}}_k= \dot{l}_{\varvec{b}_k} \hat{\varvec{b}}_k + \varvec{\omega }_k \times \varvec{b}_k\end{aligned}$$

where \(\hat{\varvec{b}}_k\) is the unit vector along the axis of the bar represented by \(\varvec{b}_k\). Taking cross product on both sides with \(\varvec{b}_k\)

$$\begin{aligned} \varvec{b}_k\times \dot{\varvec{b}}_k&= \varvec{0} + \varvec{b}_k\times (\varvec{\omega }_k \times \varvec{b}_k) \\&= \varvec{\omega }_k (\varvec{b}_k\cdot \varvec{b}_k) - \varvec{b}_k(\varvec{\omega }_k \cdot \varvec{b}_k) \end{aligned}$$

The assumption for tensegrity systems with regards to the bar not spinning about the body axis holds, i.e., \((\varvec{\omega }_k \cdot \varvec{b}_k) = \varvec{0}\), and hence,

$$\begin{aligned} \varvec{\omega }_k = \frac{\varvec{b}_k\times \dot{\varvec{b}}_k}{l_{\varvec{b}_k}^2} \end{aligned}$$

which is the same expression for angular velocity as that for the rigid bar case. However, when computing the rotational kinetic energy of the bar, we observe

$$\begin{aligned} T_{\varvec{b}_k}&= \frac{1}{2}\left( m_{\varvec{b}_k} \dot{\bar{\varvec{b}}}_k^T\dot{\bar{\varvec{b}}}_k+ \frac{I_{\varvec{b}_k}}{l_k^4}(\varvec{b}_k\times \dot{\varvec{b}}_k)\cdot (\varvec{b}_k\times \dot{\varvec{b}}_k)\right) , \end{aligned}$$

where now,

$$\begin{aligned} (\varvec{b}_k\times \dot{\varvec{b}}_k)\cdot (\varvec{b}_k\times \dot{\varvec{b}}_k) = l_{\varvec{b}_k}^2(\dot{\varvec{b}}_k\cdot \dot{\varvec{b}}_k) - (l_{\varvec{b}_k}\dot{l}_{\varvec{b}_k})^2. \end{aligned}$$

The kinetic energy of the \(k{\text {th}}\) bar therefore becomes

$$\begin{aligned} T_{\varvec{b}_k} = \frac{1}{2}\dot{\varvec{q}}^T\varvec{M}_{\varvec{b}_k}\dot{\varvec{q}}-\frac{1}{2}\left( \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2}\dot{l}_{\varvec{b}_k}^2\right) , \end{aligned}$$

and the total kinetic energy is

$$\begin{aligned} T = \frac{1}{2}\dot{\varvec{q}}^T\varvec{M}\dot{\varvec{q}}-T_f \end{aligned}$$

where \(T_f=\frac{1}{2}\sum _{k=1}^{n_b}\frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2}\dot{l}_{\varvec{b}_k}^2\). On comparing the differences with (10), we note that \(\varvec{M}\) is no longer a constant matrix and there exists an extra term \(T_f\), so

$$\begin{aligned} \frac{\partial T}{\partial \dot{\varvec{q}}}&=\dot{\varvec{q}}^T\varvec{M}-\frac{\partial T_f}{\partial \dot{\varvec{q}}}\\&= \dot{\varvec{q}}^T\varvec{M}-\frac{1}{2}\sum _{k=1}^{n_b}\frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2}(2\dot{l}_{\varvec{b}_k}\frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}})\\&= \dot{\varvec{q}}^T\varvec{M}-\sum _{k=1}^{n_b}\frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2}\frac{\varvec{q}^T\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}}\dot{l}_{\varvec{b}_k}\\&= \dot{\varvec{q}}^T\varvec{M}-\varvec{q}^T\varvec{M}_f, \end{aligned}$$

where \(\varvec{M}_f= \sum _{k=1}^{n_b} \frac{I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k\dot{l}_{\varvec{b}_k}}{l_{\varvec{b}_k}^3}\), and

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial T}{\partial \dot{\varvec{q}}}\right) =\ddot{\varvec{q}}^T\varvec{M}+\dot{\varvec{q}}^T\dot{\varvec{M}}-\dot{\varvec{q}}^T\varvec{M}_f-\varvec{q}^T\dot{\varvec{M}}_f, \end{aligned}$$
(52)

where

$$\begin{aligned} \dot{\varvec{M}}&=\sum _{k=1}^{n_b}\left[ \frac{d}{dt}\left( \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^2} \right) \varvec{X}_k^T\varvec{X}_k\right] \\&= \sum _{k=1}^{n_b}\left[ -2\left( \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^3} \right) \varvec{X}_k^T\varvec{X}_k\dot{l}_{\varvec{b}_k}+\frac{dI_{\varvec{b}_k}}{dt}\frac{1}{l_{\varvec{b}_k}^2}\varvec{X}_k^T\varvec{X}_k \right] , \end{aligned}$$

and

$$\begin{aligned} \dot{\varvec{M}}_f=\sum _{k=1}^{n_b}\left[ \frac{dI_{\varvec{b}_k}}{dt}\frac{\varvec{X}_k^T\varvec{X}_k\dot{l}_{\varvec{b}_k}}{l_{\varvec{b}_k}^3} -3\right.&\left( \frac{I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}^4} \right) \dot{l}_{\varvec{b}_k}^2 \\&\qquad \left. + \ddot{l}_{\varvec{b}_k}\frac{I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}^3} \right] , \end{aligned}$$

with

$$\begin{aligned} \ddot{l}_{\varvec{b}_k}&=\frac{d}{dt}\left[ \frac{\varvec{q}^T\varvec{X}_k^T\varvec{X}_k\dot{\varvec{q}}}{l_{\varvec{b}_k}} \right] \\&=\frac{\dot{\varvec{q}}^T\varvec{X}_k^T\varvec{X}_k\dot{\varvec{q}}}{l_{\varvec{b}_k}}+\frac{\ddot{\varvec{q}}^T\varvec{X}_k^T\varvec{X}_k\varvec{q}}{l_{\varvec{b}_k}}-\frac{\varvec{q}^T\varvec{X}_k^T\varvec{X}_k\dot{\varvec{q}}}{l_{\varvec{b}_k}^2}\dot{l}_{\varvec{b}_k}, \end{aligned}$$

and

$$\begin{aligned} \frac{dI_{\varvec{b}_k}}{dt}=\frac{m_{\varvec{b}_k}}{12}(6r_k\dot{r}_k+2l_{\varvec{b}_k}\dot{l}_{\varvec{b}_k}). \end{aligned}$$

Rearranging (52) where the terms associated with \(\ddot{\varvec{q}}\) are combined together, we arrive

$$\begin{aligned} \frac{d}{dt}\left( \frac{\partial T}{\partial \dot{\varvec{q}}}\right) =\ddot{\varvec{q}}^T\varvec{M}_{\ddot{\varvec{q}}}+\dot{\varvec{q}}^T\varvec{M}_{\dot{\varvec{q}}}+\varvec{q}^T\varvec{M}_{\varvec{q}}, \end{aligned}$$
(53)

where

$$\begin{aligned}&\varvec{M}_{\ddot{\varvec{q}}}=\varvec{M}-\sum _{k=1}^{n_b} \frac{\varvec{X}_k^T\varvec{X}_k\varvec{q}}{l_{\varvec{b}_k}}\frac{\varvec{q}^T I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}^3},\\&\varvec{M}_{\dot{\varvec{q}}}=\dot{\varvec{M}}-\varvec{M}_f,\\&\varvec{M}_{\varvec{q}}=-\sum _{k=1}^{n_b}\left[ \frac{dI_{\varvec{b}_k}}{dt}\frac{\varvec{X}_k^T\varvec{X}_k\dot{l}_{\varvec{b}_k}}{l_{\varvec{b}_k}^3} -3\left( \frac{I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}^4} \right) \dot{l}_{\varvec{b}_k}^2 \right. \\&\qquad \left. + \left( \frac{\dot{\varvec{q}}^T\varvec{X}_k^T\varvec{X}_k\dot{\varvec{q}}}{l_{\varvec{b}_k}}-\frac{\varvec{q}^T\varvec{X}_k^T\varvec{X}_k\dot{\varvec{q}}}{l_{\varvec{b}_k}^2}\dot{l}_{\varvec{b}_k} \right) \frac{I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}^3} \right] . \end{aligned}$$

Considering the elasticity of the bars, a potential energy term will also be required. Similar to the expression for potential energy in strings, we can model this term as

$$\begin{aligned} V_b&=\frac{1}{2}\sum _{k=1}^{n_b}K_{\varvec{b}_k}\left( \Vert \varvec{b}_k\Vert -l_{\varvec{b}_k}(0) \right) ^2, \end{aligned}$$

where \(K_{\varvec{b}_k}\) is the stiffness of the \(k{\text {th}}\) bar which is usually a large value, and \(l_{\varvec{b}_k}(0)\) is the rest length of the \(k{\text {th}}\) bar. For solid bars under tension or compression,

$$\begin{aligned} K_{\varvec{b}_k} = \frac{A_{\varvec{b}_k} E_{\varvec{b}_k}}{l_{\varvec{b}_k}(0)} \end{aligned}$$

where \(A_{\varvec{b}_k}\) is the area of the bar under consideration and \(E_{\varvec{b}_k}\) is its Young’s modulus. Then,

$$\begin{aligned} \frac{\partial V_b}{\partial \varvec{q}}&=\sum _{k=1}^{n_b}K_{\varvec{b}_k}\left[ \varvec{q}^T\varvec{X}_k^T\varvec{X}_k-\frac{\varvec{q}^T\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}}l_{\varvec{b}_k}(0) \right] \nonumber \\&=\varvec{q}^T\sum _{k=1}^{n_b}K_{\varvec{b}_k}\left[ \varvec{X}_k^T\varvec{X}_k-\frac{\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}}l_{\varvec{b}_k}(0) \right] \nonumber \\&=\varvec{q}^T \varvec{X} (\varvec{\varPsi } \otimes \varvec{I}_{3n}) \end{aligned}$$
(54)

where \(\varvec{\varPsi } \in \mathbb {R}^{n_b}\), \(\varPsi _k = K_{\varvec{b}_k} \left[ 1 - \frac{l_{\varvec{b}_k}(0)}{l_{\varvec{b}_k}}\right] \), and \(\varvec{X} = [\varvec{X}_1^T \varvec{X}_1 \cdots \varvec{X}_{n_b}^T \varvec{X}_{n_b}]\).

Substituting (52) and (54) into (9), the equations of motion are given by

$$\begin{aligned} \varvec{M}_{\ddot{\varvec{q}}}\ddot{\varvec{q}} - \varvec{R}_{\varvec{q}}^T\varvec{\lambda } =&-\left[ \varvec{M}_{\varvec{q}}^T + (\varvec{\varPsi }^T \otimes \varvec{I}_{3n})\varvec{X}^T \right. \nonumber \\&\left. +(\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\right] \varvec{q}\nonumber \\&-\varvec{M}_{\dot{\varvec{q}}}^T\dot{\varvec{q}} + \varvec{G} + \varvec{f} + \varvec{f}_d:=\varvec{\xi }_3, \end{aligned}$$
(55)

where the holonomic constraints \(\varvec{R}\) do not contain bar length constraints anymore, but a few more terms are added to the governing equation to capture the elasticity of the bars.

3.2 Impact on structural stiffness

Under equilibrium, the equations are:

$$\begin{aligned} - \varvec{R}_{\varvec{q}}^T\varvec{\lambda } =&-\left[ (\varvec{\varPsi }^T \otimes \varvec{I}_{3n})\varvec{X}^T + (\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\right] \varvec{q}\nonumber \\&+ \varvec{G} + \varvec{f} - \frac{\partial \varvec{M}_{\dot{\varvec{q}}}}{\partial \varvec{q}}\dot{\varvec{q}}- \varvec{M}_{\varvec{q}}^T \varvec{q}\end{aligned}$$
(56)

Note that compressibility allows for actuation of the tensegrity structure through pre-stressing of bars. Suppose, in a regular tensegrity structure with rigid bars, we wished to replace the tension-bearing cables in the structure with compression-bearing bars.

$$\begin{aligned} \varvec{q}^T \varvec{Y} (\varvec{\sigma } \otimes \varvec{I}_{3n})&= -\varvec{q}^T \varvec{X} (\varvec{\varPsi } \otimes \varvec{I}_{3n}) \end{aligned}$$

where the negative sign indicates a change from tension to compression.

The stiffness of the tensegrity structure comes from the strings as well as the compressible bars present in the structure. Stiffness is:

$$\begin{aligned} \varvec{K}_{sys}&= \frac{\partial }{\partial \varvec{q}} \left( \left. \frac{\partial V_s}{\partial \varvec{q}}\right| _{\varvec{q} = \varvec{q}_{eq}} + \left. \frac{\partial V_b}{\partial \varvec{q}}\right| _{\varvec{q} = \varvec{q}_{eq}} \right) ^T \\&= \frac{\partial }{\partial \varvec{q}} \left( \sum _{k=1}^{n_s} \sigma _k \varvec{q}^T \varvec{Y}_k^T \varvec{Y}_k + \sum _{j=1}^{n_b} \varPsi _j \varvec{q}^T \varvec{X}_j^T \varvec{X}_j \right) ^T \\&= \sum _{k=1}^{n_s} \left( \sigma _k \varvec{Y}_k^T \varvec{Y}_k + \frac{\partial \sigma _k}{\partial \varvec{q}} \varvec{Y}_k^T \varvec{Y}_k \varvec{q}\right) \\&\quad + \sum _{j=1}^{n_b} \left( \varPsi _j \varvec{X}_j^T \varvec{X}_j + \frac{\partial \varPsi _j}{\partial \varvec{q}} \varvec{X}_j^T \varvec{X}_j \varvec{q}\right) \\&= \sum _{k=1}^{n_s} \left( \sigma _k \varvec{Y}_k^T \varvec{Y}_k + \frac{K_{\varvec{s}_k} l_{{0\varvec{s}}_k}}{||\varvec{s}_k ||^3} \varvec{Y}_k^T \varvec{Y}_k \varvec{q}\varvec{q}^T \varvec{Y}_k^T \varvec{Y}_k \right) \\&\quad + \sum _{j=1}^{n_b} \left( \varPsi _j \varvec{X}_j^T \varvec{X}_j + \frac{K_{\varvec{b}_j} l_{{0\varvec{b}}_j}}{||\varvec{b}_j ||^3} \varvec{X}_j^T \varvec{X}_j \varvec{q}\varvec{q}^T \varvec{X}_j^T \varvec{X}_j \right) \end{aligned}$$

\(l_{{0\varvec{s}}_k}\) and \(l_{{0\varvec{b}}_j}\) are the natural lengths of the kth string and jth bar respectively. Clearly, there is a linear dependence of the stiffness matrix on the individual stiffnesses of the bars and the cables present in the structure. This allows for flexibility in choosing the material of the bars as well. The stiffer the bar material (steel or aluminium and the like), lower will be the deflection, and vice-versa.

Table 1 User-defined properties of the 3 models
Fig. 16
figure 1

Structures of the examples where red lines indicate strings, black lines indicate rigid bars, squares indicate point masses, black dots are fixed nodes, white dots are free nodes, and numbers are node notations. (Color figure online)

3.3 Linearization of augmented Lagrangian system

Consider the set of equations:

$$\begin{aligned} \varvec{M}_{\ddot{\varvec{q}}}(\varvec{q})\ddot{\varvec{q}} - \varvec{R}_{\varvec{q}}^T \varvec{\lambda }&=\varvec{\xi }_3 (\varvec{q},\dot{\varvec{q}},\varvec{\sigma },\varvec{\varPsi },\varvec{f}), \\ -\varvec{R}_{\varvec{q}}\ddot{\varvec{q}}&= \varvec{\xi }_2 \end{aligned}$$

Note that in the absence of bar length constraints, \(\varvec{R}(\varvec{q}) := [\varvec{A}\varvec{q}- \varvec{b}] = 0\) and \(\varvec{\xi }_2 = 0\). Therefore, \(\varvec{R}_{\varvec{q}}:= \left( \frac{\partial \varvec{R}}{\partial \varvec{q}}\right) =\varvec{A} \text { (a constant)}\). This means that the above set of dynamics equations reduces to:

$$\begin{aligned} \varvec{M}_{\ddot{\varvec{q}}}(\varvec{q})\ddot{\varvec{q}} - \varvec{R}_{\varvec{q}}^T \varvec{\lambda }&=\varvec{\xi }_3 (\varvec{q},\dot{\varvec{q}},\varvec{\sigma },\varvec{\varPsi },\varvec{f}), \\ -\varvec{R}_{\varvec{q}}\ddot{\varvec{q}}&= \varvec{0} \end{aligned}$$

Linearizing this set of equations at \([\varvec{q}_0, \dot{\varvec{q}}_0], [\varvec{\sigma }_0\), \(\varvec{\varPsi }_0]\), and \(\varvec{f}_0\), i.e., the state, control, and external loading that satisfy equilibrium conditions,

$$\begin{aligned}&\left( \frac{\partial \varvec{M}_{\ddot{\varvec{q}}}}{\partial \varvec{q}} \ddot{\varvec{q}} \right) \delta \varvec{q}+ \varvec{M}_{\ddot{\varvec{q}}} \delta \ddot{\varvec{q}} - \varvec{R}_{\varvec{q}}^T \delta \varvec{\lambda }\\&\quad = \frac{\partial \varvec{\xi }_3 }{ \partial \varvec{q}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{\varPsi }_0,\varvec{f}_0}\delta \varvec{q}+ \frac{\partial \varvec{\xi }_3}{\partial \dot{\varvec{q}}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{\varPsi }_0,\varvec{f}_0}\delta \dot{\varvec{q}} \\&\qquad + \frac{\partial \varvec{\xi }_3}{\partial \varvec{\sigma }}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{\varPsi }_0,\varvec{f}_0}\delta \varvec{\sigma } + \frac{\partial \varvec{\xi }_3}{\partial \varvec{\varPsi }}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{\varPsi }_0,\varvec{f}_0}\delta \varvec{\varPsi } \\&\qquad + \frac{\partial \varvec{\xi }_3}{\partial \varvec{f}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0,\varvec{\varPsi }_0,\varvec{f}_0}\delta \varvec{f}. \\&\qquad \varvec{R}_{\varvec{q}}\delta \ddot{\varvec{q}} = \varvec{0} \end{aligned}$$

Since at equilibrium, \(\ddot{\varvec{q}} = 0\), the first term in the first equation above can be eliminated. Further,

$$\begin{aligned} \frac{\partial \varvec{\xi }_3}{\partial \varvec{q}}&= - \left[ \varvec{M}_{\varvec{q}}^T + (\varvec{\varPsi }^T \otimes \varvec{I}_{3n})\varvec{X}^T + (\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T \right] \\&\quad - \frac{\partial \varvec{M}_{\dot{\varvec{q}}}^T}{\partial \varvec{q}} \dot{\varvec{q}} + \frac{\partial \varvec{f}_d}{\partial \varvec{q}},\\ \frac{\partial \varvec{\xi }_3}{\partial \dot{\varvec{q}}}&= - \frac{\partial \varvec{M}_{\varvec{q}}^T}{\partial \dot{\varvec{q}}} \varvec{q}- \varvec{M}_{\dot{\varvec{q}}}^T - \frac{\partial \varvec{M}_{\dot{\varvec{q}}}^T}{\partial \dot{\varvec{q}}} {\dot{\varvec{q}}} + \frac{\partial \varvec{f}_d}{\partial \dot{\varvec{q}}} \end{aligned}$$
Fig. 17
figure 2

Difference in motion of node 3 between minimum realization, the proposed method and Simscape Multibody in the example of the 2-bar structure shown in Fig. 1a

Fig. 18
figure 3

Bar length constraint violations observed in the example of the 2-bar structure described in Fig. 1a

where

$$\begin{aligned} \frac{\partial \varvec{M}_{\dot{\varvec{q}}}^T}{\partial \varvec{q}} \dot{\varvec{q}}&= \frac{\partial \dot{\varvec{M}}^T}{\partial \varvec{q}} \dot{\varvec{q}}- \frac{\partial \varvec{M}_f^T}{\partial \varvec{q}} \dot{\varvec{q}}\\&= \sum _{k=1}^{n_b} \left[ -2 \frac{I_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^3} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \varvec{q}} \right. \\&\quad -2 \frac{\dot{l}_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^3} \frac{\partial I_{\varvec{b}_k}}{\partial \varvec{q}}\\&\quad -6 \frac{I_{\varvec{b}_k} \dot{l}_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^4} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} + \frac{ \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^2} \frac{\partial \frac{dI_{\varvec{b}_k}}{dt}}{\partial \varvec{q}} \\&\quad \left. -2 \frac{dI_{\varvec{b}_k}}{dt} \frac{ \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^3} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} \right] \\&\quad - \sum _{k=1}^{n_b} \left[ \frac{I_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^3} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \varvec{q}} \right. \\&\quad \left. -3 \frac{I_{\varvec{b}_k} \dot{l}_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^4} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} + \frac{\dot{l}_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^3} \frac{\partial I_{\varvec{b}_k}}{\partial \varvec{q}} \right] \\&= \sum _{k=1}^{n_b} \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}\left[ -3 \frac{I_{\varvec{b}_k}}{{l}_{\varvec{b}_k}^3} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \varvec{q}} - 3 \frac{I_{\varvec{b}_k} \dot{l}_{\varvec{b}_k}}{{l}_{\varvec{b}_k}^4} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} \right. \\&\quad \left. + \frac{ 1}{{l}_{\varvec{b}_k}^2} \frac{\partial \frac{dI_{\varvec{b}_k}}{dt}}{\partial \varvec{q}} -2 \frac{dI_{\varvec{b}_k}}{dt} \frac{1}{{l}_{\varvec{b}_k}^3} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} - 3 \frac{\dot{l}_{\varvec{b}_k}}{{l}_{\varvec{b}_k}^3} \frac{\partial I_{\varvec{b}_k}}{\partial \varvec{q}} \right] \end{aligned}$$

Since \( \varvec{f}_{d,k} = -c \dot{l}_{\varvec{s}_k} \frac{\varvec{s}_k}{{l}_{\varvec{s}_k}}\) is the damping force present in the kth string, \(\frac{\partial \varvec{f}_{d}}{\partial \varvec{q}} = \sum _{k=1}^{n_s} \varvec{Y}_k^T \frac{\partial \varvec{f}_{d,k}}{\partial \varvec{q}}\) where

$$\begin{aligned} \frac{\partial \varvec{f}_{d,k}}{\partial \varvec{q}}&= -c \left( \frac{\varvec{Y}_k \varvec{q}}{{l}_{\varvec{s}_k}} \frac{\partial \dot{l}_{\varvec{s}_k}}{\partial \varvec{q}} + \frac{\dot{l}_{\varvec{s}_k} \varvec{Y}_k}{{l}_{\varvec{s}_k}} - \frac{\dot{l}_{\varvec{s}_k} \varvec{Y}_k \varvec{q}}{{l}_{\varvec{s}_k}^2} \frac{\partial {l}_{\varvec{s}_k}}{\partial \varvec{q}} \right) \end{aligned}$$

Here,

$$\begin{aligned} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}}&= \frac{\varvec{q}^T \varvec{X}_k^T \varvec{X}_k}{ {l}_{\varvec{b}_k}} \\ \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \varvec{q}}&= \frac{\dot{\varvec{q}}^T \varvec{X}_k^T \varvec{X}_k}{ {l}_{\varvec{b}_k}} - \frac{\dot{\varvec{q}}^T \varvec{X}_k^T \varvec{X}_k \varvec{q}}{ {l}_{\varvec{b}_k}^2} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} \\ \frac{\partial I_{\varvec{b}_k}}{\partial \varvec{q}} =&\frac{\partial \left( \frac{m_{\varvec{b}_k}}{12} \left( 3 r_k^2 + l_{\varvec{b}_k}^2 \right) \right) }{\partial \varvec{q}} \\&= \frac{{m_{\varvec{b}_k} {l}_{\varvec{b}_k}}}{6} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} \\ \frac{\frac{dI_{\varvec{b}_k}}{dt}}{\partial \varvec{q}}&= \frac{\partial \left[ \frac{m_{\varvec{b}_k}}{12}\left( 6 r_k \dot{r}_k + 2 \dot{l}_{\varvec{b}_k}{l}_{\varvec{b}_k} \right) \right] }{\partial \varvec{q}} \\&= \frac{m_{\varvec{b}_k}}{12} \left( 6 r_k \frac{\partial \dot{r}_k}{\partial \varvec{q}} + 2 \dot{l}_{\varvec{b}_k} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} + 2 {l}_{\varvec{b}_k} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \varvec{q}} \right) \\ \frac{\partial \dot{r}_k}{\partial \varvec{q}}&= \frac{\partial \left( - \frac{{\nu }_k r_k \dot{l}_{\varvec{b}_k}}{{l}_{\varvec{b}_k}} \right) }{\partial \varvec{q}}\\&= - \frac{{\nu }_k r_k}{{l}_{\varvec{b}_k}} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \varvec{q}} + \frac{{\nu }_k r_k \dot{l}_{\varvec{b}_k}}{{l}_{\varvec{b}_k}^2} \frac{\partial {l}_{\varvec{b}_k}}{\partial \varvec{q}} \\ \frac{\partial {l}_{\varvec{s}_k}}{\partial \varvec{q}}&= \frac{\varvec{q}^T \varvec{Y}_k^T \varvec{Y}_k}{ {l}_{\varvec{s}_k}} \\ \frac{\partial \dot{l}_{\varvec{s}_k}}{\partial \varvec{q}}&= \frac{\dot{\varvec{q}}^T \varvec{Y}_k^T \varvec{Y}_k}{ {l}_{\varvec{s}_k}} - \frac{\dot{\varvec{q}}^T \varvec{Y}_k^T \varvec{Y}_k \varvec{q}}{ {l}_{\varvec{s}_k}^2} \frac{\partial {l}_{\varvec{s}_k}}{\partial \varvec{q}}\\ \frac{\partial \varvec{M}_{\varvec{q}}^T}{\partial \dot{\varvec{q}}} \varvec{q}&= - \sum _{k=1}^{n_b} \left[ \frac{1}{l_{\varvec{b}_k}^3} \varvec{X}_k^T \varvec{X}_k \varvec{q}\dot{l}_{\varvec{b}_k} \frac{\partial \frac{dI_{\varvec{b}_k}}{dt}}{\partial \dot{\varvec{q}}} \right. \\&\quad \left. + \frac{dI_{\varvec{b}_k}}{dt} \frac{\varvec{X}_k^T \varvec{X}_k \varvec{q}}{l_{\varvec{b}_k}^3} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}} \right. \\&\quad \left. -6 \frac{I_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k \varvec{q}\dot{l}_{\varvec{b}_k}}{l_{\varvec{b}_k}^4} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}} \right. \\&\quad + \left( \frac{I_{\varvec{b}_k} \varvec{X}_k^T \varvec{X}_k}{l_{\varvec{b}_k}^3} \right) \left( \frac{2 \varvec{X}_k^T \varvec{X}_k \varvec{q}}{{l}_{\varvec{b}_k}} \dot{\varvec{q}}^T \right. \\&\quad \left. \left. - \frac{\varvec{q}\varvec{q}^T \varvec{X}_k^T \varvec{X}_k \dot{l}_{\varvec{b}_k}}{{l}_{\varvec{b}_k}^2} -\frac{\varvec{q}\varvec{q}^T \varvec{X}_k^T \varvec{X}_k \dot{\varvec{q}}}{{l}_{\varvec{b}_k}^2} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}} \right) \right] \\ \frac{\partial \varvec{M}_{\dot{\varvec{q}}}^T}{\partial \dot{\varvec{q}}} \dot{\varvec{q}}&= \frac{\partial \dot{\varvec{M}}^T}{\partial \dot{\varvec{q}}} \dot{\varvec{q}}-\frac{\partial \varvec{M}_f^T}{\partial \dot{\varvec{q}}} \dot{\varvec{q}}\\&= \sum _{k=1}^{n_b}\left[ -2\left( \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^3} \right) \varvec{X}_k^T\varvec{X}_k \dot{\varvec{q}}\frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}} \right. \\&\quad + \left. \frac{1}{l_{\varvec{b}_k}^2}\varvec{X}_k^T\varvec{X}_k \dot{\varvec{q}}\frac{\partial \frac{dI_{\varvec{b}_k}}{dt}}{\partial \dot{\varvec{q}}} \right] \\&\quad - \sum _{k=1}^{n_b} \frac{I_{\varvec{b}_k}\varvec{X}_k^T\varvec{X}_k \dot{\varvec{q}}}{l_{\varvec{b}_k}^3}\frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}} \\&= \sum _{k=1}^{n_b}\left[ -3 \left( \frac{I_{\varvec{b}_k}}{l_{\varvec{b}_k}^3} \right) \varvec{X}_k^T\varvec{X}_k \dot{\varvec{q}}\frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}} \right. \\&\left. \quad + \frac{1}{l_{\varvec{b}_k}^2}\varvec{X}_k^T\varvec{X}_k \dot{\varvec{q}}\frac{\partial \frac{dI_{\varvec{b}_k}}{dt}}{\partial \dot{\varvec{q}}} \right] \end{aligned}$$

As before, for every kth string,

$$\begin{aligned} \frac{\partial \varvec{f}_{d,k}}{\partial \dot{\varvec{q}}}&= -c \frac{\varvec{Y}_k \varvec{q}}{{l}_{\varvec{s}_k}} \frac{\partial \dot{l}_{\varvec{s}_k}}{\partial \dot{\varvec{q}}} \quad \text {hence,} \quad \frac{\partial \varvec{f}_{d}}{\partial \dot{\varvec{q}}} = \sum _{k=1}^{n_s} \varvec{Y}_k^T \frac{\partial \varvec{f}_{d,k}}{\partial \dot{\varvec{q}}} \end{aligned}$$
Fig. 19
figure 4

Energy violation (34) observed in the example of the 2-bar structure shown in Fig. 1a

Fig. 20
figure 5

Motion error, constraint and energy violations if simulated at \(10^{-14}\) tolerance without any correction in the example of the 2-bar structure shown in Fig. 1a

Here,

$$\begin{aligned} \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}}&=\frac{\varvec{q}^T\varvec{X}_k^T\varvec{X}_k}{l_{\varvec{b}_k}}\\ \frac{\partial \frac{dI_{\varvec{b}_k}}{dt}}{\partial \dot{\varvec{q}}}&=\frac{\partial }{\partial \dot{\varvec{q}}}\left( \frac{m_{\varvec{b}_k}}{12}(6r_k\dot{r}_k+2l_{\varvec{b}_k}\dot{l}_{\varvec{b}_k}) \right) \\&=\left[ \frac{m_{\varvec{b}_k}}{12}(-\frac{6r_k^2 \nu _k}{l_{\varvec{b}_k}}+2l_{\varvec{b}_k}) \right] \frac{\partial \dot{l}_{\varvec{b}_k}}{\partial \dot{\varvec{q}}}\\&=\left[ \frac{m_{\varvec{b}_k}}{12}(-\frac{6r_k^2 \nu _k}{l_{\varvec{b}_k}^2}+2) \right] \varvec{q}^T\varvec{X}_k^T\varvec{X}_k \\ \frac{\partial \dot{l}_{\varvec{s}_k}}{\partial \dot{\varvec{q}}}&=\frac{\varvec{q}^T\varvec{Y}_k^T\varvec{Y}_k}{l_{\varvec{s}_k}} \end{aligned}$$
Fig. 21
figure 6

Computation times for the 2-bar structure example, simulated at different tolerances

Fig. 22
figure 7

Motion error, constraint and energy violations if simulated at \(10^{-10}\) tolerance with and without energy correction in the example of the 2-bar structure shown in Fig. 1a

Fig. 23
figure 8

Motion error, constraint and energy violations if simulated at \(10^{-6}\) tolerance with and without energy correction in the example of the 2-bar structure shown in Fig. 1a

\(\frac{\partial \varvec{\xi }_3 }{ \partial \varvec{\sigma }}\) can be computed as described in the procedure in (47). Therefore,

$$\begin{aligned} \frac{\partial \varvec{\xi }_3 }{ \partial \varvec{\sigma }} = -\varvec{\hat{Y}} \end{aligned}$$

where \(\hat{\varvec{Y}}\in \mathbb {R}^{3n\times n_s}\) such that \(\varvec{\mathsf {vec}}\left( {\hat{\varvec{Y}}}\right) = \varvec{Y}^T\varvec{q}\), which is a rearrangement of the elements of column vector \(\varvec{Y}^T\varvec{q}\) into a matrix of dimension \(3n\times n_s\). Similarly,

$$\begin{aligned} \frac{\partial \varvec{\xi }_3 }{ \partial \varvec{\varPsi }} = \varvec{\hat{X}} \end{aligned}$$

where \(\hat{\varvec{X}}\in \mathbb {R}^{3n\times n_b}\) such that \(\varvec{\mathsf {vec}}\left( {\hat{\varvec{X}}}\right) = \varvec{X}^T\varvec{q}\), which is a rearrangement of the elements of column vector \(\varvec{X}^T\varvec{q}\) into a matrix of dimension \(3n\times n_b\). Finally,

$$\begin{aligned} \frac{\partial \varvec{\xi }_3}{\partial \varvec{f}} = \varvec{I} \end{aligned}$$

Let

$$\begin{aligned} \varvec{\xi }_4 = \frac{\partial \varvec{\xi }_3}{\partial \varvec{q}} \delta \varvec{q}+ \frac{\partial \varvec{\xi }_3}{\partial \dot{\varvec{q}}} \delta \dot{\varvec{q}} + \frac{\partial \varvec{\xi }_3}{\partial \varvec{\sigma }} \delta \varvec{\sigma } + \frac{\partial \varvec{\xi }_3}{\partial \varvec{\varPsi }} \delta \varvec{\varPsi } +\frac{\partial \varvec{\xi }_3}{\partial \varvec{f}} \delta \varvec{f} \end{aligned}$$

Then, since at equilibrium, \(\ddot{\varvec{q}} = 0\), equations are reduced to:

$$\begin{aligned} \begin{bmatrix} \varvec{M}_{\ddot{\varvec{q}}} &{} -\varvec{R}_{\varvec{q}}^T \\ -\varvec{R}_{\varvec{q}}&{} \varvec{0} \end{bmatrix} \begin{bmatrix} \delta \ddot{\varvec{q}} \\ \delta \varvec{\lambda } \end{bmatrix} = \begin{bmatrix} \varvec{\xi }_4 \\ \varvec{0} \end{bmatrix} \end{aligned}$$

The matrix on the left is invertible, irrespective of configuration. This means,

$$\begin{aligned} \begin{bmatrix} \delta \ddot{\varvec{q}} \\ \delta \varvec{\lambda } \end{bmatrix} = \begin{bmatrix} \varvec{M}_{\ddot{\varvec{q}}} &{} -\varvec{R}_{\varvec{q}}^T \\ -\varvec{R}_{\varvec{q}}&{} \varvec{0} \end{bmatrix}^{-1} \begin{bmatrix} \varvec{\xi }_4 \\ \varvec{0} \end{bmatrix} \end{aligned}$$
(57)

Let

$$\begin{aligned} \varvec{M}_{\varvec{\alpha }}&= \begin{bmatrix} \varvec{M}_{\ddot{\varvec{q}}} &{} -\varvec{R}_{\varvec{q}}^T \\ -\varvec{R}_{\varvec{q}}&{} \varvec{0} \end{bmatrix}^{-1}, \quad \text {and} \\ \varvec{M}_{\varvec{\beta }}&=\varvec{M}_{\varvec{\alpha }}(1:3n,1:3n), \end{aligned}$$

i.e., \(\varvec{M}_{\varvec{\beta }}\) is derived from the first 3n rows and columns of \(\varvec{M}_{\varvec{\alpha }}\). Reducing (57), we get:

$$\begin{aligned} \delta \ddot{\varvec{q}} = \varvec{M}_{\varvec{\beta }} \varvec{\xi }_4 \end{aligned}$$

Defining,

$$\begin{aligned} \varvec{A}&:= \begin{bmatrix} \varvec{0}&{}\varvec{I}\\ \varvec{M}_{\varvec{\beta }} \frac{\partial \varvec{\xi }_3}{\partial \varvec{q}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0, \varvec{\varPsi }_0,\varvec{f}_0}&{} \varvec{M}_{\varvec{\beta }} \frac{\partial \varvec{\xi }_3}{\partial \dot{\varvec{q}}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0, \varvec{\varPsi }_0,\varvec{f}_0} \end{bmatrix}\\ \varvec{B_{\varvec{u}}}&:= \begin{bmatrix} \varvec{0} &{} \varvec{0}\\ \varvec{M}_{\varvec{\beta }} \frac{\partial \varvec{\xi }_3}{ \partial \varvec{\sigma }}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0, \varvec{\varPsi }_0,\varvec{f}_0}&{} \varvec{M}_{\varvec{\beta }} \frac{\partial \varvec{\xi }_3}{ \partial \varvec{\varPsi }}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0, \varvec{\varPsi }_0,\varvec{f}_0} \end{bmatrix}\\ \varvec{B_f}&:= \begin{bmatrix} \varvec{0}\\ \varvec{M}_{\varvec{\beta }} \frac{\partial \varvec{\xi }_3}{\partial \varvec{f}}|_{\varvec{q}_0,\dot{\varvec{q}}_0,\varvec{\sigma }_0, \varvec{\varPsi }_0, \varvec{f}_0} \end{bmatrix} \end{aligned}$$

we can write the linear system as

$$\begin{aligned} \dot{\varvec{x}} = \varvec{A} \varvec{x} + \varvec{B_u}\delta \varvec{u} + \varvec{B_f}\delta \varvec{f}, \end{aligned}$$
(58)

where \(\varvec{x} :=\begin{bmatrix}\delta \varvec{\varvec{q}} \\ \delta \dot{\varvec{q}}\end{bmatrix}\) and \(\varvec{u} :=\begin{bmatrix}\delta \varvec{\sigma } \\ \delta {\varvec{\varPsi }}\end{bmatrix}\).

Again, note that (58) is not a minimal realization of the tensegrity system due to the presence of the constraints acting on \(\delta \varvec{q}\), despite the relaxation of bar length constraints. Linear constraints may still be acting on the system, thereby rendering it non-minimal.

Fig. 24
figure 9

Motion error of Node 3 if simulated at \(10^{-10}\) tolerance with and without energy correction at different rest lengths in the example of the 2-bar structure shown in Fig. 1a

3.4 Summary

Section 3 presented a detailed description of the derivations that had to be amended in the general multibody system approach to account for compressibility in bars. A gist of the approach is presented as follows.

  1. 1.

    Energies: Additional terms will be introduced into the kinetic and potential energies to account for flexibility in bars.

    $$\begin{aligned} {T}&= \frac{1}{2}\dot{\varvec{q}}^T \varvec{M} \dot{\varvec{q}}- T_f\\ V_s&= \frac{1}{2} \varvec{q}^T \varvec{Y} (\frac{\varvec{\sigma ^2}}{\varvec{K}_s} \otimes \varvec{I}_{3n}) \varvec{q}+ \frac{1}{2} \varvec{q}^T \varvec{Y} (\frac{\varvec{\psi ^2}}{\varvec{K}_b} \otimes \varvec{I}_{3n}) \varvec{q}\end{aligned}$$

    Here, \(T_f\) is the kinetic energy injected to account for longitudinal deformation in the bar, i.e., \(\dot{l}_{\varvec{b}_k}\) is no longer zero. In the absence of nonlinear bar length constraints, for a generic system,

    $$\begin{aligned} \varvec{R}(\varvec{q}) := \begin{bmatrix} \varvec{A}\varvec{q}- \varvec{b} \end{bmatrix} \end{aligned}$$
  2. 2.

    Equations of Motion: The governing equations of motion have now been amended to:

    $$\begin{aligned} \varvec{M}_{\ddot{\varvec{q}}}\ddot{\varvec{q}} - \varvec{R}_{\varvec{q}}^T\varvec{\lambda } =&-\left[ \varvec{M}_{\varvec{q}}^T + (\varvec{\varPsi }^T \otimes \varvec{I}_{3n})\varvec{X}^T \right. \\&\left. +(\varvec{\sigma }^T \otimes \varvec{I}_{3n})\varvec{Y}^T\right] \varvec{q}\\&-\varvec{M}_{\dot{\varvec{q}}}^T\dot{\varvec{q}} + \varvec{G} + \varvec{f} + \varvec{f}_d \end{aligned}$$

    Linearization follows the same approach described as before, but the introduction of elasticity necessitates re-evaluation of state and control matrices.

4 Example

In this section, we model a simple tensegrity structure in 2 dimensions as an example to demonstrate the accuracy of the constraints and motion trajectories using the proposed approach. We also compare our results with those obtained using a commercial tool, i.e. Simscape [31]. In addition, a robotic arm and a ball based on tensegrity structures as two examples are presented to show the efficiency of the method applied to models with higher complexity. The user-defined properties are listed in Table 1. In particular, corrected numerical integration is utilized by Matlab to these different models. The equation of motion (21) is integrated based on the Dormand-Prince method [11, 42] with relative and absolute tolerances of \(10^{-10}\), both constraint correction and energy correction turned on, and the given threshold \(\gamma =10^{-10}\).

First of all, a 2D tensegrity structure built using 2 bars and 4 springs shown in Fig. 1a is used, where the nodes at the bottom are fixed and the left and right springs are pre-stressed at \(90\%\) of the rest length of the springs. Secondly, a robotic arm built from 3 sets of squares is shown in Fig. 1b, where strings made of nylon are prestressed so that the structure is in equilibrium under gravity. An external force of a time-dependent sinusoidal function is applied vertically to the tip of the arm. Thirdly, a 3D ball with a payload is shown in Fig. 1c, where 6 bars and 32 strings are used. Here too, strings are prestressed so that the structure can be in equilibrium under gravity. A time-dependent external force of a sinusoidal function is given to the top 3 nodes in different directions, i.e. along x, y, z axes respectively (in order of numbering).

Fig. 25
figure 10

Motion trajectories of the particular nodes in the example of the arm shown in Fig. 1b

Fig. 26
figure 11

Bar length errors in the example of the arm shown in Fig. 1b, where the value of zero is set to the minimum positive double precision number

Figure 2a shows the discrepancies between the motion trajectories obtained using the proposed approach and the minimum realization, where we consider the latter as the benchmark since the equations of motion are derived using generalized coordinates that preserve the geometric constraints and the relative and absolute tolerance of numerical integration is \(2.2\times 10^{-14}\) (This is the minimum value of relative tolerance that can be chosen in Matlab.) and \(10^{-14}\) respectively, while Fig. 2b shows the differences between Simscape and minimum realization, where Simscape is with the same numerical method and tolerance as minimum realization. Comparing the figures, we observe that our proposed method produces the motion \(10^7\) times closer to the benchmark than Simscape, which indicates a significant improvement in accuracy. Figures 3a, b and 4 present the magnitude of constraint violations in bar length and total energy, which shows that the proposed method of constraint correction reduces the violation of the energy to around \(10^{-11}\) and keeps the bar length constraint violations at about \(10^{-12}\) simultaneously. One can observe that the bar length violations in the simulation produced using Simcape are of a smaller magnitude. This is because it utilizes generalized coordinates, thereby automatically satisfying the bar length constraints. The differences in motion seem to be increasing in time, but in fact, simulating for very long durations would show them to be within bounds, as can also be said by observing the total energy variation. Since the energy is always stable from Fig. 4, the motion must be stable and therefore, the differences are all bounded. The attached video TEST_TBAR.mp4 demonstrates the motions of the 2-bar structure with 3 approaches in real time.

We also compared the time required to run a 10 s simulation in each of the approaches being compared here. Simscape Multibody required \(\sim \) 1.1 s on average to run a T-bar simulation, while the proposed approach required \(\sim \) 2.4 s with correction built in. We expect to see a bigger difference when simulating a model with higher complexity, as with more bars present in the structure, more computational effort would be required to prevent constraint violation. The computational advantage of Simscape could also be due to several code optimizations, and an underlying mixture of programming engines including C and Fortran that gives it the additional speed up. These are implementation details that can be accounted in our formulation as well. Our code currently does not have any speed optimization, and we will address it in our future work. Nonetheless, our framework allows for easier modeling of tensegrity structures, which becomes prohibitively complex in Simscape.

Fig. 27
figure 12

Energy violation (34) of the arm shown in Fig. 1b

It is important to note here that, when simulating tensegrity systems with non-minimum coordinates at machine-level precision tolerance settings (at the expense of speed), the user might be tempted to do away with correction altogether. However, the solution, while still being accurate in its motion trajectory for short time lengths, drifts away from the constraint space and consequently, tends to become inaccurate if simulated for long durations. As Yoon [52] points out, it is a necessary condition for accurate simulation that both geometric and energy constraints be satisfied during integration. Hence, it would be advisable to keep the correction algorithm turned on at all times. Fig. 5a shows how accurately the non-minimum formulation performs without the need for correction at the tolerance settings of \(10^{-14}\), and the constraint and energy violations as presented in Fig. 5b–d present the extent of the associated constraint drift. Figure 6 shows the plot for computation times for the T-bar example, simulated at different tolerance settings ranging from \(10^{-6}\) to \(10^{-14}\). This goes to show that if computation speeds are a higher priority than accuracy, it would be much more prudent to perform simulations at lower tolerance settings like \(10^{-9}\) or \(10^{-10}\) with correction turned on than to do it at \(10^{-14}\) without any correction at all.

To investigate the impact of the energy preservation scheme of the T-bar, we simulated the T-bar example at 2 different tolerance settings (\(10^{-6}\) and \(10^{-10}\)), and at 3 different rest lengths(\(50\%\), \(70\%\), and \(90\%\)). We found a considerably stronger effect at a higher tolerance setting than at a lower one, for the same rest length \(50\%\), as indicated by the order of magnitude of motion errors in Figs. 8a and 7a respectively. Figures 7c, d and 8c, d demonstrate the consistency of the direct constraint correction scheme in stabilizing geometric constraint violations below a specified norm bound, despite a large difference in the order of magnitude of tolerance. In Fig. 9a, b, the T-bar example is simulated at a tolerance of \(10^{-10}\) for rest lengths of \(50\%\), \(70\%\), and \(90\%\). Evidently, larger deformations in the \(50\%\) case bring energy correction into play more effectively.

Fig. 28
figure 13

Motion and energy violations in the example of the ball shown in Fig. 1c

Fig. 29
figure 14

Bar length errors in the example of the ball shown in Fig. 1c, where the value of zero is set to the minimum positive double precision number

For the example of the robotic arm, Fig. 10a shows the motion of node 5, node 8 and node 10 for 20 s. Since we’ve simulated the structure with nylon strings (Young’s modulus: 2 GPa), the structure appears to be chattering intermittently. Figures 11 and 12 show the constraint violations of bar length and energy. The order of the violations testifies to the stability of the constraints for problems involving intricate geometries. One can observe that the bar length constraints of bars #3, #6, #11 amd #14 are violated more than others in the observed time period and nodes #4,#7,#12,#14 in Fig. 10b are vibrating in higher frequencies, which implies a positive correlation between constraint variations and motion frequencies. Figure 13a depicts the motion of the 3-dimensional ball which is in accordance with the high stiffness of the strings. Preserving the order of constraint violations as observed in the second example, Figs. 14 and 13b demonstrate the ability of the implemented correction method to maintain stability of the constraints despite an increase in complexities associated with 3 dimensions. The videos capturing the real-time motion of the structures and the relevant code to generate simulations are publicly available [48].

Fig. 30
figure 15

Difference in motion for the Tbar shown in Fig. 1a, but with compressible bars, compared against Tbar with rigid bars but no correction applied

Fig. 31
figure 16

Motion plots for the Tbar shown in Fig. 1a, using compressible bars made of HDPE

Further, we redo the constrained T-bar dynamics, but substitute the rigid bars in the structure with compressible ones. While this elasticity allows us to relax the bar length constraints during simulation, the DAE becomes a stiff problem, requiring us to choose a solver from the stiff ODE suite, e.g. [42]. As we can observe from Fig. 15, the difference in motion from simulations of a T-bar with compressible bars against a T-bar with rigid bars but without any constraint correction implemented, is of the order of \(10^{-7}\).

Figure 16 shows the motion of the unfixed nodes in the same T-bar structure being simulated with compressible bars, but this time, the bars are assumed to be of a different material. High Density Poly Ethylene (HDPE), a polymer-based material used to construct pneumatic struts in inflatable tensegrity systems [9], replaces conventionally used metals like steel or aluminium. The mean computation time for simulating a T-bar for 10 s using soft HDPE bars was \(\sim \) 39.18 s, while that for using aluminium bars was \(\sim \) 502.2 s, a difference of nearly 1100%. Evidently, using a softer bar material speeds up the computation by a significant margin.

Fig. 32
figure 17

Compressible T-bar using soft and metallic bars subjected to doublet force of 10 N

Fig. 33
figure 18

Deviation of free nodes from equilibrium for the Tbar shown in Fig. 1a, using compressible bars made of HDPE and Aluminium

Finally, we sought to investigate the characteristics of the two systems (soft vs metallic) from a control engineer’s perspective. The linearized models help us analyse the norms of the system [12], which in this case, implies the relationship between the size of the output signal’s energy or amplitude to that of the input signal’s energy. Even though the linearized model may differ significantly from the true nonlinear model at points far away from equilibrium, they allow us to draw preliminary inferences regarding metrics like system robustness to disturbance. Table 2 summarizes the properties of the two types of bars we used for simulating the T-bar using the compressible formulation. The resulting observations concerning the system norms and corresponding input–output relationships are also present in the table. On being subjected to a doublet force of amplitude 10 N (Fig. 17), observe the deflection of the free nodes in Fig. 18. Clearly, the T-bar with rigid metallic bars exhibits larger deviations when subject to the same force, when compared to the T-bar with softer bars. Note that due to the large difference in stiffnesses of the bars and the strings in the T-bar structure, the eigenvalues of the resulting compliance matrix do not differ meaningfully when we replace the conventionally used aluminium bars with those made of HDPE, as can be seen in Fig. 19. This essentially means that given a certain force, amplitudes of static deflection would be remarkably similar for either kind of bar material. In such scenarios, given budgetary considerations on structural weight, it would be worth investigating whether replacing stiff metallic bars with bars made of softer materials would yield comparable strength for lower mass.

Fig. 34
figure 19

Eigenvalues of the compliance matrix for the T-bar in Fig. 1a using soft and metallic bars

Table 2 Comparison of soft and metallic bars in the compressible T-bar example

5 Conclusions

Informally characterized as a network of axially loaded bars and cables, tensegrity structures are an increasingly popular subset of multibody systems finding applications in several diverse domains ranging from space robotics to biological modeling. In this paper, equations of motion for analysing the dynamics of tensegrity structures were developed in Cartesian coordinates, i.e., a non-minimum set of coordinates, using Lagrangian mechanics.

The use of non-minimum coordinates necessitates an active effort to prevent constraint violations, since numerical errors creep up on the constraint space when integrating the governing equations of motion of an overparameterized system. A direct correction approach was employed to ensure that constraints are adhered to, not only in position and velocity, but also in total mechanical energy. Simulations comparing our approach with the commercially available Simscape Multibody illustrate the superiority of our formulation in terms of numerical accuracy. The correction method ensures stability of constraints in 3-dimensional complex tensegrity systems as well. The differences with and without correction grow as the structure exhibits larger motion amplitudes, or more commonly when the error of numerical integration is unchecked for long simulation time spans. Further, a linearization of the associated equations of motion was derived to facilitate future work in control.

We also considered compressible bars, wherein bars are no longer geometrically constrained. This will allow a deeper investigation into advanced compliant tensegrity structures that might incorporate softer bars in their architecture. We conducted one such analysis comparing a linearized compressible system with 2 different kinds of bars, one made using soft HDPE and the other with conventionally used aluminium. It revealed the limited effect of bar rigidity on the amplitudes of static deflection, an interesting insight that raises further questions concerning bar material choices given strength and mass considerations.