Skip to content

Instantly share code, notes, and snippets.

View mayataka's full-sized avatar

Sotaro Katayama mayataka

View GitHub Profile
@mayataka
mayataka / set-my-ubuntu.sh
Last active June 11, 2022 12:44
Setup Ubuntu 20.04
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 -
@mayataka
mayataka / install_ros2.sh
Last active April 11, 2020 23:27
install-ros2
cd
# Add ROS2 repository
sudo apt update -y
sudo apt install curl gnupg2 lsb-release -y
curl http://repo.ros2.org/repos.key | sudo apt-key add -
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
# Specify the distribution of ROS2
export CHOOSE_ROS_DISTRO=dashing
# Install ROS2
sudo apt update -y
@mayataka
mayataka / get_driver.sh
Last active April 8, 2020 11:24
Wi-fi driver for Thinkpad X1 gen7 Ubuntu 18.04 LTS
sudo apt update
sudo apt install git build-essential
cd
git clone https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/backport-iwlwifi.git
cd backport-iwlwifi/
make defconfig-iwlwifi-public
sed -i 's/CPTCFG_IWLMVM_VENDOR_CMDS=y/# CPTCFG_IWLMVM_VENDOR_CMDS is not set/' .config
make -j$(nproc)
sudo make install
sudo modprobe iwlwifi
@mayataka
mayataka / install_pinocchio.sh
Last active March 28, 2024 07:47
Install Pinocchio
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-py27-pinocchio
export PATH=/opt/openrobots/bin:$PATH
export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/opt/openrobots/lib/python2.7/site-packages:$PYTHONPATH
export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH
@mayataka
mayataka / install_pinocchio.sh
Last active January 28, 2024 01:06
Install pinocchio for Ubuntu 20.04
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
@mayataka
mayataka / install_pinocchio_viewer.sh
Last active January 19, 2021 00:49
install pinocchio viewer
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
@mayataka
mayataka / client_settings.sh
Last active April 26, 2021 05:38
mayataka-client-settings
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
@mayataka
mayataka / casadi_ocp.py
Created October 7, 2021 23:41
Direct Optimal Control via CasADi
from casadi import *
import math
# 問題設定
T = 5.0 # ホライゾン長さ
N = 100 # ホライゾン離散化グリッド数
dt = T / N # 離散化ステップ
nx = 4 # 状態空間の次元
nu = 1 # 制御入力の次元
@mayataka
mayataka / casadi_mpc.py
Last active November 26, 2022 08:52
MPC via CasADi
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]
@mayataka
mayataka / casadi_introduction.md
Last active January 5, 2024 07:02
How to Use CasADi

CasADi とは?

数値最適化用の自動微分&各種ソルバーへのインターフェースツールです. MPCなどでの活用が便利です.

なぜ CasADiを使うのか?

  • 定式化が非常に直感的で使いやすい.
  • かなり変わった定式化にも対応可能(一般的な数値最適化ソルバーであるため)
  • バックエンドソルバーが豊富
  • AutoGenU,ACADO Toolkitといったシンボリック計算MPCツールと比べてトータルの実装時間が圧倒的に高速