This repo provides code for our paper "Port-Hamiltonian Neural ODE Networks on Lie Groups For Robot Dynamics Learning and Control". Please check out our project website for more details: https://thaipduong.github.io/LieGroupHamDL/.
Our code is tested with Ubuntu 18.04 and Python 3.7, Python 3.8. It depends on the following Python packages:
torchdiffeq 0.1.1, torchdiffeq 0.2.3
gym 0.18.0, gym 1.21.0
gym-pybullet-drones: https://github.com/utiasDSL/gym-pybullet-drones
torch 1.4.0, torch 1.9.0
numpy 1.20.1
scipy 1.5.3
matplotlib 3.3.4
pyglet 1.5.27
(pendulum rendering not working with pyglet >= 2.0.0)
Notes: NaN errors might happen during training with torch 1.10.0
or newer due to numerical issues!!!!!!!!! Please switch to float64 to fix this.
Run python ./examples/pendulum/train_pend_SO3_friction.py
to train the model with data collected from the pendulum environment. It might take some time to train. A pretrained model is stored in ./examples/pendulum/data/run1_pend_friction/pendulum-so3ham_ode-rk4-5p.tar
Run python ./examples/pendulum/analyze_pend_SO3.py
to plot the generalized mass inverse M^-1(q), the potential energy V(q), and the control coefficient g(q)
Run python ./examples/pendulum/comparison.py
to verify that compared to other baselines, our framework learns better, respects energy conservation, SE(3) constraints, and the phase portrait of a trajectory rolled out from the learned dynamics.
Run python ./examples/pendulum/control_pend_SO3.py
to test the energy-based controller with the learned dynamics.
Run python ./examples/quadrotor/train_quadrotor_SE3.py
to train the model with data collected from the pybullet drone environment. It might take some time to train. A pretrained model is stored in ./examples/quadrotor/data/quadrotor-se3ham-rk4-5p.tar
Run python ./examples/quadrotor/analyze_quadrotor_SE3.py
to plot the generalized mass inverse M^-1(q), the potential energy V(q), and the control coefficient g(q)
Run python ./examples/quadrotor/comparison.py
and python ./examples/quadrotor/comparison_plottraj.py
to verify that compared to other baselines, our framework learns better, respects energy conservation and SE(3) constraints by construction.
Run python ./examples/quadrotor/control_quadrotor_SE3.py
to test the energy-based controller with the learned dynamics.
Please check out our branch "PX4" and follow instructions in README for demos with PX4 simulated quadrotors.
Data collection
https://github.com/thaipduong/LieGroupHamDL/assets/40247151/733f017d-4cc2-4f29-b020-fa753d3fffce
Trajectory tracking with learned dynamics
https://github.com/thaipduong/LieGroupHamDL/assets/40247151/bfd06715-bba2-42dc-b423-83c0cd5017ca
If you find our papers/code useful for your research, please cite our work as follows.
@article{duong23porthamiltonian,
author = {Thai Duong, Abdullah Altawaitan, Jason Stanley AND Nikolay Atanasov},
title = {Port-{H}amiltonian Neural {ODE} Networks on Lie Groups For Robot Dynamics Learning and Control},
journal = {arXiv preprint arXiv:2401.09520},
year = {2023},
}
T. Duong, N. Atanasov. Hamiltonian-based Neural ODE Networks on the SE(3) Manifold For Dynamics Learning and Control. RSS, 2021
@inproceedings{duong21hamiltonian,
author = {Thai Duong AND Nikolay Atanasov},
title = {{Hamiltonian-based Neural ODE Networks on the SE(3) Manifold For Dynamics Learning and Control}},
booktitle = {Proceedings of Robotics: Science and Systems},
year = {2021},
address = {Virtual},
month = {July},
DOI = {10.15607/RSS.2021.XVII.086}
}