Skip to content

Commit

Permalink
Merge pull request #4 from K3cks/binder-example
Browse files Browse the repository at this point in the history
PR: Binder integration
  • Loading branch information
sunava authored Nov 8, 2023
2 parents f164462 + aa46457 commit 64e2ec9
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "pycram/src/macropy"]
path = src/macropy
url = git@github.com:Tigul/macropy.git
[submodule "src/neem_interface_python"]
path = src/neem_interface_python
url = https://github.com/Tigul/neem_interface_python
url = https://github.com/Tigul/macropy
# [submodule "src/neem_interface_python"]
# path = src/neem_interface_python
# url = https://github.com/Tigul/neem_interface_python
38 changes: 38 additions & 0 deletions binder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM intel4coro/base-notebook:20.04-noetic-full-xpra

ENV PATH=$PATH:/home/user/.local/bin
ENV PYCRAM_WS=/home/${NB_USER}/workspace/ros
WORKDIR ${PYCRAM_WS}/src/
COPY --chown=${NB_USER}:users . pycram/
RUN vcs import --input pycram/binder/pycram-http.rosinstall --recursive

# === Following step should be replace to ===
RUN cd pycram \
&& git submodule update --init \
&& git clone https://github.com/Tigul/neem_interface_python.git src/neem_interface_python \
&& cd src/neem_interface_python \
&& git clone https://github.com/benjaminalt/neem-interface.git src/neem-interface
# === To ===
# RUN cd pycram
# && git submodule update --init --recursive
# === When all .gitmodules use https urls ===

RUN pip install --requirement ${PYCRAM_WS}/src/pycram/requirements.txt --user
RUN pip install --requirement ${PYCRAM_WS}/src/pycram/src/neem_interface_python/requirements.txt --user \
&& pip cache purge

# Build pycram workspace
WORKDIR ${PYCRAM_WS}
USER root
RUN rosdep update \
&& rosdep install -y --ignore-src --from-paths ./ -r \
&& rosdep fix-permissions
USER ${NB_USER}
RUN catkin build

WORKDIR ${PYCRAM_WS}/src/pycram
RUN git config --global --add safe.directory ${PWD}
COPY --chown=${NB_USER}:users binder/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["start-notebook.sh"]
RUN pip install https://raw.githubusercontent.com/yxzhan/jupyterlab-rviz/master/dist/jupyterlab_rviz-0.3.1.tar.gz
54 changes: 54 additions & 0 deletions binder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Pycram on BinderHub

Files for running Pycram on BinderHub.

## Quick Start

### Option 1: Test Image Locally (Under repo directory)

- Run Docker image

```bash
docker compose -f ./binder/docker-compose.yml up
```

- Run Docker image with X-forwarding

```bash
xhost +local:docker && \
docker compose -f ./binder/docker-compose.yml up && \
xhost -local:docker
```

- Open Web browser and go to http://localhost:8888/

- To stop and remove container:

```bash
docker compose -f ./binder/docker-compose.yml down
```

- Force image rebuild

```bash
docker compose -f ./binder/docker-compose.yml up -d --build
```

### Option 2: Run on BinderHub

- intro.ipynb: [![Binder](https://binder.intel4coro.de/badge_logo.svg)](https://binder.intel4coro.de/v2/gh/IntEL4CoRo/pycram.git/binder-xpra?urlpath=lab%2Ftree%2Fexamples%2Fintro.ipynb)

- Passing ROS paramters (robot=pr2, environment=kitchen): [![Binder](https://binder.intel4coro.de/badge_logo.svg)](https://binder.intel4coro.de/v2/gh/IntEL4CoRo/pycram.git/binder-xpra?urlpath=lab%2Ftree%2Fexamples%2Faction_designator.ipynb%3Frobot%3Dpr2%26environment%3Dkitchen)

## Usage

1. Open notebooks in [../examples](../examples)

1. PyCram Docs: https://pycram.readthedocs.io/en/latest/examples.html

## Files Descriptions

1. ***[Dockerfile](./Dockerfile):*** Pycram jupyterlab docker image.
1. ***[pycram-http.rosinstall](./pycram-http.rosinstall):*** Initiating ros workspace in docker image require https url. (Comparing to [pycram.rosinstall](../pycram.rosinstall): pycram is excluded, repo `orocos_kinematics_dynamics` is PyKDL).
1. ***[entrypoint.sh](./entrypoint.sh):*** Entrypoint of the docker image, start roscore and robot web tools.
1. ***[docker-compose.yml](./docker-compose.yml):*** For testing the docker image locally.
29 changes: 29 additions & 0 deletions binder/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'
services:
pycram:
image: pycram:binder-xpra
build:
context: ../
dockerfile: ./binder/Dockerfile
stdin_open: true
tty: true
ports:
- 8888:8888
privileged: true
# user: root
command: jupyter lab --allow-root --NotebookApp.token='' --no-browser --ip=0.0.0.0
entrypoint: ["/home/jovyan/work/binder/entrypoint.sh"]
volumes:
- ../:/home/jovyan/work
- /tmp/.X11-unix:/tmp/.X11-unix:rw
environment:
- DISPLAY
- QT_X11_NO_MITSHM=1
- NVIDIA_DRIVER_CAPABILITIES=all
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
10 changes: 10 additions & 0 deletions binder/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

source ${PYCRAM_WS}/devel/setup.bash
roscore &
roslaunch --wait rvizweb rvizweb.launch config_file:=${PYCRAM_WS}/src/pycram/binder/rvizweb_config.json &
roslaunch --wait pycram ik_and_description.launch &

cp ${PYCRAM_WS}/src/pycram/binder/webapps.json ${PYCRAM_WS}/src/rvizweb/webapps/app.json

exec "$@"
25 changes: 25 additions & 0 deletions binder/pycram-http.rosinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repositories:
iai_maps:
type: git
url: https://github.com/code-iai/iai_maps.git
version: master
iai_robots:
type: git
url: http://github.com/code-iai/iai_robots.git
version: master
pr2_common:
type: git
url: https://github.com/PR2/pr2_common.git
version: b34703bcca2b07cadbc3777d3c504c232a0c0c28
kdl_ik_services:
type: git
url: https://github.com/cram2/kdl_ik_service.git
verison: master
pr2_kinematics:
type: git
url: https://github.com/PR2/pr2_kinematics.git
version: kinetic-devel
orocos_kinematics_dynamics:
type: git
url: https://github.com/orocos/orocos_kinematics_dynamics.git
version: v1.5.1
34 changes: 34 additions & 0 deletions binder/rvizweb_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"globalOptions": {
"background": "#333333",
"fixedFrame": "/simulated/odom"
},
"sidebarOpened": true,
"displays": [
{
"isShown": true,
"name": "Grid",
"options": {
"cellSize": "1",
"color": "#888888",
"numCells": "10"
},
"type": "grid"
},
{
"isShown": true,
"name": "TF",
"options": {},
"type": "tf"
},
{
"isShown": true,
"name": "Robot model",
"options": {
"param": "robot_description",
"tfPrefix": "simulated/pr2_2"
},
"type": "urdf"
}
]
}
33 changes: 33 additions & 0 deletions binder/webapps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"name": "rvizweb",
"title": "Rvizweb",
"icon": "proxy/8001/rvizweb/webapps/r.svg",
"url": "proxy/8001/rvizweb/webapps/rvizweb/build/www/index.html"
},
{
"name": "XPRA",
"title": "Xpra Desktop",
"icon": "proxy/8001/rvizweb/webapps/xpra-logo.svg",
"url": "xprahtml5/index.html",
"start": true
},
{
"name": "rosgraph",
"title": "Ros Graph",
"icon": "proxy/8001/rvizweb/webapps/o.svg",
"url": "proxy/8001/rvizweb/webapps/ros-node-graph/build/index.html"
},
{
"name": "rosboard",
"title": "ROSBoard",
"icon": "proxy/8001/rvizweb/webapps/s.svg",
"url": "proxy/18888/index.html"
},
{
"name": "webviz",
"title": "Webviz",
"icon": "proxy/8001/rvizweb/webapps/webviz/icon.svg",
"url": "proxy/8001/rvizweb/webapps/webviz/index.html"
}
]
Loading

0 comments on commit 64e2ec9

Please sign in to comment.