Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
381 commits
Select commit Hold shift + click to select a range
ca12691
adapt ocs2_legged_robot_mpcnet to ocs2_robotic_assets
areske Nov 11, 2021
89de283
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Nov 18, 2021
7d0d351
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Nov 18, 2021
24bc08e
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Nov 18, 2021
23e966d
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Nov 18, 2021
baf6e82
Merge branch 'feature/raisim/legged_robot' of bitbucket.org:leggedrob…
areske Nov 18, 2021
b52c532
adapt to removal of anymal_c_simple_description and use lambda instea…
areske Nov 18, 2021
3e566f7
one thread per onnx runtime session
Nov 18, 2021
6dfc744
settings from pc for legged robot
Nov 18, 2021
4cb03c3
Merge branch 'feature/raisim/legged_robot' of bitbucket.org:leggedrob…
areske Nov 19, 2021
a46b65b
adapt to checks disabled by default
areske Nov 19, 2021
4502bf8
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Nov 23, 2021
ae4db65
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Nov 23, 2021
3d430f4
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Nov 23, 2021
c6aca0d
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Nov 23, 2021
781ab1d
Merge branch 'feature/raisim/legged_robot' of bitbucket.org:leggedrob…
areske Nov 23, 2021
2101dfd
only trot for now
areske Nov 26, 2021
862ed1c
learning iterations back to default
areske Nov 26, 2021
a08e045
add trot only policy
areske Nov 26, 2021
fc20c5a
kill raisim server in destructor (joins joinable threads)
areske Dec 2, 2021
df4dab4
Merge branch 'feature/mpcnet/legged_robot' of bitbucket.org:leggedrob…
areske Dec 2, 2021
3dcd220
Merge branch 'feature/raisim/legged_robot' of bitbucket.org:leggedrob…
areske Jan 25, 2022
60b59aa
adapt to changes in ocs2_legged_robot_raisim
areske Jan 25, 2022
f555dbd
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Feb 8, 2022
c239acb
Merge branch 'feature/raisim/main' of bitbucket.org:leggedrobotics/oc…
areske Feb 8, 2022
5c82b04
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Feb 8, 2022
28d5bd7
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Feb 8, 2022
f1c2dc1
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Feb 8, 2022
62c2028
Merge branch 'feature/raisim/legged_robot' of bitbucket.org:leggedrob…
areske Feb 8, 2022
49fb4b5
adapt to changes in main
areske Feb 8, 2022
9c2cbd8
update package.xml
areske Feb 13, 2022
b1a39df
update package.xml
areske Feb 13, 2022
3c9d1fd
update package.xml
areske Feb 13, 2022
7ba09d5
add venv to installation docs
areske Feb 20, 2022
90d1e65
update mpcnet install instructions
areske Feb 22, 2022
0d55538
make controllers final
areske Feb 28, 2022
1b506e2
remove unnecessary using declarations
areske Feb 28, 2022
b21a5d9
fix asset ownership
areske Feb 28, 2022
88ef499
make copy constructors protected/private
areske Feb 28, 2022
51ed95a
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Feb 28, 2022
8e09280
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Feb 28, 2022
ea7b2a9
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Feb 28, 2022
e68fa1b
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Feb 28, 2022
edc12db
adapt legged robot mpcnet to raisim metapackage
areske Feb 28, 2022
d1030f3
add raisim pd option for legged robot mpcnet
areske Feb 28, 2022
97decd8
switch to raisim control mode 1 for legged robot
areske Mar 4, 2022
8f744d6
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Mar 4, 2022
d3f242f
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Mar 4, 2022
9364eb0
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 4, 2022
378fc00
adapt to changes from dev/main
areske Mar 4, 2022
a9e2649
fix drift issue
areske Mar 4, 2022
4f26571
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 4, 2022
d6c684f
adapt to changes from dev/amin
areske Mar 4, 2022
34cc7e6
reduce memory capacity
areske Mar 7, 2022
7c52fe7
normalize loss with batch size
areske Mar 7, 2022
475dff0
normalize loss with batch size
areske Mar 7, 2022
e0bfe36
remove amsgrad for now
areske Mar 8, 2022
6e95124
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Mar 9, 2022
be7b982
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Mar 9, 2022
3fc6b2e
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 9, 2022
4f80d6f
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 9, 2022
6016197
cleanup ort inference
areske Mar 11, 2022
aad844c
address some comments
areske Mar 15, 2022
60f2997
add license to ocs2_mpcnet
areske Mar 15, 2022
c179e1b
small fix
areske Mar 15, 2022
8fd784c
add license to ocs2_ballbot_mpcnet
areske Mar 15, 2022
6676677
small fix
areske Mar 15, 2022
3b4df01
add license to ocs2_legged_robot_mpcnet
areske Mar 15, 2022
86eacc8
cleanup mpcnet controllers
areske Mar 17, 2022
d51c6bb
additional cleanup for mpcnet controllers
areske Mar 17, 2022
5f3c72d
also move shared pointers
areske Mar 17, 2022
172497a
separate data and metrics headers
areske Mar 17, 2022
3b061bb
update computeInput of MpcnetBehavioralController
areske Mar 17, 2022
e8a2483
add getDataPoint function
areske Mar 17, 2022
a89be04
add namespace mpcnet
areske Mar 17, 2022
6805881
fix getDataPoint()
areske Mar 17, 2022
c572d67
small fix
areske Mar 17, 2022
dd970d9
optimize memory allocation a bit
areske Mar 17, 2022
ef48803
add general step method for mpcnet rollouts
areske Mar 18, 2022
748cf41
adress comments for step method
areske Mar 18, 2022
b75e70b
Merge branch 'feature/mpcnet/core_step' of bitbucket.org:leggedroboti…
areske Mar 18, 2022
0d2b34c
address further comments
areske Mar 18, 2022
b2ae8eb
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 21, 2022
f170b50
adapt to changes in ocs2 mpcnet core package
areske Mar 21, 2022
1e39603
fix: error when building robot-specific mpcnet definition
areske Mar 21, 2022
48f303c
fix: error when python defined rollout variables go out of scope
areske Mar 21, 2022
993f10b
fix: mpcnet behavioral controller uninitialized, owns nothing, return…
areske Mar 21, 2022
665aa89
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 21, 2022
c3762ba
tune ballbot sampling around nominal state a bit
areske Mar 21, 2022
f8a37b5
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 21, 2022
df804a8
adapt to changes in ocs2 mpcnet core package
areske Mar 21, 2022
d21b9a5
run black
areske Mar 21, 2022
9bed201
add black as requirement for mpcnet
areske Mar 21, 2022
8bb47fb
small change for loss functions
areske Mar 22, 2022
899bea4
small change for policies
areske Mar 22, 2022
36e94ef
document mpcnet python code with docstrings
areske Mar 22, 2022
9da4d99
small cleanup for policies
areske Mar 22, 2022
48ac716
remove unnecesary policy base class
areske Mar 22, 2022
fdfd88f
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 22, 2022
4d0d69a
run black
areske Mar 22, 2022
5daef70
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 22, 2022
8fa6949
bugfix
areske Mar 22, 2022
abbc61f
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 22, 2022
7b1805c
adapt to small changes in ocs2 mpcnet core
areske Mar 22, 2022
b3d0243
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 22, 2022
2c28ccb
adapt to small changes in ocs2 mpcnet core
areske Mar 22, 2022
fac7b3f
also fix legged robot policies
areske Mar 22, 2022
2ccf120
remove unnecessary definition
areske Mar 22, 2022
5354c15
fix error messages
areske Mar 23, 2022
b965fb6
run black
areske Mar 23, 2022
a3479c8
fix error messages
areske Mar 23, 2022
b9fc53d
run black
areske Mar 23, 2022
bfe5739
document ballbot mpcnet python code with docstrings
areske Mar 24, 2022
b987a39
add shebang line to main script
areske Mar 24, 2022
ac06122
document legged robot mpcnet python code with docstrings
areske Mar 24, 2022
b18f62a
add shebang line to main script
areske Mar 24, 2022
2f297bb
small fix in doc
areske Mar 24, 2022
9afbc30
Merge branch 'feature/mpcnet/ballbot_core' of bitbucket.org:leggedrob…
areske Mar 24, 2022
006c7ea
Merge branch 'feature/mpcnet/legged_robot_trot_core' of bitbucket.org…
areske Mar 24, 2022
4f33326
ensure only one thread per MPC instance
areske Mar 25, 2022
8535cf6
ensure only one thread per MPC instance
areske Mar 25, 2022
37045a5
address comments
areske Mar 25, 2022
bc810aa
ensure MPC and DDP settings are as needed for MPC-Net
areske Mar 25, 2022
628af4f
ensure MPC and DDP settings are as needed for MPC-Net
areske Mar 25, 2022
b4b52c1
fix raisim rollout destructor
areske Mar 28, 2022
eb8c838
fix ocs2_legged_robot for mpcnet
areske Mar 28, 2022
a52f55f
address comments
areske Mar 28, 2022
365c421
update developers
areske Mar 28, 2022
e40367c
add mpcnet documentation
areske Mar 28, 2022
1701a19
add hot to set up a new robot section
areske Mar 28, 2022
7c2b26c
small fixes
areske Mar 28, 2022
9645479
update training times
areske Mar 28, 2022
79f840d
reduce memory capacity to required amount
areske Mar 28, 2022
e351e3f
address some comments
areske Mar 30, 2022
da73efd
remove code duplication and add call method for losses
areske Mar 30, 2022
3ae467a
add type hints
areske Mar 30, 2022
a50fad4
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 30, 2022
9e4c39a
adapt to changes in ocs2 mpcnet core
areske Mar 30, 2022
6642421
global variables
areske Mar 30, 2022
7db99ef
type hints
areske Mar 30, 2022
c7f4350
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 30, 2022
5bf71ab
adapt to changes in ocs2 mpcnet core
areske Mar 30, 2022
bbb199e
global variables
areske Mar 30, 2022
8e0d73a
type hints
areske Mar 30, 2022
bc1b6f8
small fix in doc
areske Mar 31, 2022
18bc4c2
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
226ffd2
small fix in documentation
areske Mar 31, 2022
6941243
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
9051a36
add general commands and example
areske Mar 31, 2022
43c4ec5
small fix
areske Mar 31, 2022
2d5549d
Merged in feature/mpcnet/documentation (pull request #609)
areske Mar 31, 2022
afc4b35
split losses and policies into files
areske Mar 31, 2022
ed5f40b
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
f62d0eb
create memory subpackage
areske Mar 31, 2022
d784ce2
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
f4303bf
adapt to subpackages in ocs2 mpcnet core
areske Mar 31, 2022
e90df9e
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
31d937e
adapt to subpackages in ocs2 mpcnet core
areske Mar 31, 2022
6b0847a
rename ocs2_mpcnet to ocs2_mpcnet_core
areske Mar 31, 2022
1830c8e
adapt ocs2 mpcnet core to name change
areske Mar 31, 2022
8a6b9dd
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
ad59e45
small fix in mpcnet pybindings
areske Mar 31, 2022
606e079
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
ad55ae6
adapt ocs2 mpcnet ballbot to name change
areske Mar 31, 2022
fe5bdee
move ocs2 ballbot mpcnet into ocs2 mpcnet
areske Mar 31, 2022
3079e55
Merge branch 'feature/mpcnet/core' of bitbucket.org:leggedrobotics/oc…
areske Mar 31, 2022
d5fc596
adapt ocs2 mpcnet legged robot to name change
areske Mar 31, 2022
fd53853
move ocs2 legged robot mpcnet into ocs2 mpcnet
areske Mar 31, 2022
6b7e686
Merge branch 'feature/mpcnet/ballbot' of bitbucket.org:leggedrobotics…
areske Mar 31, 2022
0eb13a1
Merge branch 'feature/mpcnet/legged_robot_trot' of bitbucket.org:legg…
areske Mar 31, 2022
0182a09
add mpcnet metapackage
areske Mar 31, 2022
10d4910
unify version info for mpcnet packages
areske Mar 31, 2022
823ad1b
make expert classes internal
areske Mar 31, 2022
a41f947
fix docstrings line length
areske Mar 31, 2022
7ac8c30
Merged in feature/mpcnet/core (pull request #469)
areske Apr 4, 2022
f814481
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Apr 4, 2022
5c185c6
adapt ocs2 mpcnet core to changes in main
areske Apr 4, 2022
2843215
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Apr 4, 2022
52445d9
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Apr 4, 2022
4d5ed38
rename ballbot python files
areske Apr 4, 2022
812e7a0
rename legged robot python files
areske Apr 4, 2022
3d81f02
improve readability and documentation
areske Apr 4, 2022
9e404b6
improve documentation for cheating
areske Apr 4, 2022
4d0e39a
add name guard to the main script
areske Apr 4, 2022
42ed62c
add name guard to the main script
areske Apr 4, 2022
80447f1
add main function
areske Apr 4, 2022
8b5b258
add main function
areske Apr 4, 2022
49d3056
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Apr 4, 2022
5654b1b
Merge branch 'feature/mpcnet/ballbot' of bitbucket.org:leggedrobotics…
areske Apr 4, 2022
51aec0c
Merge branch 'feature/mpcnet/legged_robot_trot' of bitbucket.org:legg…
areske Apr 4, 2022
a54fe92
Merged in feature/mpcnet/ballbot (pull request #470)
areske Apr 6, 2022
3bf66db
Merged in feature/mpcnet/legged_robot_trot (pull request #521)
areske Apr 6, 2022
97fc01c
Merged in feature/mpcnet/metapackage (pull request #598)
areske Apr 6, 2022
7f32e73
fix small mistake in docstring
areske Apr 7, 2022
af3e8d6
small formating fix
areske Apr 7, 2022
9131673
switch to observation and action transformation
areske Apr 7, 2022
0acd7c6
weight compensating input as action bias
areske Apr 7, 2022
205633f
add observation and action scaling
areske Apr 7, 2022
d2e5dba
update ballbot policy
areske Apr 8, 2022
df6aa16
update legged robot policy
areske Apr 8, 2022
aa07810
add option to train with rough terrain
areske Apr 12, 2022
d0ff261
update policy
areske Apr 12, 2022
5bb7f4d
load config from yaml file
areske Apr 20, 2022
db04afa
move training code into common class
areske Apr 21, 2022
09d2f80
remove legged robot yaml for laptop
areske Apr 22, 2022
07af3b3
Merge branch 'feature/mpcnet/refactor_config' of bitbucket.org:legged…
areske Apr 22, 2022
5c43fef
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Apr 22, 2022
564bbed
Merge branch 'feature/mpcnet/main' of bitbucket.org:leggedrobotics/oc…
areske Apr 22, 2022
598763c
Merge branch 'feature/mpcnet/refactor' of bitbucket.org:leggedrobotic…
areske Apr 22, 2022
fb64dfe
remove weight compensating bias
areske Apr 22, 2022
0e1c85b
update policy
areske Apr 22, 2022
d785243
Merge branch 'feature/mpcnet/refactor_policy' of bitbucket.org:legged…
areske Apr 22, 2022
61a4c1d
Merge branch 'feature/mpcnet/refactor_config' of bitbucket.org:legged…
areske Apr 22, 2022
7a274ea
add base class for loss
areske Apr 26, 2022
907ee1b
add base class for policy
areske Apr 26, 2022
81caafd
add base class for memory
areske Apr 26, 2022
66f4f73
run black
areske Apr 26, 2022
c872e66
reduce unnecessarily large weight for gating loss
areske Apr 26, 2022
0cdcc5f
add gradient clipping
areske May 13, 2022
426030a
remove unnecessary key
areske Jul 20, 2022
ea47f3c
throw yaml error
areske Jul 20, 2022
bf91262
absolute path to config
areske Jul 20, 2022
8e218bc
fix magic numbers
areske Jul 20, 2022
c7a4742
run black
areske Jul 20, 2022
eb65bee
Merge branch 'feature/mpcnet/refactor_config' of bitbucket.org:legged…
areske Jul 20, 2022
59ca4ce
absolute path to log dir
areske Jul 20, 2022
3ab9e29
clean up imports
areske Jul 20, 2022
ecd51b0
abstract forward method
areske Jul 20, 2022
ab0108d
update doc for main mpcnet class
areske Jul 20, 2022
00c390b
fix typo in docstring
areske Jul 21, 2022
c71cad1
Merged in feature/mpcnet/refactor_policy (pull request #625)
areske Aug 3, 2022
cdaefb5
simplify log dir path
areske Aug 4, 2022
9f0f108
add abstract method decorator
areske Aug 4, 2022
cfb269b
Merge branch 'feature/mpcnet/refactor_python' of bitbucket.org:legged…
areske Aug 4, 2022
62a4ed8
Merged in feature/mpcnet/refactor_config (pull request #628)
areske Aug 4, 2022
5e2368b
Merged in feature/mpcnet/refactor_python (pull request #629)
areske Aug 4, 2022
ce32559
run black
areske Aug 4, 2022
15a1d94
Merged in feature/mpcnet/refactor (pull request #647)
areske Aug 4, 2022
3622290
Merged in feature/mpcnet/gradient_clipping (pull request #633)
areske Aug 4, 2022
6c18251
Merge branch 'main' of bitbucket.org:leggedrobotics/ocs2_dev into fea…
areske Aug 4, 2022
ed3d354
adapt to removal of debug caching flag
areske Aug 4, 2022
9a5062f
set position error gain to zero
areske Aug 5, 2022
6f54a1a
enable gradient clipping for legged robot mpcnet
areske Aug 5, 2022
a30d1c2
Merged in feature/mpcnet/test (pull request #649)
areske Aug 5, 2022
ab24711
adding ocs2_mpcnet to ocs2 Metapackage
farbod-farshidian Aug 5, 2022
c009e38
add onnxruntime to build
areske Aug 5, 2022
76be2f3
update system deps and donload to tmp
areske Aug 5, 2022
8af3701
wget and tar into local folder
areske Aug 5, 2022
f25301e
try installing onnxruntime in local source folder
areske Aug 5, 2022
1b8e55f
update installation instructions for onnxruntime
areske Aug 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ros-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: System deps
run: |
apt-get update
apt-get install -y git ninja-build liburdfdom-dev liboctomap-dev libassimp-dev checkinstall
apt-get install -y git ninja-build liburdfdom-dev liboctomap-dev libassimp-dev checkinstall wget rsync

- uses: actions/checkout@v2
with:
Expand All @@ -56,6 +56,12 @@ jobs:
cmake .. -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
make -j4 && checkinstall

- name: Install ONNX Runtime
run: |
wget https://github.com/microsoft/onnxruntime/releases/download/v1.7.0/onnxruntime-linux-x64-1.7.0.tgz -P src
tar xf src/onnxruntime-linux-x64-1.7.0.tgz -C src
rsync -a src/ocs2/ocs2_mpcnet/ocs2_mpcnet_core/misc/onnxruntime/cmake/ src/onnxruntime-linux-x64-1.7.0/cmake

- name: Build (${{ matrix.build_type }})
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ ocs2_ddp/test/ddp_test_generated/
*.out
*.synctex.gz
.vscode/
runs/
2 changes: 1 addition & 1 deletion jenkins-pipeline
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library 'continuous_integration_pipeline'
ciPipeline("--ros-distro noetic --publish-doxygen --recipes raisimlib\
ciPipeline("--ros-distro noetic --publish-doxygen --recipes onnxruntime raisimlib\
--dependencies 'git@github.com:leggedrobotics/hpp-fcl.git;master;git'\
'git@github.com:leggedrobotics/pinocchio.git;master;git'\
'git@github.com:leggedrobotics/ocs2_robotic_assets.git;main;git'\
Expand Down
1 change: 1 addition & 0 deletions ocs2/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<exec_depend>ocs2_robotic_examples</exec_depend>
<exec_depend>ocs2_thirdparty</exec_depend>
<exec_depend>ocs2_raisim</exec_depend>
<exec_depend>ocs2_mpcnet</exec_depend>

<export>
<metapackage />
Expand Down
2 changes: 1 addition & 1 deletion ocs2_core/include/ocs2_core/control/ControllerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ namespace ocs2 {
/**
* Enum class for specifying controller type
*/
enum class ControllerType { UNKNOWN, FEEDFORWARD, LINEAR, NEURAL_NETWORK };
enum class ControllerType { UNKNOWN, FEEDFORWARD, LINEAR, ONNX, BEHAVIORAL };

} // namespace ocs2
1 change: 1 addition & 0 deletions ocs2_doc/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Table of Contents
robotic_examples.rst
from_urdf_to_ocp.rst
profiling.rst
mpcnet.rst
faq.rst

.. rubric:: Reference and Index:
Expand Down
36 changes: 36 additions & 0 deletions ocs2_doc/docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,42 @@ Optional Dependencies

* `Grid Map <https://github.com/ANYbotics/grid_map>`__ catkin package, which may be installed with ``sudo apt install ros-noetic-grid-map-msgs``.

* `ONNX Runtime <https://github.com/microsoft/onnxruntime>`__ is an inferencing and training accelerator. Here, it is used for deploying learned :ref:`MPC-Net <doxid-ocs2_doc_mpcnet>` policies in C++ code. To locally install it, do the following:

.. code-block:: bash

wget https://github.com/microsoft/onnxruntime/releases/download/v1.7.0/onnxruntime-linux-x64-1.7.0.tgz -P ~/catkin_ws/src
tar xf ~/catkin_ws/src/onnxruntime-linux-x64-1.7.0.tgz -C ~/catkin_ws/src
rsync -a ~/catkin_ws/src/ocs2/ocs2_mpcnet/ocs2_mpcnet_core/misc/onnxruntime/cmake/ ~/catkin_ws/src/onnxruntime-linux-x64-1.7.0/cmake

We provide custom cmake config and version files to enable ``find_package(onnxruntime)`` without modifying ``LIBRARY_PATH`` and ``LD_LIBRARY_PATH``. Note that the last command above assumes that you cloned OCS2 into the folder ``git`` in your user's home directory.

* `Virtual environments <https://docs.python.org/3/library/venv.html>`__ are recommended when training :ref:`MPC-Net <doxid-ocs2_doc_mpcnet>` policies:

.. code-block:: bash

sudo apt-get install python3-venv

Create an environment and give it access to the system site packages:

.. code-block:: bash

mkdir venvs && cd venvs
python3 -m venv mpcnet

Activate the environment and install the requirements:

.. code-block:: bash

source ~/venvs/mpcnet/bin/activate
python3 -m pip install -r ~/git/ocs2/ocs2_mpcnet/ocs2_mpcnet_core/requirements.txt

Newer graphics cards might require a CUDA capability which is currently not supported by the standard PyTorch installation.
In that case check `PyTorch Start Locally <https://pytorch.org/get-started/locally/>`__ for a compatible version and, e.g., run:

.. code-block:: bash

pip3 install torch==1.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

.. _doxid-ocs2_doc_installation_ocs2_doc_install:

Expand Down
164 changes: 164 additions & 0 deletions ocs2_doc/docs/mpcnet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
.. index:: pair: page; MPC-Net

.. _doxid-ocs2_doc_mpcnet:

MPC-Net
=======

MPC-Net is an imitation learning approach that uses solutions from MPC to guide the policy search.
The main idea is to imitate MPC by minimizing the control Hamiltonian while representing the corresponding control inputs by a parametrized policy.
MPC-Net can be used to clone a model predictive controller into a neural network policy, which can be evaluated much faster than MPC.
Therefore, MPC-Net is a useful proxy for MPC in computationally demanding applications that do not require the most exact solution.

The multi-threaded data generation and policy evaluation run asynchronously with the policy training.
The data generation and policy evaluation are implemented in C++ and run on CPU, while the policy training is implemented in Python and runs on GPU.
The control Hamiltonian is represented by a linear-quadratic approximation.
Therefore, the training can run on GPU without callbacks to OCS2 C++ code running on CPU to evaluate the Hamiltonian, and one can exploit batch processing on GPU.

Robots
~~~~~~

MPC-Net has been implemented for the following :ref:`Robotic Examples <doxid-ocs2_doc_robotic_examples>`:

============= ================ ================= ======== =============
Robot Recom. CPU Cores Recom. GPU Memory RaiSim Training Time
============= ================ ================= ======== =============
ballbot 4 2 GB No 0m 20s
legged_robot 12 8 GB Yes / No 7m 40s
============= ================ ================= ======== =============

Setup
~~~~~

Make sure to follow the :ref:`Installation <doxid-ocs2_doc_installation>` page.
Follow all the instructions for the dependencies.
Regarding the optional dependencies, make sure to follow the instruction for ONNX Runtime and the virtual environment, optionally set up RaiSim.

To build all MPC-Net packages, build the meta package:

.. code-block:: bash

cd <path_to_catkin_ws>
catkin_build ocs2_mpcnet

# Example:
cd ~/catkin_ws
catkin_build ocs2_mpcnet

To build a robot-specific package, replace :code:`<robot>` with the robot name:

.. code-block:: bash

cd <path_to_catkin_ws>
catkin_build ocs2_<robot>_mpcnet

# Example:
cd ~/catkin_ws
catkin_build ocs2_ballbot_mpcnet

Training
~~~~~~~~

To train an MPC-Net policy, run:

.. code-block:: bash

cd <path_to_ocs2_repo>/ocs2_mpcnet/ocs2_<robot>_mpcnet/python/ocs2_<robot>_mpcnet
source <path_to_catkin_ws>/devel/setup.bash
source <path_to_venvs>/mpcnet/bin/activate
python3 train.py

# Example:
cd ~/git/ocs2/ocs2_mpcnet/ocs2_ballbot_mpcnet/python/ocs2_ballbot_mpcnet
source ~/catkin_ws/devel/setup.bash
source ~/venvs/mpcnet/bin/activate
python3 train.py

To monitor the training progress with Tensorboard, run:

.. code-block:: bash

cd <path_to_ocs2_repo>/ocs2_mpcnet/ocs2_<robot>_mpcnet/python/ocs2_<robot>_mpcnet
source <path_to_venvs>/mpcnet/bin/activate
tensorboard --logdir=runs

# Example:
cd ~/git/ocs2/ocs2_mpcnet/ocs2_ballbot_mpcnet/python/ocs2_ballbot_mpcnet
source ~/venvs/mpcnet/bin/activate
tensorboard --logdir=runs

If you use RaiSim, you can visualize the data generation and policy evaluation rollouts with RaiSim Unity, where pre-built executables are provided in RaiSim's :code:`raisimUnity` folder. For example, on Linux run:

.. code-block:: bash

<path_to_raisimLib_repo>/raisimUnity/linux/raisimUnity.x86_64

# Example:
~/git/raisimLib/raisimUnity/linux/raisimUnity.x86_64

Deployment
~~~~~~~~~~

To deploy the default policy stored in the robot-specific package's :code:`policy` folder, run:

.. code-block:: bash

cd <path_to_catkin_ws>
source devel/setup.bash
roslaunch ocs2_<robot>_mpcnet <robot>_mpcnet.launch

# Example:
cd ~/catkin_ws
source devel/setup.bash
roslaunch ocs2_ballbot_mpcnet ballbot_mpcnet.launch

To deploy a new policy stored in the robot-specific package's :code:`python/ocs2_<robot>_mpcnet/runs` folder, replace :code:`<path>` with the absolute file path to the final policy and run:

.. code-block:: bash

cd <path_to_catkin_ws>
source devel/setup.bash
roslaunch ocs2_<robot>_mpcnet <robot>_mpcnet.launch policyFile:=<path>

# Example:
cd ~/catkin_ws
source devel/setup.bash
roslaunch ocs2_ballbot_mpcnet ballbot_mpcnet.launch policyFile:='/home/user/git/ocs2/ocs2_mpcnet/ocs2_ballbot_mpcnet/python/ocs2_ballbot_mpcnet/runs/2022-04-01_12-00-00_ballbot_description/final_policy.onnx'

How to Set Up a New Robot
~~~~~~~~~~~~~~~~~~~~~~~~~

Setting up MPC-Net for a new robot is relatively easy, as the **ocs2_mpcnet_core** package takes care of the data generation as well as policy evaluation rollouts and implements important learning components, such as the memory, policy, and loss function.

This section assumes that you already have the packages for the robot-specific MPC implementation:

1. **ocs2_<robot>**: Provides the library with the robot-specific MPC implementation.
2. **ocs2_<robot>_ros**: Wraps around the MPC implementation with ROS to define ROS nodes.
3. **ocs2_<robot>_raisim**: (Optional) interface between the robot-specific MPC implementation and RaiSim.

For the actual **ocs2_<robot>_mpcnet** package, follow the structure of existing robot-specific MPC-Net packages.
The most important classes/files that have to be implemented are:

* **<Robot>MpcnetDefinition**: Defines how OCS2 state variables are transformed to the policy observations. and how policy actions are transformed to OCS2 control inputs.
* **<Robot>MpcnetInterface**: Provides the interface between C++ and Python, allowing to exchange data and policies.
* **<robot>.yaml**: Stores the configuration parameters.
* **mpcnet.py**: Adds robot-specific methods, e.g. implements the tasks that the robot should execute, for the MPC-Net training.
* **train.py**: Starts the main training script.

Known Issues
~~~~~~~~~~~~

Stiff inequality constraints can lead to very large Hamiltonians and gradients of the Hamilltonian near the log barrier.
This can obstruct the learning process and the policy might not learn something useful.
In that case, enable the gradient clipping in the robot's MPC-Net YAML configuration file and tune the gradient clipping value.

References
~~~~~~~~~~

This part of the toolbox has been developed based on the following publications:

.. bibliography::
:list: enumerated

carius2020mpcnet
reske2021imitation
3 changes: 2 additions & 1 deletion ocs2_doc/docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Michael Spieler (ETHZ),
Jan Carius (ETHZ),
Jean-Pierre Sleiman (ETHZ).

**Other Developers**:
**Other Developers**:
Alexander Reske,
Mayank Mittal,
Johannes Pankert,
Perry Franklin,
Expand Down
Loading