From c0d97451dc2e0aa05ec157b40213bb4b53ac7770 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Thu, 3 Aug 2023 18:49:40 +0200 Subject: [PATCH 01/16] Update dependencies and add vscode extensions docs --- .gitignore | 1 - .vscode/settings.json | 96 +++++++++++++++++++++ README.md | 36 +++++++- requirements.txt => requirements/common.txt | 0 requirements/dev.txt | 3 + 5 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json rename requirements.txt => requirements/common.txt (100%) create mode 100644 requirements/dev.txt diff --git a/.gitignore b/.gitignore index 9a8c42611..77daa15da 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ *.pyc .pyenv2/* .pyenv3/* -.vscode/* ansible_robots/* doc_internal/* diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..ee1685103 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,96 @@ +{ + "autoDocstring.docstringFormat": "sphinx", + "cSpell.language": "en,de-de,lorem", + "cSpell.words": [ + "autoconnect", + "basler", + "bitbot", + "bitbots", + "bringup", + "cartesian", + "chrt", + "coef", + "colcon", + "CORNERKICK", + "CPUS", + "cuda", + "cudnn", + "Cyberbotics", + "darknet", + "DROPBALL", + "DROPIN", + "dsize", + "dtype", + "Dynamixel", + "Dynup", + "EXTERNPROTO", + "fieldboundary", + "fieldname", + "fovs", + "FREEKICK", + "gamecontroller", + "gamestate", + "GOALKICK", + "hlvs", + "hostnames", + "hsv", + "imgmsg", + "imread", + "imwrite", + "isolcpus", + "isort", + "jupyter", + "Kalman", + "linalg", + "matplotlib", + "mutex", + "nanosec", + "ndarray", + "nmcli", + "odom", + "odometry", + "PENALTYKICK", + "pointcloud", + "pointclouds", + "pretrained", + "proto", + "protos", + "pyplot", + "rclcpp", + "rclpy", + "robocup", + "RoboCup", + "rosbag", + "rosbags", + "rosdep", + "rosdeps", + "rosgraph", + "rosout", + "ROUNDROBIN", + "rtype", + "rviz", + "scipy", + "seaborn", + "segmentations", + "taskset", + "teamplayer", + "teleop", + "THROWIN", + "timespec", + "tqdm", + "unpenalized", + "urdf", + "URDF", + "walkready", + "wandb", + "Webots", + "wifi", + "wolfgang", + "yoeo", + "yolo", + "yolov" + ], + "files.autoSave": "onFocusChange", + "files.insertFinalNewline": true, + "python.analysis.typeCheckingMode": "basic" +} diff --git a/README.md b/README.md index 4de994351..5678714e6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # bitbots_meta + This git repository contains all RoboCup-related code and documentation from the Hamburg Bit-Bots team as git submodules. All code is written as ROS 2 packages for ROS 2 on Ubuntu. @@ -6,6 +7,8 @@ All code is written as ROS 2 packages for ROS 2 on Ubuntu. ## Installation +Full step-by-step instructions for installing the Bit-Bots software stack and ROS 2 can be found in our documentation [here](https://doku.bit-bots.de/meta/manual/tutorials/install_software_ros2.html). + To download the Bit-Bots software stack clone this repository. ```bash @@ -41,10 +44,35 @@ Other scripts are available in the `scripts` folder, [documented here](scripts/R The naming prefix of submodules indicates the scope of the packages. - * bitbots_ : specific RoboCup code of our team which follows interface specification of humanoid_league_msgs - * humanoid_league_ : packages which are useful for all teams in the RoboCup Humanoid League, e.g. visualization tools and gamecontroller - * no prefix : packages which are useful in general and usable outside of RoboCup - * lib : folder for third party libraries that need to be build from source +* bitbots_ : specific RoboCup code of our team which follows interface specification of humanoid_league_msgs +* humanoid_league_ : packages which are useful for all teams in the RoboCup Humanoid League, e.g. visualization tools and gamecontroller +* no prefix : packages which are useful in general and usable outside of RoboCup +* lib : folder for third party libraries that need to be build from source + +## Recommended VSCode extensions + +```bash +code --install-extension cschlosser.doxdocgen && \ # Generates doxygen comments +code --install-extension DavidAnson.vscode-markdownlint && \ # Lints markdown files +code --install-extension DotJoshJohnson.xml && \ # XML support +code --install-extension eamodio.gitlens && \ # Extended git highlighting +code --install-extension mohsen1.prettify-json && \ # JSON formatting +code --install-extension ms-azuretools.vscode-docker && \ # Docker support +code --install-extension MS-CEINTL.vscode-language-pack-de && \ # German language pack +code --install-extension ms-iot.vscode-ros && \ # ROS support +code --install-extension ms-python.python && \ # Python support +code --install-extension ms-python.vscode-pylance && \ # Python support +code --install-extension ms-vscode.cmake-tools && \ # CMake support +code --install-extension ms-vscode.cpptools && \ # C++ support +code --install-extension ms-vscode.cpptools-extension-pack && \ # C++ support +code --install-extension ms-vscode.cpptools-themes && \ # C++ support +code --install-extension njpwerner.autodocstring && \ # Generates docstrings +code --install-extension streetsidesoftware.code-spell-checker && \ # Spell checker +code --install-extension streetsidesoftware.code-spell-checker-german && \ # Spell checker +code --install-extension tamasfe.even-better-toml && \ # TOML support +code --install-extension twxs.cmake && \ # CMake support +code --install-extension zxh404.vscode-proto3 # Protobuf support +``` ## Documentation diff --git a/requirements.txt b/requirements/common.txt similarity index 100% rename from requirements.txt rename to requirements/common.txt diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 000000000..316163d0a --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,3 @@ +black +pre-commit +ruff From 2b3644f4ba276a58c32ec58c971c3b195f656d53 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 20:46:37 +0200 Subject: [PATCH 02/16] Add pre-commit-install make command --- Makefile | 1 + scripts/pre-commit-install.sh | 4 ++++ 2 files changed, 5 insertions(+) create mode 100755 scripts/pre-commit-install.sh diff --git a/Makefile b/Makefile index 1a4eb737e..332dc1f63 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ pull-init: git pull scripts/pull_init.sh scripts/pull_files.bash + scripts/pre-commit-install.sh pull-files: scripts/pull_files.bash diff --git a/scripts/pre-commit-install.sh b/scripts/pre-commit-install.sh new file mode 100755 index 000000000..ad0014f68 --- /dev/null +++ b/scripts/pre-commit-install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Install pre-commit hooks for all submodules that have a .pre-commit-config.yaml file +git submodule foreach "test -f .pre-commit-config.yaml && pre-commit install || :" From 427f89181c1df70d0aaa11c31432f8b7b8793b53 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 20:47:05 +0200 Subject: [PATCH 03/16] Clean up make commands --- Makefile | 7 +- scripts/install.pl | 190 ---------------------------------------- scripts/pull_files.bash | 4 +- 3 files changed, 4 insertions(+), 197 deletions(-) delete mode 100755 scripts/install.pl diff --git a/Makefile b/Makefile index 332dc1f63..b09fe6a9f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : basler doc install update pull-all pull-init vision-files status +.PHONY : basler doc update pull-all pull-init status basler: test -d basler_drivers || git clone git@git.mafiasi.de:Bit-Bots/basler_drivers.git @@ -7,9 +7,6 @@ basler: doc: scripts/build-doc.py -install: pull-init - scripts/install.pl - update: pull-all rosdep install -irya @@ -28,4 +25,4 @@ pull-files: scripts/pull_files.bash status: - scripts/git_status.bash \ No newline at end of file + scripts/git_status.bash diff --git a/scripts/install.pl b/scripts/install.pl deleted file mode 100755 index 944ff493a..000000000 --- a/scripts/install.pl +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; - -use Cwd; -use File::Path; - -my $ROS_WORKSPACE = "/opt/ros/melodic"; -my $start_dir = Cwd::cwd(); - -sub get_location() { - my $location = $ENV{'HOME'} . '/catkin_ws'; - if (defined $ENV{'CATKIN_WS'}) { - $location = $ENV{'CATKIN_WS'}; - } - return $location; -} - -sub read_yes_no_input() { - # Interpret input - chomp(my $input = ); - $input = lc $input; - if ($input eq 'yes' || $input eq 'y' || $input eq "") { - return 1; - } - else { - return 0; - } -} - - -sub prepare_workspace_location() { - my $location = get_location(); - - if (-e $location) { - # Ask the user how to handle the existing entity at catkin_ws location - if (-d $location) { - if (-e $location . "/.catkin_tools" && -d $location . "/.catkin_tools") { - print "$location seems to already be a Catkin Workspace.$/"; - print "Do you want me to remove it and create a new one?$/"; - print "[Y/n]: "; - } - else { - print "Directory $location already exists but doesn't seem to be a Catkin Workspace.$/"; - print "Do you want me to remove it and create a new Catkin Workspace there?$/"; - print "[Y/n]: "; - } - } - else { - print "$location already exists but is not a directory.$/"; - print "Do you want me to remove the existing file and create a Catkin Workspace there?$/"; - print "[Y/n]: "; - } - - # Remove the existing location if answer is yes - if (read_yes_no_input()) { - print "Ok. Deleting old location$/"; - rmtree $location; - unlink $location; - print "Creating new Workspace at $location$/"; - mkdir $location; - mkdir $location . "/src"; - } else { - print "Not gonna delete it then...$/"; - } - } else { - print "Creating new Workspace at $location$/"; - mkdir $location; - mkdir $location . "/src"; - } -} - -sub configure_catkin_workspace() { - my $location = get_location(); - - print "Configuring workspace at $location$/"; - chdir $location; - # human_pose_estimation is currently blacklisted because it doesn't build - system "bash -c \"source $ROS_WORKSPACE/setup.bash && catkin config --init -DPYTHON_VERSION=3 --blacklist human_pose_estimation_openvino\""; -} - -sub link_bitbots_meta() { - my $location = get_location(); - - print "I will assume bitbots_meta to be at you current location ($start_dir).$/"; - print "Is that correct? [Y/n] "; - - if (read_yes_no_input()) { - print "Linking bitbots_meta$/"; - system "ln -sT $start_dir $location/src/bitbots_meta"; - } else { - die "Please navigate to bitbots_meta then...$/"; - } -} - -sub prepare_ros() { - print "Rosdep will be installed to resolve ROS dependecies$/"; - if (-e "/etc/apt/sources.list.d/ros-latest.list") { - system "sudo rm /etc/apt/sources.list.d/ros-latest.list" - and die "Unable to remove old ros source list"; - } - if (-e "/etc/apt/sources.list.d/ros-final.list") { - system "sudo rm /etc/apt/sources.list.d/ros-final.list" - and die "Unable to remove old ros source list"; - } - if (! -e "/etc/apt/sources.list.d/ros.list") { - system "sudo sh -c 'echo \"deb http://packages.bit-bots.de bionic main\" > /etc/apt/sources.list.d/ros.list'" - and die "Unable to add ROS sources"; - } - system "sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 4C4EDF893374591687621C75C2F8DBB6A37B2874" - or system "sudo apt update" - or system "sudo apt install -y python3-pip python3-rosdep" - or system "sudo pip3 install git+https://github.com/catkin/catkin_tools.git" - and die "Unable to install rosdep"; - system "sudo apt install -y ros-melodic-desktop-full" - and die "Unable to install ROS"; -} - -sub install_rosdeps() { - my $location = get_location(); - - print "Do you want to use rosdep to resolve dependencies now?$/"; - print "[Y/n]: "; - if (read_yes_no_input()) { - system "sudo rosdep init"; - system "rosdep update" - or system "bash -c \"source /opt/ros/melodic/setup.bash && rosdep install -i -r -y --from-paths $location/src\"" - and die "Rosdep initialization failed"; - } -} - -sub install_pip() { - print "Installing python dependencies...$/"; - system "pip3 install --user -r $start_dir/requirements.txt" and die "pip3 package installation failed"; -} - -sub first_catkin_build() { - my $location = get_location(); - chdir $location; - - print "Do you want to execute 'catkin build' now?$/"; - print "[Y/n]: "; - if (read_yes_no_input()) { - system "bash -c \"source /opt/ros/melodic/setup.bash && catkin build\""; - } -} - -sub clone_internal_repos() { - # Clone internal bitbots_repos into bitbots_meta - chdir $start_dir; - - print "Do you want to clone the private repos ('ansible', 'doku' and 'basler_drivers') now?$/"; - print "[Y/n]: "; - if (read_yes_no_input()) { - if (! -e "ansible") { - system 'git clone git@git.mafiasi.de:Bit-Bots/ansible.git bitbots_tools/ansible' - and print "Could not clone ansible_robots$/$/"; - } else { - print "ansible is already cloned$/"; - } - - if (! -e "doku") { - system 'git clone git@git.mafiasi.de:Bit-Bots/doku.git bitbots_tools/bitbots_docs_internal' - and print "Could not clone doku$/$/"; - } else { - print "doku is already cloned$/"; - } - - if (! -e "basler_drivers") { - system 'git clone git@git.mafiasi.de:Bit-Bots/basler_drivers.git' - and print "Could not clone basler_drivers$/$/"; - } else { - print "basler_drivers is already cloned$/"; - } - print "Installing basler drivers...$/"; - system 'make basler'; - } -} - - -prepare_ros(); -prepare_workspace_location(); -configure_catkin_workspace(); -link_bitbots_meta(); -install_rosdeps(); -install_pip(); -clone_internal_repos(); -first_catkin_build(); -chdir $start_dir; -print "Congratulations, the installation was successful!$/"; diff --git a/scripts/pull_files.bash b/scripts/pull_files.bash index 485527961..64f1c7e04 100755 --- a/scripts/pull_files.bash +++ b/scripts/pull_files.bash @@ -2,6 +2,6 @@ META=$(dirname $(dirname $(realpath $0))) rm -rf $META/bitbots_vision/bitbots_vision/models/fcnn03 $META/bitbots_vision/bitbots_vision/models/fcnn031 $META/bitbots_vision/bitbots_vision/models/fcnn032 $META/bitbots_vision/bitbots_vision/models/classifier01 -wget -r -N -np -nH -P $META/bitbots_vision/bitbots_vision --reject "index.html*" "http://data.bit-bots.de/models/" +wget -r -N -np -nH -P $META/bitbots_vision/bitbots_vision --reject "index.html*" "https://data.bit-bots.de/models/" -wget -r -N -np -nH -P $META/bitbots_motion/bitbots_rl_motion --reject "index.html*" "http://data.bit-bots.de/rl_walk_models/" \ No newline at end of file +wget -r -N -np -nH -P $META/bitbots_motion/bitbots_rl_motion --reject "index.html*" "https://data.bit-bots.de/rl_walk_models/" From f9f8964d64a12a87c24f2c54346819b694787c9b Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 21:46:24 +0200 Subject: [PATCH 04/16] Requirements: add robot environment, include other --- requirements/common.txt | 7 +------ requirements/dev.txt | 4 ++++ requirements/robot.txt | 6 ++++++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 requirements/robot.txt diff --git a/requirements/common.txt b/requirements/common.txt index 3289be88d..fd142b3c4 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -1,12 +1,7 @@ -fabric +# This file includes common dependencies for all environments filterpy -mycroft-mimic3-tts pip -pydot -pyopencl pytorchyolo -pyttsx3 -rich git+https://github.com/SammyRamone/stable-baselines3.git git+https://github.com/bit-bots/deep_quintic.git git+https://github.com/Flova/pyastar2d diff --git a/requirements/dev.txt b/requirements/dev.txt index 316163d0a..7b1828cba 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,3 +1,7 @@ +# This file is used by pip to install dependencies for the development environment +-r robot.txt # Include robot.txt dependencies black +fabric pre-commit +rich ruff diff --git a/requirements/robot.txt b/requirements/robot.txt new file mode 100644 index 000000000..fac28c2dc --- /dev/null +++ b/requirements/robot.txt @@ -0,0 +1,6 @@ +# This file is used for installation of dependencies on the robot +-r common.txt # Includes all common dependencies +mycroft-mimic3-tts +pydot +pyopencl +pyttsx3 From 8470008c62b36d57470e5f2507ad31e6a7ed17b5 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 21:47:09 +0200 Subject: [PATCH 05/16] Makefile: Add update command for rosdep, pip, pre-commit --- Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b09fe6a9f..00346d96e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : basler doc update pull-all pull-init status +.PHONY : basler doc pip-install pre-commit pull-all pull-init rosdep-install status update basler: test -d basler_drivers || git clone git@git.mafiasi.de:Bit-Bots/basler_drivers.git @@ -7,8 +7,11 @@ basler: doc: scripts/build-doc.py -update: pull-all - rosdep install -irya +pip-install: + pip install --upgrade -r requirements/dev.txt + +pre-commit: + scripts/pre-commit-install.sh pull-all: git pull @@ -19,10 +22,20 @@ pull-init: git pull scripts/pull_init.sh scripts/pull_files.bash - scripts/pre-commit-install.sh + pre-commit-install pull-files: scripts/pull_files.bash +rosdep-install: + rosdep update + rosdep install -iry --from-paths . + status: scripts/git_status.bash + +update: + pull-all + rosdep-update + pre-commit-install + pip-install From e2a1437572559365ee4064d23ca60352a460ab26 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 21:51:19 +0200 Subject: [PATCH 06/16] Makefile: Add install command --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 00346d96e..27d0bbe29 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : basler doc pip-install pre-commit pull-all pull-init rosdep-install status update +.PHONY : basler doc install pip-install pre-commit pull-all pull-init rosdep-install status update basler: test -d basler_drivers || git clone git@git.mafiasi.de:Bit-Bots/basler_drivers.git @@ -7,6 +7,9 @@ basler: doc: scripts/build-doc.py +install: pull-init + update + pip-install: pip install --upgrade -r requirements/dev.txt From 9c887317bf676a5ffb2e221e25289344f85cc5ea Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 21:55:12 +0200 Subject: [PATCH 07/16] Fix pre-commit-install --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 27d0bbe29..0f169a2b8 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ pull-init: git pull scripts/pull_init.sh scripts/pull_files.bash - pre-commit-install + pre-commit pull-files: scripts/pull_files.bash @@ -40,5 +40,5 @@ status: update: pull-all rosdep-update - pre-commit-install + pre-commit pip-install From 8e841d0bea1770a6d3f47df8da6cd138e39258a9 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 21:56:03 +0200 Subject: [PATCH 08/16] Makefile: Remove pre-commit-install from pull-init --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 0f169a2b8..66078f7ca 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,6 @@ pull-init: git pull scripts/pull_init.sh scripts/pull_files.bash - pre-commit pull-files: scripts/pull_files.bash From 18aec0c3556f3de335ffa1488f6725a4ee9813f6 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 22:05:40 +0200 Subject: [PATCH 09/16] Makefile: fix rosdep command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 66078f7ca..960362275 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,6 @@ status: update: pull-all - rosdep-update + rosdep-install pre-commit pip-install From 8505735fdfd48618eb4813c09dcccaefe71a05c8 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 22:45:37 +0200 Subject: [PATCH 10/16] Makefile: Subcommands to own files --- Makefile | 26 ++++++++----------- scripts/make_basler.sh | 8 ++++++ scripts/make_install.sh | 4 +++ scripts/make_pip.sh | 4 +++ ...e-commit-install.sh => make_pre-commit.sh} | 0 scripts/make_rosdep.sh | 5 ++++ scripts/make_update.sh | 5 ++++ 7 files changed, 37 insertions(+), 15 deletions(-) create mode 100755 scripts/make_basler.sh create mode 100755 scripts/make_install.sh create mode 100755 scripts/make_pip.sh rename scripts/{pre-commit-install.sh => make_pre-commit.sh} (100%) create mode 100755 scripts/make_rosdep.sh create mode 100755 scripts/make_update.sh diff --git a/Makefile b/Makefile index 960362275..60d411721 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,20 @@ -.PHONY : basler doc install pip-install pre-commit pull-all pull-init rosdep-install status update +.PHONY : basler doc install pip pre-commit pull-all pull-init pull-files rosdep status update basler: - test -d basler_drivers || git clone git@git.mafiasi.de:Bit-Bots/basler_drivers.git - cd basler_drivers && ./setup.sh + scripts/make_basler.sh doc: scripts/build-doc.py install: pull-init - update + scripts/make_basler.sh + update-foo -pip-install: - pip install --upgrade -r requirements/dev.txt +pip: + scripts/make_pip.sh pre-commit: - scripts/pre-commit-install.sh + scripts/make_pre-commit.sh pull-all: git pull @@ -29,15 +29,11 @@ pull-init: pull-files: scripts/pull_files.bash -rosdep-install: - rosdep update - rosdep install -iry --from-paths . +rosdep: + scripts/make_rosdep.sh status: scripts/git_status.bash -update: - pull-all - rosdep-install - pre-commit - pip-install +update: pull-all + script/make_update.sh diff --git a/scripts/make_basler.sh b/scripts/make_basler.sh new file mode 100755 index 000000000..497966494 --- /dev/null +++ b/scripts/make_basler.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Install Basler drivers +# Check if basler_drivers is already installed +# If not, clone the repository +# Run the setup script to install the drivers +test -d basler_drivers || git clone git@git.mafiasi.de:Bit-Bots/basler_drivers.git +cd basler_drivers && ./setup.sh diff --git a/scripts/make_install.sh b/scripts/make_install.sh new file mode 100755 index 000000000..0cbc75d42 --- /dev/null +++ b/scripts/make_install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +scripts/make_basler.sh +scripts/make_update.sh diff --git a/scripts/make_pip.sh b/scripts/make_pip.sh new file mode 100755 index 000000000..2df8e746e --- /dev/null +++ b/scripts/make_pip.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Install and upgrade pip dependencies +pip install --upgrade -r requirements/dev.txt diff --git a/scripts/pre-commit-install.sh b/scripts/make_pre-commit.sh similarity index 100% rename from scripts/pre-commit-install.sh rename to scripts/make_pre-commit.sh diff --git a/scripts/make_rosdep.sh b/scripts/make_rosdep.sh new file mode 100755 index 000000000..173b9644b --- /dev/null +++ b/scripts/make_rosdep.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# Update rosdep and install dependencies from meta directory +rosdep update +rosdep install -iry --from-paths . diff --git a/scripts/make_update.sh b/scripts/make_update.sh new file mode 100755 index 000000000..883bf089c --- /dev/null +++ b/scripts/make_update.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +scripts/make_rosdep.sh +scripts/make_pre-commit.sh +scripts/make_pip.sh From 411e9dacf4873754bfba83ba1971f4d5ba71d92b Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 23:11:09 +0200 Subject: [PATCH 11/16] Makefile: fix again --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 60d411721..c40be12a9 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ doc: install: pull-init scripts/make_basler.sh - update-foo + script/make_update.sh pip: scripts/make_pip.sh From 51eb7de97ebc48747220ca4702880ad31f021b0e Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 23:14:58 +0200 Subject: [PATCH 12/16] Makefile: Its enough! --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c40be12a9..d4f90859b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ doc: install: pull-init scripts/make_basler.sh - script/make_update.sh + scripts/make_update.sh pip: scripts/make_pip.sh @@ -36,4 +36,4 @@ status: scripts/git_status.bash update: pull-all - script/make_update.sh + scripts/make_update.sh From 6d5073945033e4d14c13f412f39961ff09890c81 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 23:25:20 +0200 Subject: [PATCH 13/16] Makefile: final fix and remove doc command --- Makefile | 5 +---- scripts/make_update.sh | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d4f90859b..ce8c58b73 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,8 @@ -.PHONY : basler doc install pip pre-commit pull-all pull-init pull-files rosdep status update +.PHONY : basler install pip pre-commit pull-all pull-init pull-files rosdep status update basler: scripts/make_basler.sh -doc: - scripts/build-doc.py - install: pull-init scripts/make_basler.sh scripts/make_update.sh diff --git a/scripts/make_update.sh b/scripts/make_update.sh index 883bf089c..f141c651d 100755 --- a/scripts/make_update.sh +++ b/scripts/make_update.sh @@ -1,5 +1,5 @@ #!/bin/sh scripts/make_rosdep.sh -scripts/make_pre-commit.sh scripts/make_pip.sh +scripts/make_pre-commit.sh From 426975897ddd99a24140b8210b2d6d85fa6988cb Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 23:32:38 +0200 Subject: [PATCH 14/16] Makefile: Add vscode command to install recommended extensions --- Makefile | 5 ++++- README.md | 29 ++--------------------------- scripts/make_vscode.sh | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100755 scripts/make_vscode.sh diff --git a/Makefile b/Makefile index ce8c58b73..fc5dfb8b7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY : basler install pip pre-commit pull-all pull-init pull-files rosdep status update +.PHONY : basler install pip pre-commit pull-all pull-init pull-files rosdep status update vs-code basler: scripts/make_basler.sh @@ -34,3 +34,6 @@ status: update: pull-all scripts/make_update.sh + +vs-code: + scripts/make_vscode.sh diff --git a/README.md b/README.md index 5678714e6..eded51a85 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ If you want to update all submodules, this repo, and supplementing files, run make pull-all ``` -Make sure you are on the correct branch and have no uncommited changes in each submodule. +Make sure you are on the correct branch and have no uncommitted changes in each submodule. To check this run ```bash @@ -45,35 +45,10 @@ Other scripts are available in the `scripts` folder, [documented here](scripts/R The naming prefix of submodules indicates the scope of the packages. * bitbots_ : specific RoboCup code of our team which follows interface specification of humanoid_league_msgs -* humanoid_league_ : packages which are useful for all teams in the RoboCup Humanoid League, e.g. visualization tools and gamecontroller +* humanoid_league_ : packages which are useful for all teams in the RoboCup Humanoid League, e.g. visualization tools and game controller * no prefix : packages which are useful in general and usable outside of RoboCup * lib : folder for third party libraries that need to be build from source -## Recommended VSCode extensions - -```bash -code --install-extension cschlosser.doxdocgen && \ # Generates doxygen comments -code --install-extension DavidAnson.vscode-markdownlint && \ # Lints markdown files -code --install-extension DotJoshJohnson.xml && \ # XML support -code --install-extension eamodio.gitlens && \ # Extended git highlighting -code --install-extension mohsen1.prettify-json && \ # JSON formatting -code --install-extension ms-azuretools.vscode-docker && \ # Docker support -code --install-extension MS-CEINTL.vscode-language-pack-de && \ # German language pack -code --install-extension ms-iot.vscode-ros && \ # ROS support -code --install-extension ms-python.python && \ # Python support -code --install-extension ms-python.vscode-pylance && \ # Python support -code --install-extension ms-vscode.cmake-tools && \ # CMake support -code --install-extension ms-vscode.cpptools && \ # C++ support -code --install-extension ms-vscode.cpptools-extension-pack && \ # C++ support -code --install-extension ms-vscode.cpptools-themes && \ # C++ support -code --install-extension njpwerner.autodocstring && \ # Generates docstrings -code --install-extension streetsidesoftware.code-spell-checker && \ # Spell checker -code --install-extension streetsidesoftware.code-spell-checker-german && \ # Spell checker -code --install-extension tamasfe.even-better-toml && \ # TOML support -code --install-extension twxs.cmake && \ # CMake support -code --install-extension zxh404.vscode-proto3 # Protobuf support -``` - ## Documentation Our documentation is hosted on [docs.bit-bots.de](https://docs.bit-bots.de/). diff --git a/scripts/make_vscode.sh b/scripts/make_vscode.sh new file mode 100755 index 000000000..fdb1835ed --- /dev/null +++ b/scripts/make_vscode.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +code --install-extension cschlosser.doxdocgen # Generates doxygen comments +code --install-extension DavidAnson.vscode-markdownlint # Lints markdown files +code --install-extension DotJoshJohnson.xml # XML support +code --install-extension eamodio.gitlens # Extended git highlighting +code --install-extension mohsen1.prettify-json # JSON formatting +code --install-extension ms-azuretools.vscode-docker # Docker support +code --install-extension MS-CEINTL.vscode-language-pack-de # German language pack +code --install-extension ms-iot.vscode-ros # ROS support +code --install-extension ms-python.python # Python support +code --install-extension ms-python.vscode-pylance # Python support +code --install-extension ms-vscode.cmake-tools # CMake support +code --install-extension ms-vscode.cpptools # C++ support +code --install-extension ms-vscode.cpptools-extension-pack # C++ support +code --install-extension ms-vscode.cpptools-themes # C++ support +code --install-extension njpwerner.autodocstring # Generates docstrings +code --install-extension streetsidesoftware.code-spell-checker # Spell checker +code --install-extension streetsidesoftware.code-spell-checker-german # Spell checker +code --install-extension tamasfe.even-better-toml # TOML support +code --install-extension twxs.cmake # CMake support +code --install-extension zxh404.vscode-proto3 # Protobuf support From 3b240fc71f01ae1792d900ca39fbe4c089def2cf Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Fri, 11 Aug 2023 23:48:05 +0200 Subject: [PATCH 15/16] Remove unused scripts --- scripts/build-doc.py | 207 -------- scripts/catkin-to-ament.py | 954 ------------------------------------- 2 files changed, 1161 deletions(-) delete mode 100755 scripts/build-doc.py delete mode 100644 scripts/catkin-to-ament.py diff --git a/scripts/build-doc.py b/scripts/build-doc.py deleted file mode 100755 index f77edd20e..000000000 --- a/scripts/build-doc.py +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/env python3 -import sys -import os -import argparse -import subprocess -from rospkg import RosPack - -EXCLUDED_PACKAGES = [ - 'wolves_image_provider', # not our package and we wil deprecate it soon anyways - 'bitbots_animation_server', # startup on import - 'bitbots_dynamixel_debug', # startup on import -] - -INCOMPATIBLE_PACKAGES = [ - 'humanoid_league_interactive_marker', # doesnt work properly TODO fix - 'humanoid_league_rviz_marker', # not currently python2 compatible - 'udp_bridge', # not currently python2 compatible - 'bitbots_imageloader', # not currently python2 compatible - 'bitbots_vision', # problems with VisionExtensions and numpy imports - 'bitbots_ros_control', # some \ref commands dont resolve -] - - -class Colors: - BLACK = "\033[0;30m" - RED = "\033[0;31m" - GREEN = "\033[0;32m" - ORANGE = "\033[0;33m" - BLUE = "\033[0;34m" - PURPLE = "\033[0;35m" - CYAN = "\033[0;36m" - LIGHT_GRAY = "\033[0;37m" - DARK_GRAY = "\033[1;30m" - LIGHT_RED = "\033[1;31m" - LIGHT_GREEN = "\033[1;32m" - YELLOW = "\033[1;33m" - LIGHT_BLUE = "\033[1;34m" - LIGHT_PURPLE = "\033[1;35m" - LIGHT_CYAN = "\033[1;36m" - WHITE = "\033[1;37m" - NO_COLOR = "\033[0m" - - -def log_error(message): - print("{}[!]{} {}".format(Colors.RED, Colors.NO_COLOR, message.replace("\n", "\n ")), - file=sys.stderr) - - -def log_info(message): - print("{}[i]{} {}".format(Colors.BLUE, Colors.NO_COLOR, message.replace("\n", "\n "))) - - -def log_warn(message): - print("{}[w]{} {}".format(Colors.YELLOW, Colors.NO_COLOR, message.replace("\n", "\n "))) - - -def parse_args(): - parser = argparse.ArgumentParser( - description='A utility script to build and merge bitbots documentation' - ) - - mode = parser.add_mutually_exclusive_group() - mode.add_argument('-m', '--meta', - action='store_const', const=True, default=False, - help='Build manual documentation from bitbots_meta only' - ) - mode.add_argument('-p', '--package', - help='Build documentation for single package only') - mode.add_argument('-i', '--internal', - action='store_const', const=True, default=False, - help='Build internal documentation from "doc_internal" only') - - parser.add_argument('-v', - action='count', dest='verbosity', default=0, - help='Be more verbose. Can be given multiple times') - parser.add_argument('-e', '--exclude', - action='append', dest='excludes', default=EXCLUDED_PACKAGES, - help='Exclude a package from documentation generation generation') - - return parser.parse_args() - - -def handle_process_output(args, process): - if process.returncode != 0: - log_error("Error calling {}".format(process.args[0])) - if process.stderr: - print(process.stderr) - if args.verbosity >= 1 and process.stdout: - print(process.stdout) - - else: - if args.verbosity >= 1: - if process.stderr: - print(process.stderr) - if args.verbosity >= 2 and process.stdout: - print(process.stdout) - else: - if process.stderr: - log_warn("{} printed to stderr. Supply -v to see".format(process.args[0])) - - -def filter_packages_for_bitbots(rospack, args): - return [pkg_name - for pkg_name in rospack.list() - if "bitbots" in rospack.get_path(pkg_name) - and os.path.join("bitbots_meta", "lib") not in rospack.get_path(pkg_name) - and pkg_name not in args.excludes - ] - - -def build_package_doc(rospack, pkg_name, args): - if not pkg_name in rospack.list(): - log_error("Package {} is not in $ROS_PACKAGE_PATH".format(pkg_name)) - return - - log_info("Building documentation for package {}".format(pkg_name)) - if pkg_name in INCOMPATIBLE_PACKAGES: - log_warn( - "{} is marked as not fully compatible\n" - "Sphinx will throw errors when it tries to import this package and code documentation will be incomplete" - .format(pkg_name)) - - if os.path.isdir(os.path.join(rospack.get_path(pkg_name), "src")): - log_info("Indexing source code") - p = subprocess.run([ - "sphinx-apidoc", "-f", - "-o", os.path.join("doc", "_generated"), - "--ext-autodoc", - "--ext-doctest", - "--ext-intersphinx", - "--ext-todo", - "--ext-coverage", - "--ext-mathjax", - "--ext-viewcode", - "src" - ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.DEVNULL, - cwd=rospack.get_path(pkg_name), - encoding="ASCII") - handle_process_output(args, p) - - log_info("Building html to {}" - .format(os.path.join(os.path.basename(rospack.get_path(pkg_name)), "doc", "_build", "html", "index.html"))) - - p = subprocess.run([ - "rosdoc_lite", "./", - "-o", os.path.join("doc", "_build") - ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.DEVNULL, - cwd=rospack.get_path(pkg_name), - encoding='ASCII') - handle_process_output(args, p) - - -def build_meta_doc(args): - log_info("Building bitbots_meta documentation") - doc_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "doc") - - p = subprocess.run(["sphinx-build", doc_dir, os.path.join(doc_dir, "_build")], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='ASCII') - - handle_process_output(args, p) - - -def build_internal_doc(args): - doc_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "doc_internal") - log_info("Building internal documentation to {}".format(os.path.join(doc_dir, '_build', 'index.html'))) - - if not os.path.isdir(doc_dir): - log_error('Path {} not found or not a directory\nInternal documentation should be located here'.format(doc_dir)) - return - - p = subprocess.run(["sphinx-build", doc_dir, os.path.join(doc_dir, "_build")], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="ASCII") - handle_process_output(args, p) - - -if __name__ == '__main__': - args = parse_args() - build_all = not args.meta and not args.package and not args.internal - - log_info("Indexing packages") - ros_package_path = os.getenv("ROS_PACKAGE_PATH", "") - if ":" in ros_package_path: - ros_package_path = ros_package_path.split(":") - else: - ros_package_path = [ros_package_path] - rospack = RosPack(ros_package_path) - - if build_all: - for pkg_name in filter_packages_for_bitbots(rospack, args): - print() - build_package_doc(rospack, pkg_name, args) - - if args.package: - if args.package not in filter_packages_for_bitbots(rospack, args): - log_error("The package {} is not a bitbots package or excluded".format(args.package)) - exit(1) - - print() - build_package_doc(rospack, args.package, args) - - if build_all or args.meta: - print() - build_meta_doc(args) - - if build_all or args.internal: - print() - build_internal_doc(args) diff --git a/scripts/catkin-to-ament.py b/scripts/catkin-to-ament.py deleted file mode 100644 index d8938cd56..000000000 --- a/scripts/catkin-to-ament.py +++ /dev/null @@ -1,954 +0,0 @@ -#!/usr/bin/env python -'''This script automates many of the tasks necessary to port a ROS (1) -catkin package to a ROS 2 ament package. -Modified from https://github.com/bponsler/ros2-support - -''' -import os -import re -import argparse -import tempfile -from os.path import exists -from xml.dom import minidom -import xml.etree.ElementTree as etree -from pathlib import Path - -# Load a module for parsing cmake lists content -try: - import parse_cmake.parsing as cmkp -except ImportError: - import traceback - - traceback.print_exc() - print("ERROR: You must install the parse_cmake python module!") - print("") - print(" sudo pip install parse_cmake") - exit(1) - -# Names of package files to modify -PACKAGE_XML = "package.xml" -CMAKELISTS = "CMakeLists.txt" - -# List of ROS packages that do not currently exist in ROS 2 -UNKNOWN_ROS_PACKAGES = [ - "dynamic_reconfigure", - "roslib", - "rosconsole" -] - -# List of ROS packages that have been renamed in ROS 2 -RENAMED_ROS_PACKAGES = { - "tf": "tf2", - "roscpp": "rclcpp", - "rospy": "rclpy", - "nodelet": "rclcpp", # nodelets have become components in ROS 2 - "message_generation": "rosidl_default_generators", - "message_runtime": "rosidl_default_runtime", -} - -# List of packages that do not need to be found by CMake -NO_CMAKE_FIND_PACKAGES = [ - "rosidl_default_runtime", -] - -MESSAGES = { - "JointState", - "Odometry", - "Char", - "Imu", - "SupportState", - "TransformStamped", - "Transform", - "Twist", - "Pose", - "PoseArray", - "PointStamped", - "Marker", - "String", - "Float64", - "Bool", - "RobotState", - "JointCommand", - "FootPressure", - "Point", - "PoseStamped", - "Quaternion", - "Vector3", - "RobotControlState", - "PoseWithCertainty", - "PoseWithCertaintyArray" -} - -RENAME_PACKAGE_IMPORTS = { - "ros/ros.h": "rclcpp/rclcpp.hpp" -} - -REMOVE_IMPORTS = [ - "ros/console.h" -] - -HARDCODED_REPLACEMENTS = { - "#include ": "#include ", - "ros::Time::now()": "this->get_clock()->now()", - "now().toSec()": "now().seconds()", - "ros::Time": "rclcpp::Time", - r"ros::Duration\(": "rclcpp::Duration::from_nanoseconds(1e9*", # is now nanoseconds - "ros::Duration": "rclcpp::Duration", - "ros::WallTime": "rclcpp::WallTime", - "ros::Rate": "rclcpp::Rate", - "ros::init": "rclcpp::init", - r"ros::NodeHandle .*": "", - r"ROS_WARN\(": "RCLCPP_WARN(this->get_logger(),", - r"ROS_FATAL\(": "RCLCPP_FATAL(this->get_logger(),", - r"ROS_INFO\(": "RCLCPP_INFO(this->get_logger(),", - r"ROS_ERROR\(": "RCLCPP_ERROR(this->get_logger(),", - r"ROS_WARN_THROTTLE\(": "RCLCPP_WARN_THROTTLE(this->get_logger(), *this->get_clock(), ", - r"ROS_INFO_THROTTLE\(": "RCLCPP_INFO_THROTTLE(this->get_logger(), *this->get_clock(), ", - r"ROS_ERROR_THROTTLE\(": "RCLCPP_ERROR_THROTTLE(this->get_logger(), *this->get_clock(), ", - r"ROS_WARN_ONCE\(": "RCLCPP_WARN_ONCE(this->get_logger(),", - r"ROS_INFO_ONCE\(": "RCLCPP_INFO_ONCE(this->get_logger(),", - r"ROS_ERROR_ONCE\(": "RCLCPP_ERROR_ONCE(this->get_logger(),", - r"ros::spinOnce\(\)": "rclcpp::spin_some(this->get_node_base_interface())", - r"ros::ok\(\)": "rclcpp::ok()", - "tf2_ros::Buffer": "std::unique_ptr", - "tf2_ros::TransformBroadcaster": "std::unique_ptr", - "tf2_ros::TransformListener": "std::shared_ptr", - "#include ": "", - "#include ": "#include ", - "robot_state::": "moveit::core::", - ".getNumSubscribers": "->get_subscription_count", - "\.publish": "->publish", - "\.sendTransform": "->send_transform", - "\.lookupTransform": "->lookup_transform", - "robot_state::msg::RobotStatePtr": "moveit::core::RobotStatePtr", - "tf2_eigen/tf2_eigen.h": "tf2_eigen/tf2_eigen.hpp", - "tf2_geometry_msgs/tf2_geometry_msgs.h": "tf2_geometry_msgs/tf2_geometry_msgs.hpp", - "ConstPtr": "SharedPtr" -} - - -def source_code_replacement(): - files = list(Path(".").rglob(r"*")) - cpp_files = [] - for file in files: - if not "CMake" in file.name and (".cpp" in file.name or ".h" in file.name or ".hpp" in file.name): - cpp_files.append(file) - for filename in cpp_files: - # replace the regex with the replacement in the given file - with open(filename, "r+") as f: - content = f.read() - # rename packages that we want to import - for find, replace in RENAME_PACKAGE_IMPORTS.items(): - content = re.sub(find, replace, content) - # rename message imports, since they have an extra "/msg" and are .hpp files - for message in MESSAGES: - message_snake_case = re.sub(r'(?", "msg/" + message_snake_case + ".hpp>", content) - # usage with lookbehind to make sure we don't induce multiple times the ::msg:: part when - # calling the script multiple times - content = re.sub("(?", "", content) - - for find, replace in HARDCODED_REPLACEMENTS.items(): - content = re.sub(find, replace, content) - - # replace publisher - content = re.sub(r"ros::Publisher (.*) = n.advertise<(.*)>\((.*)\)", - r"rclcpp::Publisher<\2>::SharedPtr \1 = this->create_publisher<\2>(\3)", content) - # in header - content = re.sub("ros::Publisher", "rclcpp::Publisher", content) - - # replace subscriber - content = re.sub(r"ros::Subscriber (.*) = n.subscribe\((.*),(.*)\&(.*),.*\)", - r"rclcpp::Subscription::SharedPtr \1 = this->create_subscription(\2, \3 std::bind(&\4, this, _1))", - content) - # different form to write a subscriber - content = re.sub(r"ros::Subscriber (.*) = n.subscribe<(.*)>\((.*),(w*)(.+)\)", - r"rclcpp::Subscription<\2>::SharedPtr \1 = this->create_subscription<\2>(\3, \4, std::bind(\5, this, _1))", - content) - # in header - content = re.sub("ros::Subscriber", "rclcpp::Subscription", content) - - # replace parameter - content = re.sub(r"(.*).param<(.*)>\((.*),(.*),(.*)\);", - r"this->declare_parameter<\2>(\3, \5);" + "\n" + r"this->get_parameter(\3, \4);", content) - - f.seek(0) - f.write(content) - - # hack to make sure that there is nothing else left - # f.write("\n"*10) - - -def param_replacement(): - files = list(Path(".").rglob(r"*")) - cfg_files = [] - for file in files: - if ".cfg" in file.name: - cfg_files.append(file) - for filename in cfg_files: - # replace the regex with the replacement in the given file - with open(filename, "r+") as f: - content = f.read() - # create correct lines for c++ out of parameter config file - content = re.sub(r'.*.add\("(.*)", (.*), .* .*"(.*)".*.*min=([-, \d, \.]*), max=([-, \d, \.]*)\)', - r'// \3 range: [\4,\5]\n\2 param_\1_;\nthis->declare_parameter<\2>("\1", 0);\n} else if (parameter.get_name() == "\1") {\n param_\1_ = parameter.as_\2();\nself.declare_parameter("\1", 0.0)\nself.get_parameter("\1").get_parameter_value().\2_value\nif param.name == \1:\n self.\1=\1', - content) - - # rename some parameter types so that they fit - content = re.sub("double_t", "double", content) - content = re.sub("int_t", "int", content) - - # TODO sortieren und rest weg werfen - - header_lines = [] - code_lines = [] - reconf_lines = [] - python_lines = [] - python_update_lines = [] - for line in iter(content.splitlines()): - if "load_manifest" in line: - continue - elif "//" in line: - header_lines.append(line) - elif "this->declare_parameter" in line: - code_lines.append(line) - elif "declare_parameter" in line or "get_parameter" in line: - python_lines.append(line) - elif "if (" in line or "as_" in line: - reconf_lines.append(line) - elif ";" in line: - header_lines.append(line) - elif not "PACKAGE" in line and not "ParameterGenerator" in line and not "python3" in line and not "import" in line: - python_update_lines.append(line) - - print(f"###\n FROM FILE {filename}\n###") - print(f"### DECLARATION OF PARAMETER VARIABLES (put in header file) ###") - for line in header_lines: - print(line) - print("\n\n") - print(f"### DECLARATION OF PARAMETERS ON SERVER (put in constructor) ###") - for line in code_lines: - print(line) - print("\n\n") - print(f"### UPDATING PARAMETERS FOR CALLBACK (put in callback) ###") - for line in reconf_lines: - print(line) - print("\n\n") - - print(f"### DECLARATION OF PARAMETERS IN INIT (put in INIT) PYTHON###") - for line in python_lines: - print(line) - print("\n\n") - - print(f"### UPDATING PARAMETERS FOR CALLBACK (put in callback) PYTHON###") - for line in python_update_lines: - print(line) - - -def launch_replacement(): - files = list(Path(".").rglob(r"*")) - launch_files = [] - for file in files: - if ".launch" in file.name: - launch_files.append(file) - for filename in launch_files: - # replace the regex with the replacement in the given file - with open(filename, "r+") as f: - content = f.read() - - content = re.sub("type=", "exec=", content) - content = re.sub("optenv", "env", content) - content = re.sub("doc", "description", content) - content = re.sub("\$\(find", "$(find-pkg-share", content) - content = re.sub("\$\(arg", "$(var", content) - content = re.sub("rosparam file", "param from", content) - - f.seek(0) - f.write(content) - - -def cmake_replacement(): - files = list(Path(".").rglob(r"*")) - launch_files = [] - for file in files: - if "CMakeLists.txt" in file.name: - launch_files.append(file) - for filename in launch_files: - # replace the regex with the replacement in the given file - with open(filename, "r+") as f: - content = f.read() - - content = re.sub("enable_bitbots_docs\(\)", - "include(${CMAKE_BINARY_DIR}/../bitbots_docs/enable_bitbots_docs.cmake)\nenable_bitbots_docs()", - content) - content = re.sub(r"generate_dynamic_reconfigure_options\((.*)\)", "", content) - - content = re.sub(r"ament_package\(\)", - "install(DIRECTORY config DESTINATION share/${PROJECT_NAME})\ninstall(DIRECTORY launch DESTINATION share/${PROJECT_NAME})\ninstall(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})\n\nament_package()", - content) - - f.seek(0) - f.write(content) - - -python_replacements = { - "import rospy": "import rclpy\nfrom rclpy.node import Node", - "rospy.Rate": "self.create_rate", - "not rospy.is_shutdown\(\)": "rclpy.ok()", - "rospy.is_shutdown\(\)": "not rclpy.ok()", - "rospy.Time.now\(\)": "self.get_clock().now()", - "stamp = self.get_clock().now()": "stamp = self.get_clock().now().to_msg()", - "rospy.spin\(\)": "rclpy.spin(self)", - "rospy.logwarn\(": "self.get_logger().warn(", - "rospy.loginfo\(": "self.get_logger().info(", - "rospy.logerr\(": "self.get_logger().error(", - "rospy.logdebug\(": "self.get_logger().debug(", - "rospy.logwarn_once\((.*)\)": r"self.get_logger().warn(\1, once=True)", - "rospy.loginfo_once\((.*)\)": r"self.get_logger().info(\1, once=True)", - "rospy.logerr_once\((.*)\)": r"self.get_logger().error(\1, once=True)", - "rospy.logdebug_once\((.*)\)": r"self.get_logger().debug(\1, once=True)", - "rospy.logwarn_throttle\((.*), (.*)\)": r"self.get_logger().warn(\2, throttle_duration_sec=\1", - "rospy.loginfo_throttle\((.*), (.*)\)": r"self.get_logger().info(\2, throttle_duration_sec=\1", - "rospy.logerr_throttle\((.*), (.*)\)": r"self.get_logger().error(\2, throttle_duration_sec=\1", - "rospy.logdebug_throttle\((.*), (.*)\)": r"self.get_logger().debug(\2, throttle_duration_sec=\1", - "import actionlib": "from rclpy.action import ActionClient", - ".send_goal\(": ".send_goal_async(", - "rospy.Duration\(": "Duration(seconds=", - "rospy.sleep\(": "self.get_clock().sleep_for(Duration(seconds=", - "from tf.transformations": "from tf_transformations", - "rospy.get_time\(\)": "float(self.get_clock().now().seconds_nanoseconds()[0] + self.get_clock().now().seconds_nanoseconds()[1]/1e9)", - r"from (.*)cfg import": "", - "from dynamic_reconfigure.server import Server": "", - "rospy.get_name\(\)": "self.get_name()", - "get_num_connections\(\)": "get_subscription_count()" -} - - -def python_replacement(): - files = list(Path(".").rglob(r"*")) - launch_files = [] - for file in files: - if ".py" in file.name and not ".pyc" in file.name: - launch_files.append(file) - for filename in launch_files: - # replace the regex with the replacement in the given file - with open(filename, "r+") as f: - content = f.read() - - for find, replace in python_replacements.items(): - content = re.sub(find, replace, content) - content = re.sub("rospy.init_node\(.*\)", "rclpy.init(args=None)", content) - content = re.sub("rospy.Publisher\((.*), (.*), queue_size=(.*)\)", r"self.create_publisher(\2, \1, \3)", - content) - content = re.sub("rospy.Publisher\((.*), (.*), queue_size=(.*), tcp_nodelay = True\)", - r"self.create_publisher(\2, \1, \3)", content) - content = re.sub("rospy.Subscriber\((.*), (.*), (.*), queue_size=(.*), tcp_nodelay=True\)", - r"self.create_subscription(\2, \1, \3, \4)", content) - content = re.sub("rospy.ServiceProxy\((.*), (.*)\)", r"self.create_client(\2, \1)", content) - content = re.sub("actionlib.SimpleActionClient\((.*), (.*)\)", r"ActionClient(self, \2, \1)", content) - content = re.sub("rospy.Time.from_sec\((.*)\)", r"Time(seconds=int(\1), nanoseconds=\1 % 1 * 1e9)", - content) - content = re.sub("rospy.get_param\((.*), (.*)\)", - r"self.get_parameter('\1').get_parameter_value().double_value", content) - content = re.sub("rospy.set_param\((.*), (.*)\)", - r"self.set_parameters([rclpy.parameter.Parameter(\1, rclpy.Parameter.Type.DOUBLE, \2)])", - content) - content = re.sub("rospy.Service\((.*), (.*), (.*)\)", r"self.create_client(\2, \1, \3)", content) - f.seek(0) - f.write(content) - - -def executeSedCmd(pattern, filename, dryrun=False): - # Choose flags based on whether the file should be modified or not - sedFlags = "" if dryrun else "-i" - - cmd = "sed %s '%s' %s" % (sedFlags, pattern, filename) - return os.system(cmd) == 0 - - -class PackageXmlPorter: - @classmethod - def port(cls, dryrun=False): - # Make sure the file exists (even though this is already checked) - if not exists(PACKAGE_XML): - print("ERROR: Unable to locate the package XML: %s" % PACKAGE_XML) - return False - - # Parse the package XML - tree = etree.parse(PACKAGE_XML) - packageRoot = tree.getroot() - - # ROS 2 only supports package XML format version 2 - packageRoot.set("format", "2") - - # Make sure there's a final newline - packageRoot.tail = "\n" - - # List of package root element indices to remove - removeElements = [] - - # TODO: need to handle the different semantics of tags between format 1 and 2 - # see: http://www.ros.org/reps/rep-0140.html - - generatesMessages = False - foundExport = False - foundBuildTool = False - for child in packageRoot.getchildren(): - # Handle specific elements - if child.tag == "build_depend": - # Message generation no longer exists - if child.text == "message_generation": - generatesMessages = True - removeElements.append(child) - elif child.tag == "run_depend": - # The run_depend tag has changed to exec_depend in format 2 - child.tag = "exec_depend" - - # Remove message generation - if child.text == "message_generation": - generatesMessages = True - removeElements.append(child) - elif child.tag == "buildtool_depend": - # Update the package to use ament instead of catkin - if child.text == "catkin": - child.text = "ament_cmake" - foundBuildTool = True - elif child.tag == "export": - foundExport = True - - # Found an export, check children for build type - foundBuildType = False - for export in child.getchildren(): - # The build type needs to be specified for ament packages - if export.tag == "build_type": - export.text = "ament_cmake" - foundBuildType = True - - # If the build type element was not found, then we must - # add one to specify that this package used ament - if not foundBuildType: - buildTypeElement = etree.Element("build_type") - buildTypeElement.text = "ament_cmake" - buildTypeElement.tail = "\n " # Spacing for export close - - # Add spacing for open of the build type element - if len(child.getchildren()) > 0: - lastExport = child.getchildren()[-1] - lastExport.tail = "\n " # Spacing to open of build type - else: - child.tail = "\n " # Spacing to build type element - - child.append(buildTypeElement) - - # Remove all desired elements - for element in removeElements: - packageRoot.remove(element) - - # If this package generates messages, then certain dependencies - # need to be added to the package - if generatesMessages: - # TODO: only add this when Duration or Time are used within the messages/services - # buildToolElement = etree.Element("depend") - # buildToolElement.text = "builtin_interfaces" - # buildToolElement.tail = "\n " # Spacing to next element - - buildToolElement = etree.Element("buildtool_depend") - buildToolElement.text = "rosidl_default_generators" - buildToolElement.tail = "\n " # Spacing to next element - - execDependElement = etree.Element("exec_depend") - execDependElement.text = "rosidl_default_runtime" - execDependElement.tail = "\n " # Spacing to next element - - # Add spacing before the open of the build tool depend element - lastChild = packageRoot.getchildren()[-1] - lastChild.tail = "\n\n " # Spacing for open build tool depend - - packageRoot.append(buildToolElement) - packageRoot.append(execDependElement) - - # If the build tool was not specified, add it (it should - # always be specified, but just in case) - if not foundBuildTool: - buildToolElement = etree.Element("buildtool_depend") - buildToolElement.text = "ament_cmake" - buildToolElement.tail = "\n" # Spacing to next element - - # Add spacing before the open of the build tool depend element - lastChild = packageRoot.getchildren()[-1] - lastChild.tail = "\n\n " # Spacing for open build tool depend - - packageRoot.append(buildToolElement) - - # If the export element was not found, we must create one to - # specify that this package used ament - if not foundExport: - # Create the build type element - buildTypeElement = etree.Element("build_type") - buildTypeElement.text = "ament_cmake" - buildTypeElement.tail = "\n " # Spacing for export close - - # Create the wrapping export element - exportElement = etree.Element("export") - exportElement.text = "\n " # Spacing for open build type - exportElement.tail = "\n" # Spacing for package close - exportElement.append(buildTypeElement) - - # Add spacing before the open of the export element - lastChild = packageRoot.getchildren()[-1] - lastChild.tail = "\n\n " # Spacing for open export - - packageRoot.append(exportElement) - - if not dryrun: - # Write the content to the file - tree.write(PACKAGE_XML, encoding='utf-8', xml_declaration=True) - else: - # Write the XML to a temporary file - fid, tempFilename = tempfile.mkstemp("_catkin_to_ament") - os.close(fid) - tree.write(tempFilename, encoding='utf-8', xml_declaration=True) - - # Read the temporary file - fid = open(tempFilename, 'r') - content = fid.read().strip() - fid.close() - - # Delete the temporary file, now that we're done with it - os.remove(tempFilename) - - # Print the content - print(content) - - return True # Success - - -class CmakeListsPorter: - @classmethod - def port(cls, dryrun=False): - # Make sure the file exists (even though this is already checked) - if not exists(CMAKELISTS): - print("ERROR: Unable to locate CMakeLists.txt") - return False - - # Read the file content - fid = open(CMAKELISTS, "r") - content = fid.read() - fid.close() - - # Parse the cmake content - cmake = cmkp.parse(content) - - # Item indices to remove from the file - removeIndices = [] - - # List of catkin packages this package depends on - catkinDepends = [] - - # Libraries created by this package - packageLibs = [] - - # Message and service files to generate - msgsAndSrvs = [] - - projectDeclIndex = -1 - hasCpp11 = False - for index, item in enumerate(cmake): - # Skip non commmand items - if type(item) != type(cmkp.Command("a", "b")): - continue - - # Grab names of all arguments to this command - args = [b.contents for b in item.body] - - if item.name == "cmake_minimum_required": - # Make sure to use at least cmake 3.5 - if len(args) == 2 and args[0] == "VERSION": - item.body[1] = cmkp.Arg("3.5") - elif item.name == "project": - projectDeclIndex = index - elif item.name == "add_definitions": - # Handle C++11 support added through definitions - if "-std=c++11" in args: - hasCpp11 = True - elif item.name == "set": - # Handle C++11 support specifically set to CXX flags - if "CMAKE_CXX_FLAGS" in args: - for arg in args: - if "-std=c++11" in arg: - hasCpp11 = True - break - elif item.name == "find_package": - if len(args) > 0 and "catkin" == args[0]: - removeIndices.append(index) - - # An example of command is: - # find_package(catkin REQUIRED COMPONENTS pkg1 pkg2) - if "COMPONENTS" in args: - componentsStart = args.index("COMPONENTS") - catkinDepends = args[componentsStart + 1:] - - generatesMessages = ("message_generation" in args) - - # Remove packages that no longer exist in ROS 2 - catkinDepends = list(filter( - lambda p: p not in UNKNOWN_ROS_PACKAGES, - catkinDepends)) - - # Handle packages that have been renamed in ROS 2 - catkinDepends = list(map( - lambda p: RENAMED_ROS_PACKAGES.get(p, p), - catkinDepends)) - - # Add additional packages needed for message generation - if generatesMessages: - catkinDepends.extend([ - "rosidl_default_generators", - "rosidl_default_runtime", - ]) - elif item.name == "catkin_package": - # Remove the catkin_packge element - removeIndices.append(index) - elif item.name == "include_directories": - # Remove the include directories, which will be added later - removeIndices.append(index) - elif item.name == "link_directories": - # Remove the link directories, which will be added later - removeIndices.append(index) - elif item.name == "catkin_destinations": - # Remove this command as it no longer exists - removeIndices.append(index) - elif item.name == "catkin_metapackage": - # Remove this command as it no longer exists - removeIndices.append(index) - elif item.name == "catkin_python_setup": - # Remove this command as it no longer exists - removeIndices.append(index) - elif item.name == "add_dependencies": - # The catkin exported targets variable no longer exists, - # so remove this - if "${catkin_EXPORTED_TARGETS}" in args: - removeIndices.append(index) - elif item.name == "target_link_libraries": - # Replace the reference to catkin libraries (which no longer - # exists) with a reference to libraries variable - if "${catkin_LIBRARIES}" in args: - catkinIndex = args.index("${catkin_LIBRARIES}") - item.body[catkinIndex] = cmkp.Arg("${LIBS}") - elif item.name == "add_library": - # Keep track of the names of all libraries created - # by this package - if len(args) > 0: - packageLibs.append(args[0]) - elif item.name == "add_message_files": - if len(args) > 1: - msgFiles = list(map( - lambda s: "msg/%s" % s, args[1:])) - msgsAndSrvs.extend(msgFiles) - - # Remove this command as it has been replaced - removeIndices.append(index) - elif item.name == "add_service_files": - if len(args) > 1: - serviceFiles = list(map( - lambda s: "srv/%s" % s, args[1:])) - msgsAndSrvs.extend(serviceFiles) - - # Remove this command as it has been replaced - removeIndices.append(index) - elif item.name == "generate_messages": - # Remove this command as it has been replaced - removeIndices.append(index) - elif item.name == "if": - # Replace if(CATKIN_ENABLE_TESTING) with if(BUILD_TESTING) - if len(args) == 1 and args[0] == "CATKIN_ENABLE_TESTING": - item.body[0] = cmkp.Arg("BUILD_TESTING") - elif item.name == "catkin_add_gtest": - # Replace catkin_add_gtest with ament_add_gtest - cmake[index] = cmkp.Command("ament_add_gtest", item.body) - elif item.name == "catkin_add_nosetests": - # Replace catkin_add_nosetests with ament_add_nose_test, add - # an additional arg which is the name of the test. Add a unique - # name that can be changed as desired later - body = [cmkp.Arg("${PROJECT_NAME}_nose_test_%s" % index)] + item.body - cmake[index] = cmkp.Command("ament_add_nose_test", body) - - # Should never happen, but just in case... - if projectDeclIndex == -1: - print("ERROR: Failed to locate project declaration!") - return False - - # Remove all indices in reverse sorted order to prevent the - # indices from changing values - for index in sorted(removeIndices, reverse=True): - del cmake[index] - - # Make sure C++11 support is added - if not hasCpp11: - comment = cmkp.Comment("# Add support for C++17") - - openIf = cmkp.Command("if", [cmkp.Arg("NOT"), cmkp.Arg("CMAKE_CXX_STANDARD")]) - - addDef = cmkp.Command( - "set", [cmkp.Arg("CMAKE_CXX_STANDARD"), cmkp.Arg("17")]) - - closeIf = cmkp.Command("endif", []) - - # Add all the items - items = [ - cmkp.BlankLine(), - comment, - openIf, - addDef, - closeIf, - cmkp.BlankLine(), - ] - for item in items: - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, item) - - ## Add all find_package calls - - # Must find the ament_cmake package - catkinDepends.insert(0, "ament_cmake") - - # Remove duplicate entries - catkinDepends = list(set(catkinDepends)) - - # Remove packages that don't need to be found by CMake - for pkg in NO_CMAKE_FIND_PACKAGES: - if pkg in catkinDepends: - catkinDepends.remove(pkg) - - # Add calls to find all other dependency packages - for pkg in catkinDepends: - findPkg = cls.__findPackage(pkg) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, findPkg) - - # Add a blank line - projectDeclIndex = cls.__addBlankLine(cmake, projectDeclIndex) - - ## Handle message generation - if len(msgsAndSrvs) > 0: - # rosidl_generate_interfaces(urg_node_msgs - # "msg/Status.msg" - # DEPENDENCIES builtin_interfaces std_msgs - # ) - cmdArgs = [cmkp.Arg("${PROJECT_NAME}")] - for filename in msgsAndSrvs: - cmdArgs.append(cmkp.Arg('"%s"' % filename)) - - # Add dependencies on message packages - cmdArgs.extend([ - cmkp.Arg("DEPENDENCIES"), - cmkp.Arg("builtin_interfaces"), - ]) - for pkg in catkinDepends: - if pkg.endswith("_msgs") or pkg.endswith("srvs"): - cmdArgs.append(cmkp.Arg(pkg)) - - genIfaceCmd = cmkp.Command("rosidl_generate_interfaces", cmdArgs) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, genIfaceCmd) - - # Add a blank line - projectDeclIndex = cls.__addBlankLine(cmake, projectDeclIndex) - - ## Define variables for all include dirs and libraries - includeArgs = [cmkp.Arg("INCLUDE_DIRS")] - libArgs = [cmkp.Arg("LIBS")] - libDirArgs = [cmkp.Arg("LIBRARY_DIRS")] - for pkg in catkinDepends: - includeArgs.append(cmkp.Arg("${%s_INCLUDE_DIRS}" % pkg)) - libArgs.append(cmkp.Arg("${%s_LIBRARIES}" % pkg)) - libDirArgs.append(cmkp.Arg("${%s_LIBRARY_DIRS}" % pkg)) - - # If an include directory exists for this package, add it to - # the include dirs - if exists("include"): - includeArgs.insert(1, cmkp.Arg("include")) - - # Add command to set include dirs - setIncludeDirs = cmkp.Command("set", includeArgs) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, setIncludeDirs) - - ## Add the include_directories command - includeDirs = cmkp.Command( - "include_directories", [cmkp.Arg("${INCLUDE_DIRS}")]) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, includeDirs) - projectDeclIndex = cls.__addBlankLine(cmake, projectDeclIndex) - - # Add command to set lib dirs - setLibDirs = cmkp.Command("set", libDirArgs) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, setLibDirs) - projectDeclIndex = cls.__addBlankLine(cmake, projectDeclIndex) - - ## Add the link_directories command - linkDirs = cmkp.Command( - "link_directories", [cmkp.Arg("${LIBRARY_DIRS}")]) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, linkDirs) - projectDeclIndex = cls.__addBlankLine(cmake, projectDeclIndex) - - # Add command to set libs - setLibs = cmkp.Command("set", libArgs) - projectDeclIndex += 1 - cmake.insert(projectDeclIndex, setLibs) - projectDeclIndex = cls.__addBlankLine(cmake, projectDeclIndex) - - ## Export all ament dependencies at the bottom of the file - cmake.append(cmkp.BlankLine()) - for pkg in catkinDepends: - export = cmkp.Command("ament_export_dependencies", [cmkp.Arg(pkg)]) - cmake.append(export) - - ## Export include directories - exportIncludes = cmkp.Command( - "ament_export_include_directories", - [cmkp.Arg("${INCLUDE_DIRS}")]) - cmake.append(exportIncludes) - - ## Export all known libraries - if len(packageLibs) > 0: - exportLibs = cmkp.Command( - "ament_export_libraries", - [cmkp.Arg(lib) for lib in packageLibs]) - - # Include all dependency libraries - exportLibs.body.append(cmkp.Arg("${LIBS}")) - cmake.append(exportLibs) - - # Add the final call to initialize the ament package - # (this must be at the bottom of the file!) - projectDeclIndex = cmake.append(cmkp.BlankLine()) - amentPackageCmd = cmkp.Command("ament_package", []) - cmake.append(amentPackageCmd) - - # Remove any double blank lines - index = 0 - while index < (len(cmake) - 1): - isBlank = lambda i: (type(i) == type(cmkp.BlankLine())) - item = cmake[index] - nextItem = cmake[index + 1] - - if isBlank(item) and isBlank(nextItem): - del cmake[index] - continue # Repeat this index - - index += 1 - - # Convert the CMakeLists content into a nicely formatted string - cmakeData = '\n'.join(cmkp.compose_lines( - cmake, cmkp.FormattingOptions())) + '\n' - - # Replace all instances of variables that no longer exist - renamedVariables = { - "${CATKIN_DEVEL_PREFIX}/": "", - "${CATKIN_GLOBAL_BIN_DESTINATION}": "bin", - "${CATKIN_GLOBAL_INCLUDE_DESTINATION}": "include", - "${CATKIN_GLOBAL_LIB_DESTINATION}": "lib", - "${CATKIN_GLOBAL_LIBEXEC_DESTINATION}": "lib", - "${CATKIN_GLOBAL_SHARE_DESTINATION}": "share", - "${CATKIN_PACKAGE_BIN_DESTINATION}": "lib/${PROJECT_NAME}", - "${CATKIN_PACKAGE_INCLUDE_DESTINATION}": "include/${PROJECT_NAME}", - "${CATKIN_PACKAGE_LIB_DESTINATION}": "lib", - "${CATKIN_PACKAGE_SHARE_DESTINATION}": "share/${PROJECT_NAME}", - } - for var, replacement in renamedVariables.items(): - cmakeData = cmakeData.replace(var, replacement) - - if not dryrun: - fid = open(CMAKELISTS, "w") - fid.write("%s\n" % cmakeData.strip()) - fid.close() - else: - print(cmakeData) - - return True # Success - - @classmethod - def __findPackage(cls, pkgName): - '''Create a command to find a specific package. - - * pkgName - the name of the package - - ''' - return cmkp.Command( - "find_package", - [cmkp.Arg(pkgName), cmkp.Arg("REQUIRED")]) - - @classmethod - def __addBlankLine(cls, cmake, index): - index += 1 - cmake.insert(index, cmkp.BlankLine()) - return index - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="Port a ROS (1) catkin package to a ROS 2 ament package") - parser.add_argument( - "--dryrun", - action="store_true", - help='do not make any changes to any files') - parser.add_argument( - "--only-source", - action="store_true", - help='only modify the source files') - parser.add_argument( - "--only-params", - action="store_true", - help='only modify the dynamic parameters') - parser.add_argument( - "--only-launch", - action="store_true", - help='only modify the launch files') - parser.add_argument( - "--only-python", - action="store_true", - help='only modify the python files') - args = parser.parse_args() - - # Quick check to make sure this script was run from within - # a ROS catkin package - if (not exists(PACKAGE_XML) or not exists(CMAKELISTS)) and not args.only_python: - print( - "ERROR: you must run this script from within a ROS " + - "catkin package directory!") - exit(1) - - if args.dryrun: - print("Performing a dryrun...") - - if not args.only_source and not args.only_params and not args.only_launch and not args.only_python: - # Port the package XML - if not PackageXmlPorter.port(args.dryrun): - print("ERROR: Failed to port package XML") - exit(2) - - # Port the CMakeLists file - if not CmakeListsPorter.port(args.dryrun): - print("ERROR: Failed to port CMakeLists.txt") - exit(3) - - cmake_replacement() - - if not args.only_params and not args.only_launch and not args.only_python: - source_code_replacement() - - if not args.only_source and not args.only_launch and not args.only_python: - param_replacement() - - if not args.only_source and not args.only_params and not args.only_python: - launch_replacement() - - if not args.only_source and not args.only_params and not args.only_launch: - python_replacement() From 2ec39bf44f3f3061b6f5a9e2fc58efe369ef72f6 Mon Sep 17 00:00:00 2001 From: Jan Gutsche Date: Tue, 15 Aug 2023 14:48:32 +0200 Subject: [PATCH 16/16] Makefile: Install command: remove basler drivers --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index fc5dfb8b7..491b06c89 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ basler: scripts/make_basler.sh install: pull-init - scripts/make_basler.sh scripts/make_update.sh pip: