Dynamics API
skelarm.dynamics
Provides functions for robot arm dynamics.
compute_coriolis_gravity_vector(skeleton, grav_vec=None)
Compute the Coriolis and gravity vector h(q, dq).
:param skeleton: The Skeleton object. :param grav_vec: The gravity vector. :return: The N-dimensional vector h.
Source code in src/skelarm/dynamics.py
compute_forward_dynamics(skeleton, tau, grav_vec=None)
Compute joint accelerations ddq given torques.
:param skeleton: The Skeleton object. :param tau: Joint torques. :param grav_vec: Gravity vector. :return: Joint accelerations ddq.
Source code in src/skelarm/dynamics.py
compute_inverse_dynamics(skeleton, grav_vec=None)
Compute the inverse dynamics of the robot arm using the Recursive Newton-Euler algorithm.
Updates the tau (joint torque) for each link in the skeleton.
:param skeleton: The Skeleton object containing the robot arm's links and their states. :param grav_vec: A 2D NumPy array representing the gravity vector. Defaults to zero (planar motion).
Source code in src/skelarm/dynamics.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
compute_kinetic_energy(skeleton)
Compute the total kinetic energy of the robot arm.
:param skeleton: The Skeleton object with link velocities (w, v, vc) computed. :return: The total kinetic energy.
Source code in src/skelarm/dynamics.py
compute_kinetic_energy_rate(skeleton, tau, grav_vec=None)
Compute the rate of change of kinetic energy (dKE/dt).
dKE/dt = dq^T * tau_applied. In the context of the dynamics equation Mddq + h = tau, dKE/dt should be dq^T * (Mddq + h). This must equal dq^T * tau_applied.
:param skeleton: The Skeleton object with current q and dq. :param tau: The N-dimensional vector of joint torques. :param grav_vec: The gravity vector. :return: The rate of change of kinetic energy.
Source code in src/skelarm/dynamics.py
compute_mass_matrix(skeleton, _grav_vec=None)
Compute the mass matrix M(q) for the robot arm.
:param skeleton: The Skeleton object. :param _grav_vec: Ignored, should be zero for mass matrix. :return: The N x N mass matrix.
Source code in src/skelarm/dynamics.py
simulate_robot(initial_skeleton, time_span, control_torques_func, grav_vec=None, dt=0.01, rtol=1e-06, atol=1e-08)
Simulate robot dynamics.
:param initial_skeleton: The initial Skeleton state (q, dq).
:param time_span: A tuple (start_time, end_time) for the simulation.
:param control_torques_func: A callable function f(t, skeleton) -> tau that returns
the N-dimensional control torques for the current time and skeleton state.
:param grav_vec: The gravity vector.
:param dt: Time step for the simulation, used for output points.
:param rtol: Relative tolerance for the ODE solver.
:param atol: Absolute tolerance for the ODE solver.
:return: A tuple (times, q_trajectory, dq_trajectory) of NumPy arrays.