diff --git a/.gitignore b/.gitignore index e3305e30f..73fbae297 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ # Python compiled files __pycache__/ *.pyc -.idea/ +.idea # webots cache files soccer_webots/protos/*.cache soccer_webots/protos/Soccerbot_meshes/*.cache diff --git a/.gitmodules b/.gitmodules index 4fafdf74c..d0e4e73cd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "external/webots"] - path = external/webots - url = git@github.com:utra-robosoccer/webots.git - branch = R2022b [submodule "external/GameController"] path = external/GameController url = git@github.com:RoboCup-Humanoid-TC/GameController.git diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 3e22f4b71..000000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123c2..000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index a86eb75c1..000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2..000000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 64c2b57d8..000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 7a45522d0..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/remote-mappings.xml b/.idea/remote-mappings.xml deleted file mode 100644 index f97a43e32..000000000 --- a/.idea/remote-mappings.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/soccerbot.iml b/.idea/soccerbot.iml deleted file mode 100644 index 00c55d199..000000000 --- a/.idea/soccerbot.iml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 6fe457631..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/external/webots b/external/webots deleted file mode 160000 index a5ad48b34..000000000 --- a/external/webots +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a5ad48b34b281bc26042c843229514a8fd37b076 diff --git a/soccerbot/launch/modules/webots.launch b/soccerbot/launch/modules/webots.launch index b9d6fc77e..223f1e4e8 100644 --- a/soccerbot/launch/modules/webots.launch +++ b/soccerbot/launch/modules/webots.launch @@ -1,7 +1,7 @@ - + diff --git a/soccerbot/scripts/webots.sh b/soccerbot/scripts/webots.sh index 5e1ce5db5..f175f1124 100755 --- a/soccerbot/scripts/webots.sh +++ b/soccerbot/scripts/webots.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash export GAME_CONTROLLER_HOME=~/catkin_ws/src/soccerbot/external/GameController/ export JAVA_HOME=/usr -cd ~/catkin_ws/src/soccerbot/external/webots || exit 1 -#./webots ./../hlvs_webots/worlds/robocup.wbt -./webots ./../hlvs_webots/worlds/robocup.wbt +export WEBOTS_HOME=/usr/local/webots + +cd ~/catkin_ws/src/soccerbot/external || exit 1 +webots ./hlvs_webots/worlds/robocup.wbt diff --git a/tools/setup/setup.sh b/tools/setup/setup.sh new file mode 100644 index 000000000..2c774afa2 --- /dev/null +++ b/tools/setup/setup.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash + +check_internet_connection () { + if ! ping -q -c 1 -W 1 google.com > /dev/null; then + echo "No internet connection. Please check your internet connection to install the webots simulator." + exit 1 + fi +} + +ask_question() { + while true; do + read -p "$1 [Y/n]: " -n 1 -r response + echo "" + case $response in + [Yy] | "") return 0;; + [Nn]) return 1;; + * ) echo "Please answer yes or no.";; + esac + done +} + +setup_cuda(){ + if (( has_sudo )); then + export OS=ubuntu2004 + export ARCHITECTURE=x86_64 # sbsa for ARM + wget https://developer.download.nvidia.com/compute/cuda/repos/$OS/$ARCHITECTURE/cuda-$OS.pin + sudo mv cuda-$OS.pin /etc/apt/preferences.d/cuda-repository-pin-600 + sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${OS}/$ARCHITECTURE/3bf863cc.pub + sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/${OS}/$ARCHITECTURE/ /" + sudo apt-get update && sudo apt-get -y install cuda libcudnn9-cuda-12 libcudnn9-dev-cuda-12 libnccl2 libnccl-dev + else + echo "Please install CUDA manually!" + fi + +} + + +setup_ros(){ + if (( has_sudo )); then + echo "Setting up ROS ..." + sudo apt-get install -y python3-pip vim git git-lfs python-is-python3 + pip3 install pre-commit + echo "export PATH=/home/$USER/.local/bin:$PATH" >> ~/.bashrc && source ~/.bashrc + + sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' + sudo apt install -y curl # if you haven't already installed curl + curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - + sudo apt update && sudo apt install -y ros-noetic-desktop-full + echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc && source ~/.bashrc + sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential + sudo rosdep init + rosdep update + + sudo sh \ + -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" \ + > /etc/apt/sources.list.d/ros-latest.list' + wget http://packages.ros.org/ros.key -O - | sudo apt-key add - + sudo apt-get update && sudo apt-get install -y python3-catkin-tools + + + else + echo "Please install ROS manually!" + fi + +} + +setup_repo(){ + if (( has_sudo )); then + echo "Setting up Repo ..." + mkdir -p ~/catkin_ws/src && cd ~/catkin_ws + catkin init + catkin config --cmake-args -DCMAKE_BUILD_TYPE=Debug # For Debug builds + cd src + git clone --recurse-submodules git@github.com:utra-robosoccer/soccerbot.git + git pull + git submodule sync + git submodule update --init --recursive + git-lfs pull + git submodule foreach git-lfs pull + + cd ~/catkin_ws/src/soccerbot/ + sudo apt-get install -y $(cat tools/setup/rosdep.txt) + pip install --upgrade pip + pip install -U setuptools[core] + pip install -r /tools/setup/requirements.txt + if (( wants_cuda )) ; then + pip install -r /tools/setup/requirements-gpu.txt + fi + pre-commit install + rosdep update && rosdep install --from-paths . --ignore-src -r -y + + # Building the webots controllers + cd ~/catkin_ws/src/soccerbot/external/hlvs_webots + pip install -r controllers/referee/requirements.txt + sudo apt-get install protobuf-compiler libprotobuf-dev ant + make + + # Building GameController + cd ~/catkin_ws/src/soccerbot/external/GameController + ant + + mkdir -p /home/$USER/.ros/config && cd /home/$USER/.ros/config + ln -s /opt/ros/noetic/etc/ros/python_logging.conf + + catkin build soccerbot + echo "source /home/$USER/catkin_ws/devel/setup.bash" >> ~/.bashrc && source ~/.bashrc + + else + echo "Please install Repo manually!" + fi + +} + + + + +has_sudo=0 +wants_cuda=0 +if ask_question "Do you have sudo rights?"; then + has_sudo=1 +fi +if ask_question "Do you have a nvidia graphics card and want to install cuda"; then + wants_cuda=1 +fi + +if (( ! has_sudo )); then + echo "Because, you don't have sudo rights, ensure all necessary ROS packages are installed." +fi + +check_internet_connection + +if (( wants_cuda )) ; then + setup_cuda +fi + +setup_ros +setup_repo diff --git a/tools/setup/setup_webots.sh b/tools/setup/setup_webots.sh new file mode 100755 index 000000000..d253b11b4 --- /dev/null +++ b/tools/setup/setup_webots.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -eEo pipefail + +WEBOTS_VERSION="2022b" +WEBOTS_DOWNLOAD_URL="https://github.com/cyberbotics/webots/releases/download/R${WEBOTS_VERSION}/webots_${WEBOTS_VERSION}_amd64.deb" + +check_internet_connection () { + if ! ping -q -c 1 -W 1 google.com > /dev/null; then + echo "No internet connection. Please check your internet connection to install the webots simulator." + exit 1 + fi +} + +# Check if the correct webots simulator WEBOTS_VERSION is installed (apt) +if apt list webots --installed | grep -q "$WEBOTS_VERSION"; then + echo "Webots simulator release $WEBOTS_VERSION is already installed." +else + echo "Webots simulator release $WEBOTS_VERSION is not installed. Installing..." + # Check if we have an internet connection + check_internet_connection + # Check if the url exist + if ! curl --output /dev/null --silent --head --fail "$WEBOTS_DOWNLOAD_URL"; then + echo "Webots download url does not exist. Please check the url and update the 'WEBOTS_DOWNLOAD_URL' variable in the 'make_webots.sh' script." + exit 1 + fi + # Download the webots simulator dep package to temp folder + wget --no-verbose --show-progress "$WEBOTS_DOWNLOAD_URL" -O "/tmp/webots_${WEBOTS_VERSION}.deb" + # Install the webots simulator + sudo apt-get install "/tmp/webots_${WEBOTS_VERSION}.deb" -y + + echo "export WEBOTS_HOME=/usr/local/webots" >> ~/.bashrc && source ~/.bashrc + echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ros/noetic/lib/:$WEBOTS_HOME/lib/controller" >> ~/.bashrc + echo "export PYTHONPATH=$PYTHONPATH:$WEBOTS_HOME/lib/controller/python38" >> ~/.bashrc && source ~/.bashrc + +fi