1 Introduction

In recent years, various types of mechanisms have been developed to make a robot move naturally like animals do. During the late 1990s, a new type of robotic mechanism was introduced by Fukuda et al. (1991) that imitated the movement of an ape swinging from one branch to another. The swinging motion of an ape is shown in Fig. 1.

Fig. 1
figure 1

Brachiation of the long-armed ape on uneven supports

The brachiation control problem was introduced to the robotics literature in Saito et al. (1994), where a simple two-link brachiation robot was presented and a heuristic learning method for generating feasible trajectory for the robot was proposed. Fukuda, Hasegawa, Shimojima and Saito developed a self-scaling reinforcement learning algorithm. Later, Saito added a feedback controller to improve the robustness of the method (Hasegawa et al. 1999). The main shortcoming of their method is the long training time required for a successful movement. Nakanishi et al. (2000) took another approach, using target dynamics to control brachiation underactuated systems. Kajima et al. (2003) used a local behavior control to control the multi-locomotion robot to perform brachiation. An energy-based control to the swing phase of brachiation is presented in Kajima et al. (2006) with the purpose of minimizing the amount of input energy in the swing phases. In Zhao et al. (2008) an energy-based control combined with Lyapunov stability theory is proposed. In Fukuda et al. (2007) a control strategy for brachiation motion considering irregular ladder is proposed based on passive dynamic autonomous control (PDAC).

The method of CL has been developed to stabilize Lagrangian systems by shaping the mechanical energy. The basic idea in this method is to transform, by appropriate feedback, a given Lagrangian system to another Lagrangian system with positive definite energy function. A dissipative part can also be introduced in this method to enforce the decrease in energy, making it a good candidate for Lyapunov function.

The method of CL is also called the energy shaping method. The work in (Arimoto 1984), where potential energy was shaped to stabilize a fully actuated robot manipulator, was a pioneer in energy shaping methods. A kinetic shaping technique was later introduced in Bloch et al. (2001) to stabilize the unstable rotational motion of an underactuated satellite. Total energy shaping was introduced through a series of papers (Bloch et al. 1992, 1997, 2000, 2001a, b). Force shaping was first investigated in Gómez-Estern et al. (2004) and Woolsey et al (2004), and a more formal form of energy shaping was presented in Auckly and Kapitanski (2002), Auckly et al. (2000) and Hamberg (1999). More recently, in Tavallaeinejad (2016) the CL method has been employed to design tracking controller for a micro-cantilever beam with rotating joint.

In this paper, a brachiation robot is controlled using the Controlled Lagrangians (CL) method. The extended λ-method (Chang 2005) is used to formulate PDEs involved in the method of Controlled Lagrangians. The PDEs are then solved to derive the control law. Because of the complex controller synthesis algorithm of the Controlled Lagrangians method, often the insight into the physical meaning of various terms in the control law will be lost. This results in a cumbersome tuning process for the controller parameters. To overcome this drawback and to find satisfactory controller parameters, this paper proposes a PSO algorithm. Feasibility of the developed controller is further investigated by numerical simulations and experimental observations.

Theoretical parts of this paper were presented in Tashakori et al. (2014). The current manuscript integrates these results with new simulation results, experimental validations and improved readability.

The paper is organized as follows. In Sect. 2 the governing equations of motion of the brachiation robot are derived. Section 3 briefly reviews the CL method. In Sect. 4 the extended λ-equations that formulate the matching conditions involved in the method of CL are discussed. In Sect. 5 the λ-equations are solved to design a controller. Section 6 reviews the PSO algorithm, and Sect. 7 presents the simulation and experiment results.

2 System Dynamics

The simplified model for a brachiating robot is a planar double pendulum which is actuated at the elbow joint. The parameters and the generalized coordinate of the system are shown in Fig. 2.

Fig. 2
figure 2

Kinematic and dynamic parameters and generalized coordinates of the simplified brachiating robot

The Euler–Lagrange equation is used to obtain the equation of motion of the system. The Lagrangian of the system is defined by

$$ L = K - U = \frac{1}{2}\dot{q}^{T} M\left( q \right)\dot{q} - U\left( q \right), $$
(1)

where K is the kinetic energy and U is the potential energy of the system. M(q) is the inertia matrix which is a symmetric positive-definite matrix, and \( q = \left[ {\theta_{1} , \theta_{2} } \right]^{T} \) is the generalized coordinate vector and represents the joint position. The Euler–Lagrange equation states that

$$ {\mathcal{E}\mathcal{L}}\left( L \right) = F + u, $$
(2)

where \( \varepsilon {\mathcal{L}} \) is the Euler–Lagrange operator defined by

$$ {\mathcal{E}\mathcal{L}}\left( L \right) = \frac{\text{d}}{{{\text{d}}t}}\left( {\frac{\partial L}{{\partial \dot{q}_{i} }}} \right) - \frac{\partial L}{{\partial q_{i} }}, $$
(3)

and u is the vector of joint torques and F is the external force. Using above formulas, the equation of motion of the system is obtained as

$$ M\left( q \right)\ddot{q} + C\left( {q,\dot{q}} \right)\dot{q} + G\left( q \right) = F + u, $$
(4)

where \( C\left( {q,\dot{q}} \right) \) is the matrix of the centrifugal and Coriolis terms and G(q) represents the vector of gravitational forces. The brachiating robot is underactuated, because the actuation torque is only applied on the middle joint and no torque is exerted between the gripper and the supporting bar. Hence, the vector of the applied joint torque has the form:

$$ u = \left[ {\begin{array}{*{20}c} 0 \\ \tau \\ \end{array} } \right], $$
(5)

where τ is the torque exerted on the joint between links 1 and 2.

The inertia matrix, the matrix of centrifugal and Coriolis terms and the vector of gravitational effect are given by:

$$ \begin{aligned} & M = \left[ {\begin{array}{*{20}c} {m_{1,1} } & {m_{1,2} } \\ {m_{2,1} } & {m_{2,2} } \\ \end{array} } \right] \\ & m_{1,1} = a_{1} + 2a_{2} { \cos }\left( {\theta_{2} } \right) \\ & m_{2,2} = a_{3} \\ & C = \left[ {\begin{array}{*{20}c} {c_{1,1} } & {c_{1,2} } \\ {c_{2,1} } & {c_{2,2} } \\ \end{array} } \right] \\ & c_{1,1} = - a_{2} \sin \left( {\theta_{2} } \right)\dot{\theta }_{2} \\ & c_{1,2} = - a_{2} \sin \left( {\theta_{2} } \right)\left( {\dot{\theta }_{1} + \dot{\theta }_{2} } \right) \\ & c_{2,1} = a_{2} \sin \left( {\theta_{2} } \right)\dot{\theta }_{1} \\ & c_{2,2} = 0 \\ & G = \left[ {\begin{array}{*{20}c} {b_{1} \sin \left( {\theta_{1} } \right) + b_{2} \sin \left( {\theta_{1} + \theta_{2} } \right)} \\ {b_{2} \sin \left( {\theta_{1} + \theta_{2} } \right)} \\ \end{array} } \right], \\ \end{aligned} $$
(6)

where

$$ \begin{aligned} & a_{1} = m_{2} l_{1}^{2} + m_{1} l_{{{\text{c}}1}}^{2} + m_{2} l_{{{\text{c}}2}}^{2} + I_{1} + I_{2} \\ & a_{2} = m_{2} l_{1} l_{{{\text{c}}2}} \\ & a_{3} = m_{2} l_{{{\text{c}}2}}^{2} + I_{2} \\ & b_{1} = \left( {m_{1} l_{{{\text{c}}1}} + m_{2} l_{1} } \right)g \\ & b_{2} = m_{2} l_{{{\text{c}}2}} g, \\ \end{aligned} $$
(7)

and mi, li and lci are the mass, length and center of mass of link \( i, \left( {i = 1,2} \right) \), respectively. Ii is the moment of inertia of the link i about an axis perpendicular to the plane of motion at the center of mass, and g is the gravitational acceleration. Kinematic and dynamic parameters of the brachiating robot for the first swing are shown in Table 1.

Table 1 Kinematic and dynamic parameters of the brachiation robot

3 CL Systems

Definition 1

A (simple) Controlled Lagrangians system is a triple, \( \left( {L, F, W} \right) \) where L is Lagrangian of the system, F is external force exerted on the system, and W is called control subbundle that is a subspace of the generalized coordinates in which the control force can be applied.

Definition 2

Given two systems \( \left( {L, F, W} \right) \) and \( (\hat{L},\hat{F},\hat{W}) \)), the Euler–Lagrange matching conditions are

$$ \begin{aligned} & ELM \text{-} 1 \, :W = M\hat{M}^{ - 1} \left( {\hat{W}} \right) \\ & ELM \text{-} 2: \text{Im} \left[ {\left( {\varepsilon {\mathcal{L}}\left( L \right) - F} \right) - M\hat{M}^{ - 1} \left( {\varepsilon {\mathcal{L}}\left( {\hat{L}} \right) - \hat{F}} \right)} \right] \subset W, \\ \end{aligned} $$
(8)

where Im means the pointwise image of the linear map in brackets. We say that the two simple Lagrangian systems \( \left( {L, F, W} \right) \) and \( (\hat{L},\hat{F},\hat{W}) \) are equivalent if ELM-1 and ELM-2 hold (Chang 2005).

Proposition 3

Suppose two simple Controlled Lagrangians systems\( \left( {L, F, W} \right) \)and\( (\hat{L},\hat{F},\hat{W}) \)are equivalent. Then, for any controller\( \hat{u} \)there exists a controller u such that the two closed-loop system\( \left( {L, F, W} \right) \)and\( (\hat{L},\hat{F},\hat{W}) \)produce the same equations of motion, and vice versa. The explicit relation between u and\( \hat{u} \)is given by

$$ u = \left( {{ \mathcal{E}\mathcal{L}}\left( L \right) - F} \right) - M\hat{M}^{ - 1} \left( {{\mathcal{E}\mathcal{L}}\left( {\hat{L}} \right) - \hat{F}} \right) + M\hat{M}^{ - 1} \hat{u} , $$
(9)

where M is the mass matrix of the Lagrangian L and\( \hat{M} \)is the mass matrix of\( \hat{L} \).

4 Extended Lambda Method

In Chang ( 2005), Chang makes a complete development of the extended λ-method in a coordinate-free way exclusively on the Lagrangian side to solve PDEs involved in the Controlled Lagrangians systems. Before describing the extended λ-method, let us define the Christoffel symbol.

Definition 3

Given a local coordinate system \( x^{i} , i = 1,2, \ldots n \) on a n-manifold M with metric tensor g, the Christoffel symbol of the first kind is defined as

$$ \left[ {ab,c} \right] = \frac{1}{2}\left( {\frac{{\partial g_{ca} }}{{\partial x^{b} }} + \frac{{\partial g_{cb} }}{{\partial x^{a} }} - \frac{{\partial g_{ab} }}{{\partial x^{c} }}} \right) $$
(10)

Considering above definition, the λ-equations in generalized coordinates are

$$ \frac{{\partial \left( {m_{\alpha i} \lambda_{\beta }^{i} } \right)}}{{\partial q^{k} }} - \left[ {\alpha k,i} \right]\lambda_{\beta }^{i} - \left[ {\beta k,i} \right]\lambda_{\alpha }^{i} = \frac{1}{2}\left( {\hat{G}_{ijk} + \hat{G}_{jik} } \right) \lambda_{\alpha }^{i} \lambda_{\beta }^{i} $$
(11)
$$ \lambda_{\alpha }^{k} \frac{{\partial \hat{m}_{ij} }}{{\partial q^{k} }} + \frac{{\partial \lambda_{\alpha }^{k} }}{{\partial q^{i} }}\hat{m}_{kj} + \frac{{\partial \lambda_{\alpha }^{k} }}{{\partial q^{j} }}\hat{m}_{ki} = \frac{{\partial m_{ij} }}{{\partial q^{\alpha } }} - \left( {\hat{G}_{ijk} + \hat{G}_{jik} } \right)\lambda_{\alpha }^{k} $$
(12)
$$ \lambda_{\alpha }^{k} \frac{{\partial \hat{U}}}{{\partial q^{k} }} = \frac{\partial U}{{\partial q^{\alpha } }} , $$
(13)

where \( i, j, k = 1, \ldots , s\,\,{\text{and}}\,\,\alpha , \beta = 1, \ldots , r \) (s is the degrees of freedom and r is the number of control inputs), \( \hat{G} \) is a (0, 3)-tensor satisfying \( \hat{G}_{ijk} = \hat{G}_{jik} ,\hat{G}_{ijk} + \hat{G}_{jki} + \hat{G}_{kij} = 0 \) and

$$ \lambda = \hat{M}^{ - 1} M $$
(14)

5 Design of the Controller

We apply the extended λ-method to design a feedback control law for the brachiating robot shown in Fig. 2. This system can be described as a CL system (L, 0, W) where

$$ L = \frac{1}{2}\left( {a_{1} + 2a_{2} \cos \theta_{2} } \right)\dot{\theta }_{1}^{2} + \left( {a_{3} + a_{2} \cos \theta_{2} } \right)\dot{\theta }_{1} \dot{\theta }_{2} + \frac{1}{2}a_{3} \dot{\theta }_{2}^{2} + b_{1} \cos \theta_{1} + b_{2} \cos \left( {\theta_{1} + \theta_{2} } \right) $$
(15)

and ai and \( b_{i} \) were introduced in (7) and

$$ W = \left[ {\begin{array}{*{20}c} 0 \\ 1 \\ \end{array} } \right] $$
(16)

Then, the nonzero Christoffel symbols of the first kind, seen in (11), are given by

$$ h = - a_{2} \sin (\theta_{2} ) $$
(17)

By choosing \( \hat{G}_{211} = \hat{G}_{121} = G_{1}, \)\( \hat{G}_{212} = \hat{G}_{122} = G_{2} \),\( \hat{G}_{111} = \hat{G}_{222} = 0 \), \( \hat{G}_{112} = - 2G_{1} \) and \( \hat{G}_{221} = - 2G_{2}, \) the λ-equations in (11) are given by:

$$ m_{1,1} \frac{{\partial \lambda_{1}^{1} }}{{\partial \theta_{1} }} + m_{1,2} \frac{{\partial \lambda_{1}^{2} }}{{\partial \theta_{1} }} - 2a_{2} { \sin }\theta_{2} \lambda_{1}^{2} - 2G_{1} \lambda_{1}^{1} \lambda_{1}^{2} + 2G_{2} \lambda_{1}^{1} \lambda_{1}^{2} = 0 $$
(18)
$$ \frac{{\partial (m_{1,1} \lambda_{1}^{1} )}}{{\partial \theta_{2} }} + \frac{{\partial (m_{1,2} \lambda_{1}^{2} )}}{{\partial \theta_{2} }} + 2a_{2} { \sin }\theta_{2} \lambda_{1}^{2} + 2G_{1} \lambda_{1}^{1} \lambda_{1}^{1} - 2G_{2} \lambda_{1}^{1} \lambda_{1}^{2} = 0 $$
(19)

Since we have more unknowns than equations in (18) and (19), we choose:

$$ \lambda_{1}^{1} = \frac{ - 1}{{C_{1} }} , \lambda_{1}^{2} = \frac{2}{{C_{1} }} , G_{1} = 0 , G_{2} = \frac{1}{2}C_{1} a_{2} { \sin }\theta_{2} , $$
(20)

where C1 is a constant. Therefore, (12) becomes:

$$ \left\{ {\begin{array}{*{20}l} {\frac{ - 1}{{C_{1} }}\frac{{\partial \hat{m}_{11} }}{{\partial \theta_{1} }} + \frac{2}{{C_{1} }}\frac{{\partial \hat{m}_{11} }}{{\partial \theta_{2} }} = 0} \\ {\frac{ - 1}{{C_{1} }}\frac{{\partial \hat{m}_{12} }}{{\partial \theta_{1} }} + \frac{2}{{C_{1} }}\frac{{\partial \hat{m}_{12} }}{{\partial \theta_{2} }} = - 2a_{2} { \sin }\theta_{2} } \\ {\frac{ - 1}{{C_{1} }}\frac{{\partial \hat{m}_{22} }}{{\partial \theta_{1} }} + \frac{2}{{C_{1} }}\frac{{\partial \hat{m}_{22} }}{{\partial \theta_{2} }} = - 2a_{2} { \sin }\theta_{2} } \\ \end{array} } \right. $$
(21)

One can solve the first equation in (21) by choosing \( \hat{m}_{11} \) to be a constant:

$$ \hat{m}_{11} = C_{2} $$
(22)

Note that there is no need to solve the other two equations in (21) for \( \hat{m}_{12} \) and \( \hat{m}_{22} \). Instead, using (14), we obtain:

$$ \hat{m}_{12} = \frac{1}{2}C_{1} \left( {a_{1} + 2a_{2} { \cos }\theta_{2} } \right) + \frac{1}{2}C_{2} $$
(23)
$$ \hat{m}_{22} = \frac{1}{4}C_{1} \left( {a_{1} + 4a_{2} { \cos }\theta_{2} + 2a_{3} } \right) + \frac{1}{4}C_{2} , $$
(24)

and \( \hat{C} \) is given by

$$ \hat{C} = C_{1} a_{2} { \sin }\theta_{2} \dot{\theta }_{2} \left[ {\begin{array}{*{20}c} 0 & { - 1} \\ 0 & { - \frac{1}{2}} \\ \end{array} } \right] $$
(25)

Hence, (13) can be rewritten as

$$ \frac{ - 1}{{C_{1} }}\frac{{\partial \hat{U}}}{{\partial \theta_{1} }} + \frac{2}{{C_{1} }}\frac{{\partial \hat{U}}}{{\partial \theta_{2} }} = b_{1} { \sin }\theta_{1} + b_{2} { \sin }(\theta_{1} + \theta_{2} ), $$
(26)

which leads to

$$ \hat{U} = b_{1} C_{1} { \cos }\theta_{1} - b_{2} C_{1} \cos \left( {\theta_{1} + \theta_{2} } \right) + F_{1} \left( {2\theta_{1} + \theta_{2} } \right), $$
(27)

where

$$ F_{1} \left( {2\theta_{1} + \theta_{2} } \right) = \frac{1}{2}C_{3} \left( {2\theta_{1} + \theta_{2} } \right)^{2} , $$
(28)

and \( \hat{G} \) is given by

$$ \hat{G} = \left[ {\begin{array}{*{20}c} {\frac{{\partial \hat{U}}}{{\partial \theta_{1} }}} \\ {\frac{{\partial \hat{U}}}{{\partial \theta_{2} }}} \\ \end{array} } \right] $$
(29)

Since by definition \( \hat{F} = \hat{G}_{ijk} X^{i} X^{j} dq^{k} \), we have

$$ \hat{F} = C_{1} a_{2} { \sin }\theta_{2} \left[ {\begin{array}{*{20}c} { - \dot{\theta }_{2}^{2} } \\ {\dot{\theta }_{1} \dot{\theta }_{2} } \\ \end{array} } \right] $$
(30)

And \( \hat{W} \) is given by

$$ \hat{W} = \hat{M}M^{ - 1} W = \left[ {\begin{array}{*{20}c} {\hat{w}_{1} } \\ {\hat{w}_{2} } \\ \end{array} } \right] $$
(31)

In order to add dissipation to the system, we can choose

$$ \hat{u} = - C_{4} \left( {\hat{w}_{1} \dot{\theta }_{1} + \hat{w}_{2} \dot{\theta }_{2} } \right) $$
(32)

Then, the control law can be obtained from (9). Note that C4 should be positive.

Since \( \hat{E} = \hat{T} + \hat{U} \) is the total energy of the equivalent system, we have

$$ \frac{{{\text{d}}\hat{E}}}{{{\text{d}}t}} = \dot{q} \cdot \hat{F} + \dot{q} \cdot \hat{u} = - C_{4} \left( {\hat{w}_{1} \dot{\theta }_{1} + \hat{w}_{2} \dot{\theta }_{2} } \right)^{2} \le 0 $$
(33)

Because \( \dot{q} \cdot \hat{F} = 0 \) (see Eq. 30). Equation (33) shows that the closed-loop system energy decreases with time, and it will result in the system stability.

6 PSO Algorithm

In the previous section, the control law was obtained. Controller parameters C1, C2, C3 and C4 are constants that affect the closed-loop performance. Since we lose the physical insight to the controller parameters in the Controlled Lagrangians method, selection of these parameters is often a complex and time consuming process.

In this section, the controller parameters (C1, C2, C3 and C4) are chosen using particle swarm optimization (PSO) algorithm which was first introduced by Kennedy and Eberhart in 1995.

PSO is one of the evolutionary optimization techniques. The method is developed from research on swarms such as fish schooling and bird flocking (Eberhart and Shi 1998). The method has been found to be robust in solving problems featuring nonlinearity and non-differentiability, multiple optima and high dimensionality through adaptation which is derived from the social-psychological theory. Moreover, the method can be easily implemented and has stable convergence characteristic with good computational efficiency.

Each particle (individual) in PSO moves in the search space with velocity which is dynamically adjusted according to its own and its companions’ history. This is in contrast with other evolutionary optimization algorithms which often use evolutionary operators to manipulate the particle movement.

In PSO, each particle is treated as a volume-less particle in g-dimensional search space (here the four-dimensional controller parameters space C1, C2, C3 and C4). Each particle keeps track of its coordinates in the problem space, which are associated with the best solution it has achieved so far. This value is called pbest. Another best value that is tracked by the particle swarm optimizer is the overall best value, and its value, obtained so far by any particle in the group, and is called gbest.

The PSO concept consists of, at each time step, changing the velocity of each particle toward its pbest and gbest values. Acceleration is weighted by a random term, with separate random numbers being generated for acceleration toward pbest and gbest locations.

For example, the jth particle is represented as xj = (xj,1, xj,2, …, xj,g) in the g-dimensional space. The best previous position of the jth particle is recorded and represented as pbestj = (pbestj,1, pbestj,2, …, pbestj,g). The index of best particle among all of the particles in the group is represented by the gbestg. The rate of the position change (velocity) for particle j is represented as vj = (vj,1, vj,2, …, vj,g).

The modified velocity and position of each particle can be calculated using the current velocity and the distance from pbestj,g to gbestg, as shown in the following formulas:

$$ v_{j,g}^{{\left( {t + 1} \right)}} = w.v_{j,g}^{\left( t \right)} + d_{1} R_{1} \left( {pbest_{j,g} - x_{j,g}^{\left( t \right)} } \right) + d_{2} R_{2} \left( {gbest_{g} - x_{j,g}^{\left( t \right)} } \right) $$
(34)
$$ x_{j,g}^{{\left( {t + 1} \right)}} = x_{j,g}^{\left( t \right)} + v_{j,g}^{{\left( {t + 1} \right)}} $$
(35)

\( {\text{where}}\,\, = 1, 2, \ldots , n,\, g = 1, 2, \ldots , m, \) and other parameters can be found in Table 2.

Table 2 Introduction of the PSO parameters

The constants \( d_{1} \) and \( d_{2} \) represent the weighting of the stochastic acceleration terms that pull each particle toward pbest and gbest positions. Low values allow particles to roam far from the target regions before being tugged back. On the other hand, high values result in abrupt movement toward, or past, target regions. Hence, the acceleration constants are often set to be 2.0 (Gaing 2004).

The PSO parameters used in this paper are shown in Table 3.

Table 3 Parameters of the PSO algorithm

Flow diagram illustrating the particle swarm optimization algorithm is presented in Fig. 3.

Fig. 3
figure 3

Schematic explanation of PSO algorithm

7 Simulation Results

To verify the performance of the controller, let us first simulate the closed-loop response for a brachiation task in which the robot gripper releases an initial bar and swings toward a target bar. The positions of the initial and target bars are [ − 0.3, 0] and \( \left[ { + \,0.21,0.07} \right] \)(m), respectively, and the support arm rotates around origin as shown in Fig. 4. Furthermore, velocity of the gripper should be close to zero just as it reaches the target bar to avoid impact between them. Consequently, possible harmful effects of the impact on the robot can be prevented. Therefore, the cost function in the PSO algorithm has been chosen as

$$ {\text{soln}} = \frac{1}{2}V^{2} + \frac{1}{2}S^{2} , $$

where V is the gripper’s velocity and S is the distance between gripper and target point. We would like to find controller parameters C1, C2, C3 and C4 that minimize soln. It is essential to mention that V and S are representatives of errors of generalized coordinates. In other words, controller’s gains depend on the position of target bar and desired velocity of the gripper at the moment that the target bar is achieved which is equal to zero in the present problem. In fact, the controller parameters are functions of desired generalized coordinates, indirectly.

Fig. 4
figure 4

The initial and final conditions

The controller’s gains, obtained by PSO algorithm, are: C1 = 170.001, C2 = 20.1375, C3 = 76.0234, C4 = 3.9801

The simulation results are shown in Fig. 5, with parameters mentioned in Table 1. Figure 5a, b, g indicates that the robot can catch the target point, and Fig. 5c–e illustrates that the robot touches the target bar without impact (i.e., the velocity of the end effector is almost zero as it reaches the target bar). The input u(t), the torque exerted by the motor on link 2 from link 1, is shown in Fig. 5f.

Fig. 5
figure 5

Simulation results. The positions of the initial and target bars are [− 0.3,0] and [+ 0.21,0.07] (m), respectively. a Angle of first link; b angle of second link; c angular velocity of first link; d angular velocity of second link; e velocity of the gripper; f control input; g movement of the brachiating robot

7.1 Comparison of the Trajectory of the Proposed Controller, with the Optimal Trajectory

In Meghdari et al. (2013), Pontryagin’s minimum principle was used to obtain the optimal trajectories that minimize the actuator work. It is shown that this trajectory also minimizes the brachiation time.

In order to compare the trajectory of the proposed Controlled Lagrangians method with the optimal trajectory (Meghdari et al. 2013), the same location for the initial and target bars as in Meghdari et al. (2013) was used to obtain the trajectory. The results of both the proposed method and the optimal method of Meghdari et al (2013) are illustrated in Fig. 6.

Fig. 6
figure 6

Comparison of the selected trajectory by the proposed method in this paper with the optimal trajectory. The positions of the initial and target bars are [− 0.3,0] and [+ 0.21,0.07] (m), respectively. a Angle of first link; b angle of second link; c angular velocity of first link; d angular velocity of second link; e velocity of the gripper; f control input

Interestingly, this comparison shows that proposed controller selected an almost optimal trajectory and the brachiation time is approximately equal to the minimum possible time. However, as it is shown in Fig. 6f the actuation torque is not equal to its optimal value but its maximum magnitude is about 1.5 N m that is an acceptable value from the practical point of view.

7.2 Experimental Testbed and Results

This section describes the experimental setup of the brachiation robot which is used to validate the proposed control strategy. The configuration of the CEDRA brachiation robot is illustrated in Fig. 7. The CEDRA brachiation robot has two links and two grippers at the end of each link. In order to grab the bars, each gripper is equipped with two radio-controlled (RC) servo motors. A direct current (DC) coreless motor is placed at the central joint as the only actuator of the robot. The DC motor (3868A024C), gearbox (38/2S14:1), encoder (HEDS5500C12) and motion controller (MCDC3006S) are manufactured by the “Faulhaber” group.

Fig. 7
figure 7

The CEDRA two-link brachiation robot. (Reproduced with permission from Meghdari et al. 2013)

Two gyroscope sensors are attached to the links to measure the angular velocity. The movement of the robot is captured by a GoPro camera with 240 fps (frames per second) which consequently has been splat to pictures by a video to picture converter software. Finally, the angle of each link is determined by the ImageJ software. The position of the initial and target bars is set exactly equal to the values considered in the simulation section. The motion of the CEDRA brachiation robot, equipped with the proposed Controlled Lagrangians controller through a brachiation task, is shown in Fig. 8. (Frames are captured every 0.065 s.)

Fig. 8
figure 8

The movement of CEDRA brachiation robot for almost every 0.065 s

The comparison between the simulation and experiment results is shown in Fig. 9. As can be seen, simulations nearly match experimental results. It is also worthy to mention that the erratic variation of the joint velocity in Fig. 9 might be caused due to Coulomb friction and frictional torques at gripper’s contact with the initial bar as well as somewhat out-of-plane motion of the robot during the swinging motion.

Fig. 9
figure 9

Experimental results. a Angle of first link; b angle of second link; c angular velocity of first link; d angular velocity of second link

8 Conclusions

This paper investigates the control problem of a brachiation robot. Controlled Lagrangians method was used to design a controller. The controller parameters are then computed using a PSO optimization. Numerical simulations illustrate the effectiveness of the proposed method. Comparison of the trajectory of the proposed controller with the optimal trajectory illustrates the intrinsic ability of the Controlled Lagrangians method in control of underactuated mechanical systems. Interestingly, this comparison shows that proposed controller selected an almost optimal trajectory and the brachiation time is approximately equal to the minimum possible time. Experimental observations confirm theoretical results and illustrate the effectiveness of the proposed method. Authors would like to clarify that simpler methods can also be used to control this robot to avoid complexity of Controlled Lagrangians method, especially in tuning process. Previous works in the field of Controlled Lagrangians used trial and error to tune the controller and find appropriate controller gain. However, the trial and error method is cumbersome for controllers with higher degrees of freedom. In this paper, an optimization technique is proposed to overcome this difficulty, but the determination of controller’s gains is considerably time-consuming and might be practically impossible in some cases.

Even though it was thought that the method of Controlled Lagrangians is more practical in stabilizing a 2-DOF system around its equilibrium point, in this paper, by combining the CL method and PSO algorithm it is indicated that this method can be used for conducting a system to a point that is not an equilibrium point while it is not easy without the help of PSO algorithm. Also, in this way, we remove any trial and error for finding controller’s gains.