Package: adam-robotics
adamAutomatic Differentiation for rigid-body-dynamics AlgorithMsadamimplements a collection of algorithms for calculating rigid-body dynamics forfloating-baserobots, inmixedandbody fixed representations(seeTraversaro's A Unified View of the Equations of Motion used for Control Design of Humanoid Robots) using:JaxCasADiPyTorchNumPyadamemploys theautomatic differentiationcapabilities of these frameworks to compute, if needed, gradients, Jacobian, Hessians of rigid-body dynamics quantities. This approach enables the design of optimal control and reinforcement learning strategies in robotics.adamis based on Roy Featherstone's Rigid Body Dynamics Algorithms.⚠️ REPOSITORY UNDER DEVELOPMENT ⚠️We cannot guarantee stable API🐍 Dependenciespython3Other requisites are:urdf_parser_pyjaxcasadipytorchnumpyThey will be installed in the installation step!💾 InstallationThe installation can be done either using the Python provided by apt (on Debian-based distros) or via conda (on Linux and macOS).🐍 Installation with pipInstallpython3, if not installed (inUbuntu 20.04):sudoaptinstallpython3.8Create avirtual environment, if you prefer. For example:pipinstallvirtualenv
python3-mvenvyour_virtual_envsourceyour_virtual_env/bin/activateInside the virtual environment, install the library from pip:InstallJaxinterface:pipinstalladam-robotics[jax]InstallCasADiinterface:pipinstalladam-robotics[casadi]InstallPyTorchinterface:pipinstalladam-robotics[pytorch]InstallALLinterfaces:pipinstalladam-robotics[all]If you want the last version:pipinstalladam-robotics[selected-interface]@git+https://github.com/ami-iit/ADAMor clone the repo and install:gitclonehttps://github.com/ami-iit/adam.gitcdadam
pipinstall.[selected-interface]📦 Installation with condaInstallation from conda-forge packagemambacreate-nadamenv-cconda-forgeadam-roboticsIf you want to usejaxorpytorch, just install the corresponding package as well.🔨 Installation from repoInstall in a conda environment the required dependencies:Jaxinterface dependencies:mambacreate-nadamenv-cconda-forgejaxnumpylxmlprettytablematplotliburdfdom-pyCasADiinterface dependencies:mambacreate-nadamenv-cconda-forgecasadinumpylxmlprettytablematplotliburdfdom-pyPyTorchinterface dependencies:mambacreate-nadamenv-cconda-forgepytorchnumpylxmlprettytablematplotliburdfdom-pyALLinterfaces dependencies:mambacreate-nadamenv-cconda-forgejaxcasadipytorchnumpylxmlprettytablematplotliburdfdom-pyActivate the environment, clone the repo and install the library:mambaactivateadamenv
gitclonehttps://github.com/ami-iit/ADAM.gitcdadam
pipinstall--no-deps.🚀 UsageThe following are small snippets of the use ofadam. More examples are arriving!
Have also a look at tetestsfolder.Jax interfaceimportadamfromadam.jaximportKinDynComputationsimporticub_modelsimportnumpyasnp# if you want to icub-models https://github.com/robotology/icub-models to retrieve the urdfmodel_path=icub_models.get_model_file("iCubGazeboV2_5")# The joint listjoints_name_list=['torso_pitch','torso_roll','torso_yaw','l_shoulder_pitch','l_shoulder_roll','l_shoulder_yaw','l_elbow','r_shoulder_pitch','r_shoulder_roll','r_shoulder_yaw','r_elbow','l_hip_pitch','l_hip_roll','l_hip_yaw','l_knee','l_ankle_pitch','l_ankle_roll','r_hip_pitch','r_hip_roll','r_hip_yaw','r_knee','r_ankle_pitch','r_ankle_roll']# Specify the root linkroot_link='root_link'kinDyn=KinDynComputations(model_path,joints_name_list,root_link)# choose the representation, if you want to use the body fixed representationkinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)# or, if you want to use the mixed representation (that is the default)kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)w_H_b=np.eye(4)joints=np.ones(len(joints_name_list))M=kinDyn.mass_matrix(w_H_b,joints)print(M)CasADi interfaceimportadamfromadam.casadiimportKinDynComputationsimporticub_modelsimportnumpyasnp# if you want to icub-models https://github.com/robotology/icub-models to retrieve the urdfmodel_path=icub_models.get_model_file("iCubGazeboV2_5")# The joint listjoints_name_list=['torso_pitch','torso_roll','torso_yaw','l_shoulder_pitch','l_shoulder_roll','l_shoulder_yaw','l_elbow','r_shoulder_pitch','r_shoulder_roll','r_shoulder_yaw','r_elbow','l_hip_pitch','l_hip_roll','l_hip_yaw','l_knee','l_ankle_pitch','l_ankle_roll','r_hip_pitch','r_hip_roll','r_hip_yaw','r_knee','r_ankle_pitch','r_ankle_roll']# Specify the root linkroot_link='root_link'kinDyn=KinDynComputations(model_path,joints_name_list,root_link)# choose the representation you want to use the body fixed representationkinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)# or, if you want to use the mixed representation (that is the default)kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)w_H_b=np.eye(4)joints=np.ones(len(joints_name_list))M=kinDyn.mass_matrix_fun()print(M(w_H_b,joints))PyTorch interfaceimportadamfromadam.pytorchimportKinDynComputationsimporticub_modelsimportnumpyasnp# if you want to icub-models https://github.com/robotology/icub-models to retrieve the urdfmodel_path=icub_models.get_model_file("iCubGazeboV2_5")# The joint listjoints_name_list=['torso_pitch','torso_roll','torso_yaw','l_shoulder_pitch','l_shoulder_roll','l_shoulder_yaw','l_elbow','r_shoulder_pitch','r_shoulder_roll','r_shoulder_yaw','r_elbow','l_hip_pitch','l_hip_roll','l_hip_yaw','l_knee','l_ankle_pitch','l_ankle_roll','r_hip_pitch','r_hip_roll','r_hip_yaw','r_knee','r_ankle_pitch','r_ankle_roll']# Specify the root linkroot_link='root_link'kinDyn=KinDynComputations(model_path,joints_name_list,root_link)# choose the representation you want to use the body fixed representationkinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)# or, if you want to use the mixed representation (that is the default)kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)w_H_b=np.eye(4)joints=np.ones(len(joints_name_list))M=kinDyn.mass_matrix(w_H_b,joints)print(M)🦸‍♂️ Contributingadamis an open-source project. Contributions are very welcome!Open an issue with your feature request or if you spot a bug. Then, you can also proceed with a Pull-requests! :rocket:TodoCenter of Mass positionJacobiansForward kinematicsMass Matrix via CRBACentroidal Momentum Matrix via CRBARecursive Newton-Euler algorithm (still no acceleration in the algorithm, since it is used only for the computation of the bias force)Articulated Body algorithm