def Newton_Euler(robo, symo): """Internal function. Computes Inverse Dynamic Model using Newton-Euler formulation Parameters ========== robo : Robot Instance of robot description container symo : Symoro Instance of symbolic manager """ # init external forces Fex = copy(robo.Fex) Nex = copy(robo.Nex) # init transformation antRj, antPj = compute_rot_trans(robo, symo) # init velocities and accelerations w, wdot, vdot, U = compute_vel_acc(robo, symo, antRj, antPj) # init forces vectors F = Init.init_vec(robo) N = Init.init_vec(robo) Fjnt = Init.init_vec(robo) Njnt = Init.init_vec(robo) for j in xrange(1, robo.NL): compute_wrench(robo, symo, j, w, wdot, U, vdot, F, N) for j in reversed(xrange(1, robo.NL)): compute_joint_wrench(robo, symo, j, antRj, antPj, vdot, Fjnt, Njnt, F, N, Fex, Nex) for j in xrange(1, robo.NL): compute_torque(robo, symo, j, Fjnt, Njnt)
def dynamic_identification_NE(robo): """Computes Dynamic Identification Model using Newton-Euler formulation Parameters ========== robo : Robot Instance of robot description container Returns ======= symo.sydi : dictionary Dictionary with the information of all the sybstitution """ # init forces vectors Fjnt = Init.init_vec(robo) Njnt = Init.init_vec(robo) # init file output, writing the robot description symo = Symoro() symo.file_open(robo, 'dim') title = "Dynamic identification model using Newton - Euler Algorith" symo.write_params_table(robo, title, inert=True, dynam=True) # init transformation antRj, antPj = compute_rot_trans(robo, symo) # init velocities and accelerations w, wdot, vdot, U = compute_vel_acc(robo, symo, antRj, antPj) # virtual robot with only one non-zero parameter at once robo_tmp = deepcopy(robo) robo_tmp.IA = sympy.zeros(robo.NL, 1) robo_tmp.FV = sympy.zeros(robo.NL, 1) robo_tmp.FS = sympy.zeros(robo.NL, 1) for k in xrange(1, robo.NL): param_vec = robo.get_inert_param(k) F = Init.init_vec(robo) N = Init.init_vec(robo) for i in xrange(10): if param_vec[i] == ZERO: continue # change link names according to current non-zero parameter robo_tmp.num = [str(l) + str(param_vec[i]) for l in xrange(k + 1)] # set the parameter to 1 mask = sympy.zeros(10, 1) mask[i] = 1 robo_tmp.put_inert_param(mask, k) # compute the total forcec of the link k compute_wrench(robo_tmp, symo, k, w, wdot, U, vdot, F, N) # init external forces Fex = copy(robo.Fex) Nex = copy(robo.Nex) for j in reversed(xrange(k + 1)): compute_joint_wrench(robo_tmp, symo, j, antRj, antPj, vdot, Fjnt, Njnt, F, N, Fex, Nex) for j in xrange(k + 1): compute_torque(robo_tmp, symo, j, Fjnt, Njnt, 'DG') # reset all the parameters to zero robo_tmp.put_inert_param(sympy.zeros(10, 1), k) # compute model for the joint parameters compute_joint_torque_deriv(symo, robo.IA[k], robo.qddot[k], k) compute_joint_torque_deriv(symo, robo.FS[k], sympy.sign(robo.qdot[k]), k) compute_joint_torque_deriv(symo, robo.FV[k], robo.qdot[k], k) # closing the output file symo.file_close() return symo