diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be81bdc7bd8e78b883aeff9194790c8ab3a730a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM osrf/ros:melodic-desktop-full-bionic + +ENV uid 1000 +ENV gid 1000 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENV USERNAME ros +RUN useradd -m $USERNAME && \ + echo "$USERNAME:$USERNAME" | chpasswd && \ + usermod --shell /bin/bash $USERNAME && \ + usermod -aG sudo $USERNAME && \ + echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \ + chmod 0440 /etc/sudoers.d/$USERNAME && \ + # Replace 1000 with your user/group id + usermod --uid $uid $USERNAME && \ + groupmod --gid $gid $USERNAME + +WORKDIR /home/$USERNAME +COPY src /home/$USERNAME/src +RUN apt-get update && apt-get install -y \ + python-catkin-tools bash +RUN rosdep install --from-paths . -r -y +RUN catkin config \ + --extend /opt/ros/melodic && \ + catkin build + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index afa25cbdd3ec00b7b64fa851edde01b2c72ad86e..c65f7f0f586d480836886fe252a09182a4c0dcf4 100644 --- a/README.md +++ b/README.md @@ -44,5 +44,12 @@ See the [README.md of the submodule](../../../../sample_applications/-/blob/mast - Execution of a simple motion costraint by a blocking object: `roslaunch sample_applications sample_constraint_simulation.launch` - Execution of a velocity constraint cartesian trajectory: `roslaunch sample_applications simulation.launch` +## Docker +To run via docker on any up-to-date linux system: +- `docker build . -t ceti-panda-gazebo-workspace` +- `./docker-run.sh roslaunch sample_applications sample_simple_simulation.launch` + +Note that this expects your `uid` and `gid` to be `1000`. This is generally the case if your user is the primary user on your system. Otherwise, please change +the values at the top of the `Dockerfile`. \ No newline at end of file diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 0000000000000000000000000000000000000000..8fbb638b940b97eb4dd114f4c0f78145593a0be2 --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# http://wiki.ros.org/docker/Tutorials/GUI + +XSOCK=/tmp/.X11-unix +XAUTH=/tmp/.docker.xauth +touch $XAUTH +xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge - + +docker run -it \ + --volume=$XSOCK:$XSOCK:rw \ + --volume=$XAUTH:$XAUTH:rw \ + --env="XAUTHORITY=${XAUTH}" \ + --env="DISPLAY" \ + --user="ros" \ + ceti-panda-gazebo-workspace \ + "$@" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..527ef79f97e119b848d1817fcec54f9bc4be1227 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source /opt/ros/melodic/setup.bash +source $HOME/devel/setup.bash +exec "$@" \ No newline at end of file