<jupyter_start><jupyter_text>Robot Dynamics- How is the motion of a manipulator affected by external forces?- What joints torques are generated from external forces applied to the manipulator?- The following example will demonstrate how to calculate the joint torques required to counteract a given TCP wrench.  Create the Robot Model<jupyter_code>from pybotics.robot import Robot
#from pybotics.predefined_models import ur10
#from ur5_model import ur10_site as ur10
from ur5_model import ur10_copy as ur10

robot = Robot.from_parameters(ur10())<jupyter_output><empty_output><jupyter_text>Define the Forces/Torques Acting on the TCP- Aka the "wrench"<jupyter_code>forces = [0, 0, 10]
torques = [0, 0, 0]
wrench = [*forces, *torques]<jupyter_output><empty_output><jupyter_text>Calculate Joint Torques- What are the joint torques required to counteract this payload?- This calculation can be repeated at each discrete pose in a trajectory for trajectory dynamics<jupyter_code>import numpy as np

robot.joints = np.deg2rad([0, 0, 0, 0, 0, 0])
j_torques = robot.compute_joint_torques(wrench)
print(f'Robot Joints: {robot.joints}')
print(f'Joint Torques: {j_torques}')

robot.joints = np.deg2rad([0, -90, -90, 0, -90, 0])
j_torques = robot.compute_joint_torques(wrench)
print(f'Robot Joints: {robot.joints}')
print(f'Joint Torques: {j_torques}')<jupyter_output>Robot Joints: [0. 0. 0. 0. 0. 0.]
Joint Torques: [11843.     0.     0.     0.     0.     0.]
Robot Joints: [ 0.         -1.57079633 -1.57079633  0.         -1.57079633  0.        ]
Joint Torques: [-1639.  7284.  1157.  1157.     0.     0.]
{'fraction_non_alphanumeric': 0.10532915360501567, 'fraction_numerical': 0.06394984326018809, 'mean_word_length': 4.355704697986577, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '190750', 'license': 'MIT', 'n_tokens_mistral': 639, 'n_tokens_neox': 566, 'n_words': 178, 'path': 'dynamics.ipynb', 'repo_name': 'sohiai/ur5', 'size': '1595'}