% MotionGenesis file: MGSolveNonlinearEqnsContinuouslyB.txt % Copyright (c) 2024 Motion Genesis LLC. All rights reserved. % Purpose: Continuous solution to the nonlinear algebraic equations: % cos(qA) + 2*cos(qB) = 2 + 0.2*cos(t) % 2*sin(qB) - sin(qA) = 0.3*sin(3*t) % Related: MGSolveNonlinearEqnContinuouslyA.txt % MGSolveNonlinearEqnsContinuouslyB.txt % MGSolveNonlinearEqnsContinuouslyC.txt % MGFigureEightLinkageInverseKinematics.txt %------------------------------------------------------------------------------- Variable qA', qB' eqnToSolve[1] = cos(qA) + 2*cos(qB) - 2 - 0.2*cos(t) eqnToSolve[2] = 2*sin(qB) - sin(qA) - 0.3*sin(3*t) %------------------------------------------------------------------------------- % Differentiate eqnToSolve to form equations that are _linear_ in qA', qB'. eqnDt = Dt( eqnToSolve ) %------------------------------------------------------------------------------- % Solve eqnDt = 0 to form an ODE (ordinary differential equation) for qA' and qB' Solve( eqnDt = 0, qA', qB' ) %------------------------------------------------------------------------------- % Form a set of equations that govern the values of qA and qB at t = 0. eqnInitial = Evaluate( eqnToSolve, t = 0 ) %------------------------------------------------------------------------------- % Solve the nonlinear equations at t = 0 to set initial values for qA and qB. % Since the equations are nonlinear, provide a guess for qA and qB SolveSetInput( eqnInitial = 0, qA = 20 degrees, qB = 60 degrees ) %------------------------------------------------------------------------------- % List output quantities (for subsequent ODE command). Output t seconds, qA degrees, qB degrees %-------------------------------------------------------------------- % Set numerical integration parameters and solve ODEs. Input tFinal = 8 sec, tStep = 0.02 sec, absError = 1.0E-07 ODE() MGSolveNonlinearEqnsContinuouslyB %------------------------------------------------------------------------------- % Optional: Plot results. % Plot MGSolveNonlinearEqnsContinuouslyB.1 [1, 2, 3] %------------------------------------------------------------------------------- % Record input together with responses. Save MGSolveNonlinearEqnsContinuouslyB.html Quit