Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembler起動用Shell Scriptの作成 #58

Open
tomosii opened this issue Feb 15, 2023 · 2 comments
Open

Assembler起動用Shell Scriptの作成 #58

tomosii opened this issue Feb 15, 2023 · 2 comments
Assignees

Comments

@tomosii
Copy link
Collaborator

tomosii commented Feb 15, 2023

Docker環境でassemberを起動するシェルスクリプトを作成する。
(ドキュメント内の説明で使用予定)

  • run_assembler.sh
    repo.irslからDockerイメージをpullして、assemblerを起動する。

  • run_choreonoid.sh
    run_assembler.shとは別のコンテナで、通常のChoreonoidを起動する。

  • (exec.sh)
    run_assembler.sh で起動したコンテナの中に入る。(ユーザーは必要なさそう)

@tomosii tomosii self-assigned this Feb 15, 2023
@tomosii
Copy link
Collaborator Author

tomosii commented Feb 15, 2023

.shファイルをどこに置くかなど、ご意見ございましたらお願いします。

置き場所等が決まるまで、ここにshを載せておきます。

run_assembler.sh
#!/bin/bash
set -x

iname=${DOCKER_IMAGE:-"repo.irsl.eiiris.tut.ac.jp/choreonoid_robot_assembler_plugin:20.04"}
cname=${DOCKER_CONTAINER:-"irsl_choreonoid_assembler"}

DEFAULT_USER_DIR="$(pwd)"
DEFAULT_SETUP=${SETUP_FILE:-"/choreonoid_ws/install/setup.bash"}
mtdir=${MOUNTED_DIR:-$DEFAULT_USER_DIR}

VAR=${@:-"choreonoid --assembler /choreonoid_src/choreonoid/ext/robot_assembler_plugin/config/irsl/irsl_assembler_config.yaml /choreonoid_src/choreonoid/ext/robot_assembler_plugin/config/assembler.cnoid"}

if [ $# -eq 0 -a -z "$OPT" ]; then
    OPT=-it
fi

if [ "$NO_GPU" = "" ]; then
    GPU_OPT='--gpus all,"capabilities=compute,graphics,utility,display"'
else
    GPU_OPT=""
fi

NET_OPT="--net=host"

DOCKER_ENVIRONMENT_VAR=""

XDG_OPTION="-u $(id -u):$(id -g) --volume=/run/user/$(id -u):/tmp/xdg_runtime --env=XDG_RUNTIME_DIR=/tmp/xdg_runtime"

xhost +si:localuser:root

docker rm ${cname}

docker run \
    --pull=always    \
    --privileged     \
    --rm             \
    ${OPT}           \
    ${GPU_OPT}       \
    ${NET_OPT}       \
    ${DOCKER_ENVIRONMENT_VAR} \
    ${XDG_OPTION} \
    --env="DOCKER_ROS_SETUP=${DEFAULT_SETUP}" \
    --env="ROS_IP=localhost" \
    --env="ROS_MASTER_URI=http://localhost:11311" \
    --env="DISPLAY"  \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    --name=${cname} \
    --volume="${mtdir}:/workdir" \
    -w="/workdir" \
    ${iname} \
    ${VAR}
run_choreonoid.sh
#!/bin/bash
set -x

iname=${DOCKER_IMAGE:-"repo.irsl.eiiris.tut.ac.jp/choreonoid_robot_assembler_plugin:20.04"}
cname=${DOCKER_CONTAINER:-"irsl_choreonoid"}

DEFAULT_USER_DIR="$(pwd)"
DEFAULT_SETUP=${SETUP_FILE:-"/choreonoid_ws/install/setup.bash"}
mtdir=${MOUNTED_DIR:-$DEFAULT_USER_DIR}

VAR=${@:-"choreonoid"}

if [ $# -eq 0 -a -z "$OPT" ]; then
    OPT=-it
fi

if [ "$NO_GPU" = "" ]; then
    GPU_OPT='--gpus all,"capabilities=compute,graphics,utility,display"'
else
    GPU_OPT=""
fi

NET_OPT="--net=host"

DOCKER_ENVIRONMENT_VAR=""

XDG_OPTION="-u $(id -u):$(id -g) --volume=/run/user/$(id -u):/tmp/xdg_runtime --env=XDG_RUNTIME_DIR=/tmp/xdg_runtime"

xhost +si:localuser:root

docker rm ${cname}

docker run \
    --pull=always    \
    --privileged     \
    --rm             \
    ${OPT}           \
    ${GPU_OPT}       \
    ${NET_OPT}       \
    ${DOCKER_ENVIRONMENT_VAR} \
    ${XDG_OPTION} \
    --env="DOCKER_ROS_SETUP=${DEFAULT_SETUP}" \
    --env="ROS_IP=localhost" \
    --env="ROS_MASTER_URI=http://localhost:11311" \
    --env="DISPLAY"  \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    --name=${cname} \
    --volume="${mtdir}:/workdir" \
    -w="/workdir" \
    ${iname} \
    ${VAR}
exec.sh
container_name=${DOCKER_CONTAINER:-"irsl_choreonoid_assembler"}

docker exec -it ${container_name} bash

@tomosii
Copy link
Collaborator Author

tomosii commented Mar 16, 2023

上記shの docker run コマンドに --pull=always オプションを追加しました。

https://matsuand.github.io/docs.docker.jp.onthefly/engine/reference/commandline/run/#-set-the-pull-policy---pull

デフォルトは --pull=missing ですが、--pull=always にすると docker run 時にイメージのキャッシュが最新版でない場合、毎回イメージをプルし直してくれます。
→ 毎回最新版のAssemblerを起動できます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant