数値最適化用の自動微分&各種ソルバーへのインターフェースツールです. MPCなどでの活用が便利です.
- 定式化が非常に直感的で使いやすい.
- かなり変わった定式化にも対応可能(一般的な数値最適化ソルバーであるため)
- バックエンドソルバーが豊富
- AutoGenU,ACADO Toolkitといったシンボリック計算MPCツールと比べてトータルの実装時間が圧倒的に高速
from casadi import * | |
import numpy as np | |
# optimization variables | |
x1 = SX.sym('x1') | |
x2 = SX.sym('x2') | |
w = [x1, x2] | |
w0 = [0, 0] | |
lbw = [-np.inf, -np.inf] |
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']" | |
sudo apt update -y | |
sudo apt upgrade -y | |
sudo apt autoremove -y | |
sudo apt install build-essential cmake git libeigen3-dev vim tmux doxygen graphviz ffmpeg libglpk-dev -y | |
sudo apt install python3-sphinx -y | |
# install docker | |
sudo apt install lsb-release -y | |
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
from casadi import * | |
import math | |
import numpy as np | |
import optuna | |
class CartPole: | |
def __init__(self): | |
self.mc = 2.0 # cart の質量[kg] | |
self.mp = 0.2 # pole の質量[kg] |
from casadi import * | |
import math | |
import numpy as np | |
# cartpole のダイナミクスを記述 | |
# cartpoleの運動方程式は(https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-832-underactuated-robotics-spring-2009/readings/MIT6_832s09_read_ch03.pdf)を参照した | |
class CartPole: | |
def __init__(self): | |
self.mc = 2.0 # cart の質量[kg] |
from casadi import * | |
import math | |
# 問題設定 | |
T = 5.0 # ホライゾン長さ | |
N = 100 # ホライゾン離散化グリッド数 | |
dt = T / N # 離散化ステップ | |
nx = 4 # 状態空間の次元 | |
nu = 1 # 制御入力の次元 |
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']" | |
echo export PATH=/opt/openrobots/bin:$PATH >> ~/.bashrc | |
echo export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH >> ~/.bashrc | |
echo export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH >> ~/.bashrc | |
echo export PYTHONPATH=/opt/openrobots/lib/python3.8/site-packages:$PYTHONPATH >> ~/.bashrc | |
echo export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH >> ~/.bashrc | |
source ~/.bashrc |
sudo apt update | |
sudo apt install robotpkg-py38-qt5-gepetto-viewer-corba -y | |
git clone https://github.com/stack-of-tasks/pinocchio-gepetto-viewer.git --recursive | |
cd pinocchio-gepetto-viewer | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_BUILD_TYPE=Release | |
sudo make install |
sudo apt install -qqy lsb-release gnupg2 curl | |
echo "deb [arch=amd64] http://robotpkg.openrobots.org/packages/debian/pub $(lsb_release -cs) robotpkg" | sudo tee /etc/apt/sources.list.d/robotpkg.list | |
curl http://robotpkg.openrobots.org/packages/debian/robotpkg.key | sudo apt-key add - | |
sudo apt update -y | |
sudo apt install -qqy robotpkg-py38-pinocchio | |
echo export PATH=/opt/openrobots/bin:$PATH >> ~/.bashrc | |
echo export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH >> ~/.bashrc | |
echo export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH >> ~/.bashrc | |
echo export PYTHONPATH=/opt/openrobots/lib/python3.8/site-packages:$PYTHONPATH >> ~/.bashrc | |
echo export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH >> ~/.bashrc |