diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d56d6ef9a..a2609b38e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,8 @@ -FROM ros:iron +FROM ros:jazzy + +ARG user=bitbots +ARG uid=1000 +ARG gid=1000 # Basic Utilities ENV DEBIAN_FRONTEND=noninteractive @@ -54,41 +58,51 @@ RUN apt update -y \ RUN apt-get install -y \ python3-rosdep \ python3-vcstool \ - ros-iron-camera-calibration \ - ros-iron-desktop \ - ros-iron-joint-state-publisher-gui \ - ros-iron-plotjuggler \ - ros-iron-plotjuggler-msgs \ - ros-iron-plotjuggler-ros \ - ros-iron-rmw-cyclonedds-cpp \ - ros-iron-rqt-robot-monitor \ - ros-iron-soccer-vision-3d-rviz-markers - -# Update pip and install colcon-clean -RUN pip3 install pip -U - -# Install colcon extensions / patches -RUN python3 -m pip install \ - git+https://github.com/ruffsl/colcon-clean \ - git+https://github.com/timonegk/colcon-core.git@colors \ - git+https://github.com/timonegk/colcon-notification.git@colors \ - git+https://github.com/timonegk/colcon-output.git@colors + python3-virtualenv \ + ros-jazzy-camera-calibration \ + ros-jazzy-desktop \ + ros-jazzy-joint-state-publisher-gui \ + ros-jazzy-plotjuggler \ + ros-jazzy-plotjuggler-msgs \ + ros-jazzy-plotjuggler-ros \ + ros-jazzy-rmw-cyclonedds-cpp \ + ros-jazzy-rqt-robot-monitor \ + ros-jazzy-soccer-vision-3d-rviz-markers # Set zsh as default shell SHELL ["/bin/zsh", "-c"] -# Create home directory and colcon workspace -RUN mkdir -p "/root/colcon_ws" +# Remove the users group, because when it exists on the host system +# the devcontainer will not dynamically update the containerUser GID, +# when the host user is part of the users group. +# Then create a bitbots user with home directory and add allow it to use sudo +RUN groupdel users \ + && userdel -r ubuntu \ + && useradd -m -U -u "$uid" -G sudo -s /bin/zsh $user \ + && groupmod -g "$gid" $user \ + && echo "$user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + +USER $user + +# Install pip colcon extensions / patches as user +RUN python3 -m pip install --user --break-system-packages \ + git+https://github.com/ruffsl/colcon-clean \ + git+https://github.com/timonegk/colcon-core.git@colors \ + git+https://github.com/timonegk/colcon-notification.git@colors \ + git+https://github.com/timonegk/colcon-output.git@colors + +# Create colcon workspace +RUN mkdir -p /home/$user/colcon_ws/src # Install oh-my-zsh for pretty terminal RUN sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ - git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions + git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" -# Add zshrc -COPY zshrc "/root/.zshrc" +# Add zshrc to bitbots home directory +COPY --chown=$user:$user zshrc /home/$user/.zshrc # This is required for sharing Xauthority ENV QT_X11_NO_MITSHM=1 # Switch to the workspace directory -WORKDIR "/root/colcon_ws" +WORKDIR /home/$user/colcon_ws diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d7c87f452..2b735fca2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "Bit-Bots Iron Dev", + "name": "Bit-Bots Jazzy Dev", "build": { "dockerfile": "Dockerfile" }, @@ -14,14 +14,16 @@ "vscode": { "settings": { "terminal.integrated.defaultProfile.linux": "zsh", - "terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } } + "terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } }, + "dev.containers.copyGitConfig": false, + "dev.containers.gitCredentialHelperConfigLocation": "none" }, "extensions": ["ms-iot.vscode-ros"] } }, - "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/root/colcon_ws/src/bitbots_main", - "workspaceFolder": "/root/colcon_ws/src/bitbots_main", + "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/home/bitbots/colcon_ws/src/bitbots_main", + "workspaceFolder": "/home/bitbots/colcon_ws/src/bitbots_main", "mounts": [ "type=bind,source=${localEnv:HOME},target=/srv/host_home,consistency=cached" diff --git a/.devcontainer/zshrc b/.devcontainer/zshrc index 27e9c7767..70e5cf296 100644 --- a/.devcontainer/zshrc +++ b/.devcontainer/zshrc @@ -50,12 +50,12 @@ bindkey "^[[1;5D" backward-word # Settings for the prompt to show that we are in a docker container -export PROMPT="%K{black} 🐋 %K{blue}%F{black}%/ %f%k%F{blue}%f " # Prefix the prompt with DOCKER +export PROMPT="%K{black} 🐋 %K{blue}%F{black} %~ %f%k%F{blue}%f " # Prefix the prompt with DOCKER # >>> bit-bots initialize >>> # Ignore some deprecation warnings -export PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources +export PYTHONWARNINGS="ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources,ignore:easy_install command is deprecated,ignore:setup.py install is deprecated" # Limit ROS 2 communication to localhost (can be overridden when needed) export ROS_DOMAIN_ID=24 diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index d5bb2ab71..7baa3225b 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -11,3 +11,4 @@ f29fb619aef9f416cbbdc74ec77c23423dcefe07 3b9f322183bed2cb271bf6bd07d803a93c398c3e ae9fbef74c50ba1e462d1b76da16779c76aa0d5b 476e75e3f3d17c35ac89b17f513d93078687d613 +cd3280273363807e1b5df2ade0138d48178cb06b diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 377ce3f22..e73122e8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,17 +4,27 @@ on: - cron: '0 0 * * *' push: +env: + PYTHONWARNINGS: "ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources,ignore:easy_install command is deprecated,ignore:setup.py install is deprecated" + jobs: build: runs-on: ubuntu-latest container: - image: ubuntu:jammy + image: ubuntu:noble steps: - name: Cancel outdated jobs uses: fkirc/skip-duplicate-actions@v5 with: cancel_others: 'true' + + # Remove comments to spawn an interactive debigging ssh shell in the ci + #- name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # with: + # detached: true + - name: Set up ROS ecosystem uses: ros-tooling/setup-ros@v0.7 @@ -30,7 +40,9 @@ jobs: echo "PATH=$PATH:/github/home/.local/bin" >> "$GITHUB_ENV" - name: Pull source code for libraries and install dependencies - run: make install HTTPS=true ARGS="--ci" + run: | + sudo apt-get remove -y python3-pytest-repeat #TODO remove once the upstream apt package reports the correct version on the newest pip version + make install HTTPS=true ARGS="--ci" - name: Set up colcon workspace run: | @@ -39,14 +51,14 @@ jobs: - name: Build packages run: | - . /opt/ros/iron/setup.sh + . /opt/ros/jazzy/setup.sh colcon build --symlink-install working-directory: /colcon_ws - name: Test packages run: | # Source workspace - . /opt/ros/iron/setup.sh + . /opt/ros/jazzy/setup.sh . install/setup.sh # Run tests for all packages colcon test --event-handlers console_direct+ --return-code-on-test-failure --parallel-workers 1 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 88b1011ed..bb80c075f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -7,10 +7,10 @@ on: jobs: pre-commit: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 - name: Install cppcheck run: sudo apt install cppcheck -y - - uses: pre-commit/action@v3.0.0 + - uses: pre-commit/action@v3.0.1 diff --git a/.gitignore b/.gitignore index 3d75bbd0c..df3f74bd9 100644 --- a/.gitignore +++ b/.gitignore @@ -97,8 +97,6 @@ qtcreator-* # Emacs .#* -# Catkin custom files -CATKIN_IGNORE ### Python template # Byte-compiled / optimized / DLL files __pycache__/ @@ -220,10 +218,11 @@ doku/* # library subdirectories /lib/ -# Path to the protocol buffer definitions, which are a diffrerent repository and managed by vcstool +# Path to the protocol buffer definitions, which are a different repository and managed by vcstool /bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/RobocupProtocol # Protobuf generated file /bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/robocup_extension_pb2.py +/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/robocup_extension_pb2.pyi # Workspace git status file from the deploy tool **/workspace_status.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2c0c5e37a..8f6e20745 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.9.6 hooks: - id: ruff args: @@ -16,18 +16,18 @@ repos: - id: cppcheck args: - "--inline-suppr" - - "--suppress=missingInclude" + - "--suppress=missingIncludeSystem" - "--suppress=unmatchedSuppression" - "--suppress=unusedFunction" - "--suppress=unusedStructMember" - "--suppress=useStlAlgorithm" - repo: https://github.com/cheshirekow/cmake-format-precommit - rev: v0.6.10 + rev: v0.6.13 hooks: - id: cmake-format - id: cmake-lint - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-merge-conflict - id: check-toml diff --git a/.vscode/settings.json b/.vscode/settings.json index be0dde9f6..ba732efae 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -117,6 +117,7 @@ "unpenalize", "unpenalized", "urdf", + "vcstool", "walkready", "wandb", "webots", @@ -219,13 +220,13 @@ }, // Tell the ROS extension where to find the setup.bash // This also utilizes the COLCON_WS environment variable, which needs to be set - "ros.distro": "iron", + "ros.distro": "jazzy", "search.useIgnoreFiles": false, "python.autoComplete.extraPaths": [ - "/opt/ros/iron/lib/python3.10/site-packages" + "/opt/ros/jazzy/lib/python3.12/site-packages" ], "python.analysis.extraPaths": [ - "/opt/ros/iron/lib/python3.10/site-packages" + "/opt/ros/jazzy/lib/python3.12/site-packages" ], "cmake.configureOnOpen": false, "editor.formatOnSave": true, @@ -237,4 +238,8 @@ "[json]": { "editor.defaultFormatter": "vscode.json-language-features" }, + "makefile.configureOnOpen": true, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, } diff --git a/Makefile b/Makefile index 92abcbe43..86500334c 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ install-no-root: pull-init update-no-root pip: # Install and upgrade pip dependencies - pip install --upgrade pip --user - pip install --upgrade -r requirements/dev.txt --user -v + pip install --upgrade pip --user --break-system-packages -v + pip install --upgrade -r requirements/dev.txt --user --break-system-packages -v pre-commit: # Install pre-commit hooks for all submodules that have a .pre-commit-config.yaml file @@ -91,8 +91,8 @@ rosdep: # Initialize rosdep if not already done [ -f /etc/ros/rosdep/sources.list.d/20-default.list ] || sudo rosdep init # Update rosdep and install dependencies from meta directory - rosdep update --include-eol-distros - rosdep install --from-paths . --ignore-src --rosdistro iron -y + rosdep update + rosdep install --from-paths . --ignore-src --rosdistro jazzy -y status: # Show status of all repositories diff --git a/README.md b/README.md index c04f8132d..067943c5b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build & Test](https://github.com/bit-bots/bitbots_main/actions/workflows/ci.yml/badge.svg)](https://github.com/bit-bots/bitbots_main/actions/workflows/ci.yml) [![Code style checks](https://github.com/bit-bots/bitbots_main/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/bit-bots/bitbots_main/actions/workflows/pre-commit.yml) -[![ROS Version Iron](https://img.shields.io/badge/ROS%20Version-Iron-ab8c71)](https://docs.ros.org/en/iron/index.html) +[![ROS Version Jazzy](https://img.shields.io/badge/ROS%20Version-Jazzy-00b8ff)](https://docs.ros.org/en/jazzy/index.html) This git repository contains all RoboCup-related code and documentation from the Hamburg Bit-Bots team. All code is written as individual ROS 2 packages targeting Ubuntu. diff --git a/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/world_model_capsule.py b/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/world_model_capsule.py index d1a9f47ab..caa4589c2 100644 --- a/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/world_model_capsule.py +++ b/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/world_model_capsule.py @@ -21,16 +21,13 @@ from bitbots_blackboard.capsules import AbstractBlackboardCapsule -class WorldModelTFError(Exception): - ... +class WorldModelTFError(Exception): ... -class WorldModelPositionTFError(WorldModelTFError): - ... +class WorldModelPositionTFError(WorldModelTFError): ... -class WorldModelBallTFError(WorldModelTFError): - ... +class WorldModelBallTFError(WorldModelTFError): ... class WorldModelCapsule(AbstractBlackboardCapsule): diff --git a/bitbots_behavior/bitbots_body_behavior/package.xml b/bitbots_behavior/bitbots_body_behavior/package.xml index ed5935edf..c0256d7dc 100644 --- a/bitbots_behavior/bitbots_body_behavior/package.xml +++ b/bitbots_behavior/bitbots_body_behavior/package.xml @@ -32,6 +32,7 @@ tf2 ament_mypy + python3-pytest diff --git a/bitbots_behavior/bitbots_body_behavior/setup.py b/bitbots_behavior/bitbots_body_behavior/setup.py index 2b535daae..097ec5c5b 100644 --- a/bitbots_behavior/bitbots_body_behavior/setup.py +++ b/bitbots_behavior/bitbots_body_behavior/setup.py @@ -1,13 +1,13 @@ import glob -from setuptools import setup +from setuptools import find_packages, setup package_name = "bitbots_body_behavior" setup( name=package_name, - packages=[package_name], + packages=find_packages(exclude=["test"]), data_files=[ ("share/" + package_name, ["package.xml"]), ("share/ament_index/resource_index/packages", ["resource/" + package_name]), diff --git a/bitbots_lowlevel/bitbots_ros_control/CMakeLists.txt b/bitbots_lowlevel/bitbots_ros_control/CMakeLists.txt index 65939952a..b418f2b3a 100644 --- a/bitbots_lowlevel/bitbots_ros_control/CMakeLists.txt +++ b/bitbots_lowlevel/bitbots_ros_control/CMakeLists.txt @@ -25,7 +25,6 @@ find_package(moveit_core REQUIRED) find_package(moveit_ros_planning REQUIRED) find_package(pluginlib REQUIRED) find_package(rclcpp REQUIRED) -find_package(realtime_tools REQUIRED) find_package(rosidl_typesupport_cpp REQUIRED) find_package(std_msgs REQUIRED) find_package(std_srvs REQUIRED) @@ -71,7 +70,6 @@ ament_target_dependencies( moveit_ros_planning pluginlib rclcpp - realtime_tools rosidl_typesupport_cpp std_msgs std_srvs @@ -94,7 +92,6 @@ ament_target_dependencies( hardware_interface pluginlib rclcpp - realtime_tools rosidl_typesupport_cpp std_msgs std_srvs @@ -112,7 +109,6 @@ ament_export_dependencies(controller_manager) ament_export_dependencies(dynamixel_workbench_toolbox) ament_export_dependencies(hardware_interface) ament_export_dependencies(pluginlib) -ament_export_dependencies(realtime_tools) ament_export_dependencies(std_msgs) ament_export_dependencies(tf2_ros) ament_export_dependencies(transmission_interface) diff --git a/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/hardware_interface.hpp b/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/hardware_interface.hpp index cc59c3041..499222df5 100644 --- a/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/hardware_interface.hpp +++ b/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/hardware_interface.hpp @@ -12,11 +12,11 @@ class HardwareInterface { public: virtual bool init() = 0; - virtual void read(const rclcpp::Time &t, const rclcpp::Duration &dt){}; + virtual void read(const rclcpp::Time &t, const rclcpp::Duration &dt) {}; - virtual void write(const rclcpp::Time &t, const rclcpp::Duration &dt){}; + virtual void write(const rclcpp::Time &t, const rclcpp::Duration &dt) {}; - virtual void restoreAfterPowerCycle(){}; + virtual void restoreAfterPowerCycle() {}; virtual ~HardwareInterface(){}; }; diff --git a/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/utils.hpp b/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/utils.hpp index 68e480cd2..eab409395 100644 --- a/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/utils.hpp +++ b/bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/utils.hpp @@ -1,8 +1,8 @@ #ifndef BITBOTS_ROS_CONTROL_INCLUDE_BITBOTS_ROS_CONTROL_UTILS_H_ #define BITBOTS_ROS_CONTROL_INCLUDE_BITBOTS_ROS_CONTROL_UTILS_H_ -#include "bitbots_msgs/msg/audio.hpp" -#include "rclcpp/rclcpp.hpp" +#include +#include namespace bitbots_ros_control { @@ -13,7 +13,7 @@ void speakError(rclcpp::Publisher::SharedPtr speak_pub uint16_t dxlMakeword(uint64_t a, uint64_t b); uint32_t dxlMakedword(uint64_t a, uint64_t b); -float dxlMakeFloat(uint8_t* data); +float dxlMakeFloat(const uint8_t* data); std::string gyroRangeToString(uint8_t range); std::string accelRangeToString(uint8_t range); diff --git a/bitbots_lowlevel/bitbots_ros_control/package.xml b/bitbots_lowlevel/bitbots_ros_control/package.xml index 23abbeb60..ac969f877 100644 --- a/bitbots_lowlevel/bitbots_ros_control/package.xml +++ b/bitbots_lowlevel/bitbots_ros_control/package.xml @@ -31,13 +31,13 @@ bitbots_tts pluginlib rclcpp - realtime_tools std_msgs system_monitor transmission_interface yaml-cpp imu_complementary_filter + rviz_imu_plugin diff --git a/bitbots_lowlevel/bitbots_ros_control/scripts/pose_check.py b/bitbots_lowlevel/bitbots_ros_control/scripts/pose_check.py index 531cc4f23..d9a037a22 100755 --- a/bitbots_lowlevel/bitbots_ros_control/scripts/pose_check.py +++ b/bitbots_lowlevel/bitbots_ros_control/scripts/pose_check.py @@ -44,7 +44,7 @@ def num_to_emoji(num: int) -> str: emoji_numbers = ["0️⃣", "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"] - return f'{"".join([emoji_numbers[int(digit)] for digit in str(num)])} ' + return f"{''.join([emoji_numbers[int(digit)] for digit in str(num)])} " def move_to_joint_position(publisher: Publisher, joint_goals: dict[str, float], offsets=True): diff --git a/bitbots_lowlevel/bitbots_ros_control/src/dynamixel_servo_hardware_interface.cpp b/bitbots_lowlevel/bitbots_ros_control/src/dynamixel_servo_hardware_interface.cpp index 34f24cb5d..81371b754 100644 --- a/bitbots_lowlevel/bitbots_ros_control/src/dynamixel_servo_hardware_interface.cpp +++ b/bitbots_lowlevel/bitbots_ros_control/src/dynamixel_servo_hardware_interface.cpp @@ -1,8 +1,7 @@ -#include -#include - #include #include +#include +#include #include namespace bitbots_ros_control { @@ -148,7 +147,7 @@ void DynamixelServoHardwareInterface::individualTorqueCb(bitbots_msgs::msg::Join RCLCPP_WARN(nh_->get_logger(), "Couldn't set torque for servo %s ", msg.joint_names[i].c_str()); } } - for (auto &bus : bus_interfaces_) { + for (const auto &bus : bus_interfaces_) { bus->switch_individual_torque_ = true; } } @@ -157,7 +156,7 @@ void DynamixelServoHardwareInterface::setTorqueCb(std_msgs::msg::Bool::SharedPtr /** * This saves the given required value, so that it can be written to the servos in the write method */ - for (auto &bus : bus_interfaces_) { + for (const auto &bus : bus_interfaces_) { bus->goal_torque_ = enabled->data; } for (size_t j = 0; j < joint_names_.size(); j++) { @@ -196,7 +195,7 @@ void DynamixelServoHardwareInterface::write(const rclcpp::Time &t, const rclcpp: // set all values from controller to the buses // todo improve performance int i = 0; - for (auto &bus : bus_interfaces_) { + for (const auto &bus : bus_interfaces_) { for (int j = 0; j < bus->joint_count_; j++) { bus->goal_position_[j] = goal_position_[i]; bus->goal_velocity_[j] = goal_velocity_[i]; diff --git a/bitbots_lowlevel/bitbots_ros_control/src/pressure_converter.cpp b/bitbots_lowlevel/bitbots_ros_control/src/pressure_converter.cpp index 7cdc9f597..0dff0ae2e 100644 --- a/bitbots_lowlevel/bitbots_ros_control/src/pressure_converter.cpp +++ b/bitbots_lowlevel/bitbots_ros_control/src/pressure_converter.cpp @@ -76,8 +76,7 @@ PressureConverter::PressureConverter(rclcpp::Node::SharedPtr nh, char side) { } for (int i = 0; i < 4; i++) { std::stringstream single_wrench_frame; - single_wrench_frame << side << "_" - << "cleat_" << wrench_topics[i]; + single_wrench_frame << side << "_" << "cleat_" << wrench_topics[i]; wrench_frames_.push_back(single_wrench_frame.str()); } diff --git a/bitbots_lowlevel/bitbots_ros_control/src/servo_bus_interface.cpp b/bitbots_lowlevel/bitbots_ros_control/src/servo_bus_interface.cpp index b034a2f98..06c82fff5 100644 --- a/bitbots_lowlevel/bitbots_ros_control/src/servo_bus_interface.cpp +++ b/bitbots_lowlevel/bitbots_ros_control/src/servo_bus_interface.cpp @@ -202,7 +202,7 @@ bool ServoBusInterface::writeROMRAM(bool first_time) { // Allocate memory for the values in the driver std::vector values(joint_names_.size()); // Iterate over parameter names - for (auto register_name : parameter_names) { + for (const auto ®ister_name : parameter_names) { // Get the value for each joint for (size_t num = 0; num < joint_names_.size(); num++) { // Get the value from the cache diff --git a/bitbots_lowlevel/bitbots_ros_control/src/utils.cpp b/bitbots_lowlevel/bitbots_ros_control/src/utils.cpp index a9e0745ba..9286eba43 100644 --- a/bitbots_lowlevel/bitbots_ros_control/src/utils.cpp +++ b/bitbots_lowlevel/bitbots_ros_control/src/utils.cpp @@ -40,7 +40,7 @@ uint32_t dxlMakedword(uint64_t a, uint64_t b) { return uint32_t(uint16_t(a & 0xffff) | uint32_t(uint16_t(b & 0xffff) << 16)); } -float dxlMakeFloat(uint8_t* data) { +float dxlMakeFloat(const uint8_t* data) { float f; uint32_t b = dxlMakedword(dxlMakeword(data[0], data[1]), dxlMakeword(data[2], data[3])); memcpy(&f, &b, sizeof(f)); diff --git a/bitbots_lowlevel/bitbots_ros_control/src/wolfgang_hardware_interface.cpp b/bitbots_lowlevel/bitbots_ros_control/src/wolfgang_hardware_interface.cpp index 929812d83..96097debd 100644 --- a/bitbots_lowlevel/bitbots_ros_control/src/wolfgang_hardware_interface.cpp +++ b/bitbots_lowlevel/bitbots_ros_control/src/wolfgang_hardware_interface.cpp @@ -307,7 +307,7 @@ void WolfgangHardwareInterface::write(const rclcpp::Time &t, const rclcpp::Durat } if (!bus_start_time_ || t > bus_start_time_.value()) { if (bus_first_write_) { - for (std::vector> &port_interfaces : interfaces_) { + for (std::vector> const &port_interfaces : interfaces_) { for (std::shared_ptr interface : port_interfaces) { interface->restoreAfterPowerCycle(); } diff --git a/bitbots_misc/bitbots_basler_camera/src/basler_camera.cpp b/bitbots_misc/bitbots_basler_camera/src/basler_camera.cpp index c1f6b2e92..eaaec5993 100644 --- a/bitbots_misc/bitbots_basler_camera/src/basler_camera.cpp +++ b/bitbots_misc/bitbots_basler_camera/src/basler_camera.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -18,8 +19,6 @@ #include #include -#include "pylon_camera_parameters.hpp" - using std::placeholders::_1, std::placeholders::_2; using namespace Pylon; @@ -271,7 +270,8 @@ class BaslerCamera { } // Convert to cv::Mat - cv::Mat image(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC1, (uint8_t*)ptrGrabResult->GetBuffer()); + cv::Mat image(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC1, + static_cast(ptrGrabResult->GetBuffer())); // Create cv::Mat for color image cv::Mat color(image.size(), CV_MAKETYPE(CV_8U, 3)); diff --git a/bitbots_misc/bitbots_containers/hlvs/Dockerfile b/bitbots_misc/bitbots_containers/hlvs/Dockerfile index 206b10d1e..891b78832 100644 --- a/bitbots_misc/bitbots_containers/hlvs/Dockerfile +++ b/bitbots_misc/bitbots_containers/hlvs/Dockerfile @@ -1,81 +1,242 @@ # Use upstream ubuntu images as base -FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 -ENV DEBIAN_FRONTEND=noninteractive +FROM nvidia/cuda:12.8.0-devel-ubuntu24.04 + +ARG UID=150 +ARG ROS_DISTRO=jazzy +ARG BITBOTS_MAIN_BRANCH=feature/jazzy-ubuntu2404-devcontainer -# Install system dependencies -ADD sources.list /etc/apt/sources.list -RUN apt update -RUN apt install -y wget auto-apt-proxy apt-utils -RUN mkdir -p /usr/local/share/keyrings -RUN wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O /usr/local/share/keyrings/ros-archive-keyring.gpg -RUN echo "deb [arch=amd64 signed-by=/usr/local/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu jammy main" | tee /etc/apt/sources.list.d/ros2.list -RUN apt update +ENV DEBIAN_FRONTEND=noninteractive -# Install a lot of apt packages. They could also be installed with rosdep, but we want them to be cached -RUN apt install -y build-essential espeak git libjsoncpp-dev libprotobuf-dev libprotoc-dev locales protobuf-compiler python3-colcon-clean python3-colcon-common-extensions python3-colcon-core python3-construct python3-hypothesis python3-numpy python3-opencv python3-pip python3-protobuf python3-psutil python3-rosdep python3-rospkg python3-sklearn python3-sphinx-rtd-theme python3-transforms3d ros-iron-rmw-cyclonedds-cpp sudo xvfb && \ - apt clean && \ - rm -rf /var/lib/apt/lists/* +RUN apt update \ + && apt install -y wget auto-apt-proxy apt-utils \ + && mkdir -p /usr/local/share/keyrings \ + && wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O /usr/local/share/keyrings/ros-archive-keyring.gpg \ + && echo "deb [arch=amd64 signed-by=/usr/local/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu noble main" | tee /etc/apt/sources.list.d/ros2.list \ + && apt update + +# Install a lot of apt packages. +# They could also be installed with rosdep, but we want them to be cached. +RUN apt install -y \ + build-essential \ + espeak \ + ffmpeg \ + git \ + ipython3 \ + locales \ + protobuf-compiler \ + sudo \ + vcstool \ + gir1.2-gst-plugins-base-1.0 \ + gir1.2-gstreamer-1.0 \ + gstreamer1.0-alsa \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-tools \ + libboost-all-dev \ + libeigen3-dev \ + libfmt-dev \ + libfreeimage-dev\ + libgstreamer-plugins-base1.0-0 \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer1.0-0 \ + libgstreamer1.0-dev \ + libjsoncpp-dev \ + libopencv-dev \ + libprotobuf-dev \ + libprotoc-dev \ + librange-v3-dev \ + liburdfdom-dev \ + libyaml-cpp-dev \ + protobuf-compiler \ + pybind11-dev \ + pyqt5-dev \ + python3-breathe \ + python3-colcon-clean \ + python3-colcon-common-extensions \ + python3-construct \ + python3-coverage \ + python3-cryptography \ + python3-hypothesis \ + python3-matplotlib \ + python3-nose \ + python3-numpy \ + python3-opencv \ + python3-pil \ + python3-pip \ + python3-protobuf \ + python3-psutil \ + python3-pydot \ + python3-pyqt5 \ + python3-pyqt5.qtsvg \ + python3-pytest \ + python3-rosdep \ + python3-rospkg \ + python3-scipy \ + python3-sip-dev \ + python3-sphinx-rtd-theme \ + python3-tk \ + python3-transforms3d \ + python3-yaml \ + xvfb \ + ros-${ROS_DISTRO}-action-msgs \ + ros-${ROS_DISTRO}-ament-cmake \ + ros-${ROS_DISTRO}-ament-cmake-gtest \ + ros-${ROS_DISTRO}-ament-cmake-mypy \ + ros-${ROS_DISTRO}-ament-cmake-python \ + ros-${ROS_DISTRO}-ament-cmake-ros \ + ros-${ROS_DISTRO}-ament-copyright \ + ros-${ROS_DISTRO}-ament-flake8 \ + ros-${ROS_DISTRO}-ament-lint-auto \ + ros-${ROS_DISTRO}-ament-lint-common \ + ros-${ROS_DISTRO}-ament-mypy \ + ros-${ROS_DISTRO}-ament-pep257 \ + ros-${ROS_DISTRO}-apriltag-ros \ + ros-${ROS_DISTRO}-backward-ros \ + ros-${ROS_DISTRO}-builtin-interfaces \ + ros-${ROS_DISTRO}-camera-info-manager \ + ros-${ROS_DISTRO}-control-toolbox \ + ros-${ROS_DISTRO}-controller-interface \ + ros-${ROS_DISTRO}-controller-manager \ + ros-${ROS_DISTRO}-cv-bridge \ + ros-${ROS_DISTRO}-demo-nodes-cpp \ + ros-${ROS_DISTRO}-diagnostic-aggregator \ + ros-${ROS_DISTRO}-diagnostic-msgs \ + ros-${ROS_DISTRO}-foxglove-bridge \ + ros-${ROS_DISTRO}-gazebo-msgs \ + ros-${ROS_DISTRO}-generate-parameter-library \ + ros-${ROS_DISTRO}-geometry-msgs \ + ros-${ROS_DISTRO}-hardware-interface \ + ros-${ROS_DISTRO}-image-proc \ + ros-${ROS_DISTRO}-image-transport \ + ros-${ROS_DISTRO}-imu-complementary-filter \ + ros-${ROS_DISTRO}-joint-state-publisher \ + ros-${ROS_DISTRO}-joint-state-publisher-gui \ + ros-${ROS_DISTRO}-launch-xml \ + ros-${ROS_DISTRO}-message-filters \ + ros-${ROS_DISTRO}-moveit-core \ + ros-${ROS_DISTRO}-moveit-kinematics \ + ros-${ROS_DISTRO}-moveit-msgs \ + ros-${ROS_DISTRO}-moveit-planners-ompl \ + ros-${ROS_DISTRO}-moveit-ros \ + ros-${ROS_DISTRO}-moveit-ros-move-group \ + ros-${ROS_DISTRO}-moveit-ros-planning \ + ros-${ROS_DISTRO}-moveit-ros-planning-interface \ + ros-${ROS_DISTRO}-moveit-ros-robot-interaction \ + ros-${ROS_DISTRO}-moveit-ros-visualization \ + ros-${ROS_DISTRO}-moveit-setup-assistant \ + ros-${ROS_DISTRO}-moveit-simple-controller-manager \ + ros-${ROS_DISTRO}-nav-msgs \ + ros-${ROS_DISTRO}-plotjuggler \ + ros-${ROS_DISTRO}-plotjuggler \ + ros-${ROS_DISTRO}-pluginlib \ + ros-${ROS_DISTRO}-pybind11-vendor \ + ros-${ROS_DISTRO}-qt-dotgraph \ + ros-${ROS_DISTRO}-rcl \ + ros-${ROS_DISTRO}-rclcpp \ + ros-${ROS_DISTRO}-rclcpp-components \ + ros-${ROS_DISTRO}-rclpy \ + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ + ros-${ROS_DISTRO}-robot-state-publisher \ + ros-${ROS_DISTRO}-ros2launch \ + ros-${ROS_DISTRO}-ros2trace \ + ros-${ROS_DISTRO}-rosbag2 \ + ros-${ROS_DISTRO}-rosgraph-msgs \ + ros-${ROS_DISTRO}-rosidl-default-generators \ + ros-${ROS_DISTRO}-rosidl-default-runtime \ + ros-${ROS_DISTRO}-rot-conv \ + ros-${ROS_DISTRO}-rqt-gui \ + ros-${ROS_DISTRO}-rqt-gui-py \ + ros-${ROS_DISTRO}-rviz-imu-plugin \ + ros-${ROS_DISTRO}-sensor-msgs \ + ros-${ROS_DISTRO}-sensor-msgs-py \ + ros-${ROS_DISTRO}-shape-msgs \ + ros-${ROS_DISTRO}-soccer-vision-2d-msgs \ + ros-${ROS_DISTRO}-soccer-vision-3d-msgs \ + ros-${ROS_DISTRO}-soccer-vision-3d-rviz-markers \ + ros-${ROS_DISTRO}-soccer-vision-attribute-msgs \ + ros-${ROS_DISTRO}-std-msgs \ + ros-${ROS_DISTRO}-std-srvs \ + ros-${ROS_DISTRO}-test-msgs \ + ros-${ROS_DISTRO}-tf-transformations \ + ros-${ROS_DISTRO}-tf2 \ + ros-${ROS_DISTRO}-tf2-eigen \ + ros-${ROS_DISTRO}-tf2-geometry-msgs \ + ros-${ROS_DISTRO}-tf2-kdl \ + ros-${ROS_DISTRO}-tf2-ros \ + ros-${ROS_DISTRO}-tf2-sensor-msgs \ + ros-${ROS_DISTRO}-topic-tools \ + ros-${ROS_DISTRO}-tracetools-acceleration \ + ros-${ROS_DISTRO}-tracetools-analysis \ + ros-${ROS_DISTRO}-tracetools-image-pipeline \ + ros-${ROS_DISTRO}-tracetools-test \ + ros-${ROS_DISTRO}-trajectory-msgs \ + ros-${ROS_DISTRO}-transmission-interface \ + ros-${ROS_DISTRO}-urdf \ + ros-${ROS_DISTRO}-urdfdom-py \ + ros-${ROS_DISTRO}-vision-msgs \ + ros-${ROS_DISTRO}-vision-opencv \ + ros-${ROS_DISTRO}-visualization-msgs \ + ros-${ROS_DISTRO}-xacro \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* # Set up locale -RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && locale-gen && update-locale LANG=en_US.UTF-8 -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 +RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen \ + && locale-gen \ + && update-locale LANG=en_US.UTF-8 -# Add user -ARG UID=150 -RUN useradd -M -d /colcon_ws -s /bin/bash -u $UID robot +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US:en +ENV LC_ALL=en_US.UTF-8 -# Install sudoers file -ADD sudoers /etc/sudoers +RUN mkdir -p /colcon_ws/src \ + && useradd -M -d /colcon_ws -s /bin/bash -u $UID robot \ + && chown -R robot:robot /colcon_ws \ + && echo "robot ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/robot WORKDIR /colcon_ws -RUN chown robot:robot /colcon_ws USER robot:robot ENV PATH=$PATH:/colcon_ws/.local/bin -RUN . /opt/ros/iron/setup.sh && \ - mkdir src - -# Initialize rosdep -RUN sudo rosdep init +RUN . /opt/ros/${ROS_DISTRO}/setup.sh \ + && sudo rosdep init -# Add some requirements already here so that they are cached -#RUN python3 -m pip install -U pip && \ -# pip3 install -U PyYAML construct defusedxml matplotlib numpy opencv-python \ -# protobuf psutil pytorchyolo setuptools sklearn transforms3d +RUN mkdir -p -m 700 $HOME/.ssh \ + && ssh-keyscan github.com >> $HOME/.ssh/known_hosts -ADD --chown=robot:robot https://raw.githubusercontent.com/bit-bots/bitbots_main/master/requirements/common.txt src/requirements_common.txt - -RUN pip3 install -U -r src/requirements_common.txt --no-cache-dir && \ - pip3 uninstall -y numpy - -RUN cd src && \ - git clone https://github.com/bit-bots/bitbots_main.git && \ - cd bitbots_main && \ - make pull-init +RUN --mount=type=ssh,uid=$UID git clone --branch "$BITBOTS_MAIN_BRANCH" git@github.com:bit-bots/bitbots_main.git src/bitbots_main \ + && cd src/bitbots_main \ + && make pull-init rosdep pip # From here on, we don't want to cache anything. That's achieved by adding the current time. ADD https://www.timeapi.io/api/Time/current/zone?timeZone=UTC /tmp/build-time -RUN cd src/bitbots_main && \ - make pull-all && \ - rm -rf lib/udp_bridge bitbots_misc/bitbots_containers \ - lib/dynamic_stack_decider/dynamic_stack_decider_visualization bitbots_lowlevel \ - bitbots_robot/bitbots_pybullet_sim lib/DynamixelSDK lib/dynamixel-workbench \ - bitbots_misc/bitbots_basler_camera && \ - sed -i '/plotjuggler/d' bitbots_motion/bitbots_quintic_walk/package.xml && \ - sed -i '/run_depend/d' bitbots_robot/wolfgang_moveit_config/package.xml - -# Install ros dependencies with rosdep -RUN sudo apt update && rosdep update -RUN cd src/bitbots_main && rosdep install --rosdistro=iron --from-paths . --ignore-src -r -y - -RUN . /opt/ros/iron/setup.sh && colcon build --cmake-args -DBUILD_TESTING=OFF - -# TODO execute tests - -RUN cp src/bitbots_main/bitbots_robot/bitbots_robocup_api/scripts/start.sh .local/bin/start +RUN --mount=type=ssh,uid=$UID cd src/bitbots_main \ + && make pull-all \ + && rm -rf bitbots_lowlevel \ + bitbots_misc/bitbots_basler_camera \ + bitbots_misc/bitbots_ceiling_cam \ + bitbots_misc/bitbots_containers \ + bitbots_motion/bitbots_animation_rqt \ + bitbots_simulation/bitbots_pybullet_sim \ + bitbots_team_communication/bitbots_team_data_sim_rqt \ + bitbots_wolfgang \ + lib/dynamic_stack_decider/dynamic_stack_decider_visualization \ + lib/dynamixel-workbench \ + lib/pylon-ros-camera \ + lib/soccer_field_map_generator \ + lib/udp_bridge \ + && sed -i '/plotjuggler/d' bitbots_motion/bitbots_quintic_walk/package.xml + +# Install missing ros dependencies with rosdep +RUN sudo apt update \ + && rosdep update \ + && rosdep install --rosdistro=${ROS_DISTRO} --from-paths src/bitbots_main --ignore-src -r -y \ + && . /opt/ros/${ROS_DISTRO}/setup.sh \ + && colcon build --cmake-args -DBUILD_TESTING=OFF + +RUN cp src/bitbots_main/bitbots_simulation/bitbots_robocup_api/scripts/start.sh .local/bin/start # Volume for logs VOLUME /robocup-logs diff --git a/bitbots_misc/bitbots_containers/hlvs/entrypoint.sh b/bitbots_misc/bitbots_containers/hlvs/entrypoint.sh index 4db0c6165..855bbf598 100755 --- a/bitbots_misc/bitbots_containers/hlvs/entrypoint.sh +++ b/bitbots_misc/bitbots_containers/hlvs/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -source /opt/ros/iron/setup.bash +source /opt/ros/jazzy/setup.bash source /colcon_ws/install/setup.bash exec "$@" diff --git a/bitbots_misc/bitbots_containers/hlvs/sources.list b/bitbots_misc/bitbots_containers/hlvs/sources.list deleted file mode 100644 index 19a2fca7f..000000000 --- a/bitbots_misc/bitbots_containers/hlvs/sources.list +++ /dev/null @@ -1,4 +0,0 @@ -deb http://de.archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse -deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse diff --git a/bitbots_misc/bitbots_containers/hlvs/sudoers b/bitbots_misc/bitbots_containers/hlvs/sudoers deleted file mode 100644 index b589f942a..000000000 --- a/bitbots_misc/bitbots_containers/hlvs/sudoers +++ /dev/null @@ -1,7 +0,0 @@ -## -## User privilege specification -## -## Uncomment to allow any user to run sudo if they know the password -## of the user they are running the command as (root by default). -# Defaults targetpw # Ask for the password of the target user -ALL ALL=(ALL) NOPASSWD: ALL diff --git a/bitbots_misc/bitbots_docs/docs/manual/testing/testing.rst b/bitbots_misc/bitbots_docs/docs/manual/testing/testing.rst index e3990f5f3..4f0ce8dd0 100644 --- a/bitbots_misc/bitbots_docs/docs/manual/testing/testing.rst +++ b/bitbots_misc/bitbots_docs/docs/manual/testing/testing.rst @@ -49,7 +49,7 @@ Compile (compiles) ------------------ The first step is to test if the package compiles. -Obviously this should preferably be tested on the same system that is used on the robot (Ubuntu 22.04 with the iron distribution). +Obviously this should preferably be tested on the same system that is used on the robot (Ubuntu 24.04 with the jazzy distribution). A part of this is to check if all dependencies are correct in the package.xml. This is important so they can be installed with rosdep. diff --git a/bitbots_misc/bitbots_docs/docs/manual/tutorials/cl_simulation_testing_setup.rst b/bitbots_misc/bitbots_docs/docs/manual/tutorials/cl_simulation_testing_setup.rst index 7ce7b2331..2942f71a2 100644 --- a/bitbots_misc/bitbots_docs/docs/manual/tutorials/cl_simulation_testing_setup.rst +++ b/bitbots_misc/bitbots_docs/docs/manual/tutorials/cl_simulation_testing_setup.rst @@ -35,7 +35,7 @@ For compilation of the whole meta repository run ``cba``, which is an alias for: ``cd $COLCON_WS; colcon build --symlink-install --continue-on-error`` After a successful run, before we are able to use any ros commands we now need to source colcon built sources with ``sa``, which is an alias for: -``source "/opt/ros/iron/setup.$SHELL" && source "$COLCON_WS/install/setup.$SHELL"`` +``source "/opt/ros/jazzy/setup.$SHELL" && source "$COLCON_WS/install/setup.$SHELL"`` **3. Run Webots Simulation** diff --git a/bitbots_misc/bitbots_docs/docs/manual/tutorials/install_software_ros2.rst b/bitbots_misc/bitbots_docs/docs/manual/tutorials/install_software_ros2.rst index caf93aab6..176854de0 100644 --- a/bitbots_misc/bitbots_docs/docs/manual/tutorials/install_software_ros2.rst +++ b/bitbots_misc/bitbots_docs/docs/manual/tutorials/install_software_ros2.rst @@ -1,13 +1,13 @@ Software installation with ROS2 =============================== -In this tutorial, we will learn how to install ROS2 Iron Irwini on Ubuntu 22.04 and build our software stack. +In this tutorial, we will learn how to install ROS2 Jazzy Jalisco on Ubuntu 24.04 and build our software stack. **TLDR**: single command setup ------------------------------ **Prerequirements** -- You have a running Ubuntu 22.04 environment +- You have a running Ubuntu 24.04 environment - You have an existing Github account and added a SSH key to your account - You have root access to your system (sudo) @@ -23,17 +23,17 @@ If you have not previously set up any of our software stack, you can use the fol Manual steps with in depth explanation -------------------------------------- -**0. Use Ubuntu 22.04** +**0. Use Ubuntu 24.04** As ROS works best on Ubuntu, we are using this distribution. -Currently, ROS2 Iron runs on Ubuntu 22.04. +Currently, ROS2 Jazzy runs on Ubuntu 24.04. -If you are not already using Ubuntu 22.04, consider installing it on your system (perhaps as a dual boot?). +If you are not already using Ubuntu 24.04, consider installing it on your system (perhaps as a dual boot?). Alternatively you can use a devcontainer :doc:`vscode-dev-container`, with a preconfigured environment and follow those instructions, as these docs do not apply to the devcontainer. **1. Setup and Install ROS 2** -- Follow this guide and when it comes to the section **Install ROS 2 packages**, install the recommended ``ros-iron-desktop-full``: https://docs.ros.org/en/iron/Installation/Ubuntu-Install-Debians.html +- Follow this guide and when it comes to the section **Install ROS 2 packages**, install the recommended ``ros-jazzy-desktop-full``: https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debs.html - Install additional dependencies: .. code-block:: bash @@ -46,29 +46,14 @@ Alternatively you can use a devcontainer :doc:`vscode-dev-container`, with a pre python3-pip \ python3-rosdep \ python3-vcstool \ - ros-iron-plotjuggler-ros \ - ros-iron-rmw-cyclonedds-cpp \ - ros-iron-rqt-robot-monitor \ - ros-iron-rqt-runtime-monitor + ros-jazzy-plotjuggler-ros \ + ros-jazzy-rmw-cyclonedds-cpp \ + ros-jazzy-rqt-robot-monitor \ + ros-jazzy-rqt-runtime-monitor - Run ``sudo rosdep init`` to initialize ``rosdep``, a tool that helps you install system dependencies for ROS packages. -- Optionally, to get nice colored output from colcon, you can install the following pip packages: -.. code-block:: bash - - python3 -m pip install \ - git+https://github.com/ruffsl/colcon-clean \ - git+https://github.com/timonegk/colcon-core.git@colors \ - git+https://github.com/timonegk/colcon-notification.git@colors \ - git+https://github.com/timonegk/colcon-output.git@colors - -**2. Install Webots** - -Webots is a robot simulator, which we use to simulate our robots and test our software. -It is not strictly necessary to install it, but it is very useful for development and testing. -If you want to install it, you can do so by running ``make webots`` in the bitbots_main repository. - -**3. Download our software** +**2. Download our software (if not already done)** - Create a GitHub account, if not already done (see `here `_ for further information) - Add your SSH key to GitHub to access and sync our repositories @@ -86,9 +71,15 @@ If you want to install it, you can do so by running ``make webots`` in the bitbo This will take a while, as it downloads all the code and other files from our repositories and additionally installs all missing dependencies (using rosdep and pip). Finally, it will register pre-commit hooks (automatic code-formatting and warnings), which will be run every time you commit code to our repositories. +**3. Install Webots** + +Webots is a robot simulator, which we use to simulate our robots and test our software. +It is not strictly necessary to install it, but it is very useful for development and testing. +If you want to install it, you can do so by running ``make webots`` in the bitbots_main repository. + **4. Setup colcon workspace** -`Colcon `_ is the tool provided by ROS 2 to build and install our ROS packages, so that they can be launched later. +`Colcon `_ is the tool provided by ROS 2 to build and install our ROS packages, so that they can be launched later. The colcon workspace is where your source code gets build and where we use colcon. - Create colcon workspace directory (typically ``~/colcon_ws/``) @@ -108,8 +99,11 @@ In case you are not using the bash shell, replace ``~/.bashrc`` and ``bash`` wit # >>> bit-bots initialize >>> + # Add python pip bins to PATH + export PATH="\$HOME/.local/bin:\$PATH" + # Ignore some deprecation warnings - export PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources + export PYTHONWARNINGS="ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources,ignore:easy_install command is deprecated,ignore:setup.py install is deprecated" # Limit ROS 2 communication to localhost (can be overridden when needed) export ROS_DOMAIN_ID=24 diff --git a/bitbots_misc/bitbots_docs/docs/manual/tutorials/vscode-ros2.rst b/bitbots_misc/bitbots_docs/docs/manual/tutorials/vscode-ros2.rst index 75d17ec0a..23030b7cf 100644 --- a/bitbots_misc/bitbots_docs/docs/manual/tutorials/vscode-ros2.rst +++ b/bitbots_misc/bitbots_docs/docs/manual/tutorials/vscode-ros2.rst @@ -9,14 +9,14 @@ Navigate to your colcon workspace. Source ros -`source /opt/ros/iron/setup.zsh` +`source /opt/ros/jazzy/setup.zsh` Open VSCode `code .` Install the ROS extension (from Microsoft). -You should see a `ROS2.iron` in the lower left corner. +You should see a `ROS2.jazzy` in the lower left corner. Now you should be able to build the code with `Ctrl+Shift+B` diff --git a/bitbots_misc/bitbots_extrinsic_calibration/src/extrinsic_calibration.cpp b/bitbots_misc/bitbots_extrinsic_calibration/src/extrinsic_calibration.cpp index 1530622d4..ba668a025 100644 --- a/bitbots_misc/bitbots_extrinsic_calibration/src/extrinsic_calibration.cpp +++ b/bitbots_misc/bitbots_extrinsic_calibration/src/extrinsic_calibration.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include #include using std::placeholders::_1; diff --git a/bitbots_misc/bitbots_robot_description/launch/move_group.py b/bitbots_misc/bitbots_robot_description/launch/move_group.py index d36a0f5ac..1d4749014 100644 --- a/bitbots_misc/bitbots_robot_description/launch/move_group.py +++ b/bitbots_misc/bitbots_robot_description/launch/move_group.py @@ -62,8 +62,17 @@ def launch_setup(context, *args, **kwargs): ompl_planning_pipeline_config = { "move_group": { - "planning_plugin": "ompl_interface/OMPLPlanner", - "request_adapters": """default_planner_request_adapters/AddTimeOptimalParameterization default_planner_request_adapters/FixWorkspaceBounds default_planner_request_adapters/FixStartStateBounds default_planner_request_adapters/FixStartStateCollision default_planner_request_adapters/FixStartStatePathConstraints""", + "planning_plugins": ["ompl_interface/OMPLPlanner"], + "request_adapters": [ + "default_planning_request_adapters/ValidateWorkspaceBounds", + "default_planning_request_adapters/CheckStartStateBounds", + "default_planning_request_adapters/CheckStartStateCollision", + ], + "response_adapters": [ + "default_planning_response_adapters/AddTimeOptimalParameterization", + "default_planning_response_adapters/ValidateSolution", + "default_planning_response_adapters/DisplayMotionPath", + ], "start_state_max_bounds_error": 0.1, } } diff --git a/bitbots_misc/bitbots_teleop/package.xml b/bitbots_misc/bitbots_teleop/package.xml index 298625eab..15aad8159 100644 --- a/bitbots_misc/bitbots_teleop/package.xml +++ b/bitbots_misc/bitbots_teleop/package.xml @@ -20,6 +20,8 @@ std_msgs tf_transformations + python3-pytest + python2 diff --git a/bitbots_misc/bitbots_teleop/setup.py b/bitbots_misc/bitbots_teleop/setup.py index 0e1db4322..148552ede 100644 --- a/bitbots_misc/bitbots_teleop/setup.py +++ b/bitbots_misc/bitbots_teleop/setup.py @@ -19,6 +19,7 @@ "launch", "setuptools", ], + tests_require=["pytest"], zip_safe=True, keywords=["ROS"], license="MIT", diff --git a/bitbots_misc/bitbots_tts/package.xml b/bitbots_misc/bitbots_tts/package.xml index 096597d26..f0a86a2cc 100644 --- a/bitbots_misc/bitbots_tts/package.xml +++ b/bitbots_misc/bitbots_tts/package.xml @@ -11,7 +11,7 @@ Hamburg Bit-Bots MIT - + Marc Bestmann ament_cmake @@ -21,6 +21,8 @@ espeak std_msgs + python3-pytest + broken diff --git a/bitbots_misc/bitbots_tts/setup.py b/bitbots_misc/bitbots_tts/setup.py index 29cedacd8..9d702643b 100644 --- a/bitbots_misc/bitbots_tts/setup.py +++ b/bitbots_misc/bitbots_tts/setup.py @@ -6,7 +6,7 @@ setup( name=package_name, - packages=find_packages(), + packages=find_packages(exclude=["test"]), data_files=[ ("share/" + package_name, ["package.xml"]), ("share/ament_index/resource_index/packages", ["resource/" + package_name]), @@ -16,6 +16,7 @@ install_requires=[ "setuptools", ], + tests_require=["pytest"], scripts=glob.glob("scripts/*"), entry_points={ "console_scripts": [ diff --git a/bitbots_misc/bitbots_utils/bitbots_utils/utils.py b/bitbots_misc/bitbots_utils/bitbots_utils/utils.py index ac338987a..693a92ad0 100644 --- a/bitbots_misc/bitbots_utils/bitbots_utils/utils.py +++ b/bitbots_misc/bitbots_utils/bitbots_utils/utils.py @@ -56,7 +56,7 @@ def get_parameters_from_ros_yaml(node_name: str, parameter_file: str, use_wildca if param_keys == []: raise RuntimeError( - f"Param file does not contain parameters for {node_name}, " f" only for nodes: {param_file.keys()}" + f"Param file does not contain parameters for {node_name}, only for nodes: {param_file.keys()}" ) param_dict = {} for k in param_keys: diff --git a/bitbots_misc/bitbots_utils/scripts/motor_goals_viz_helper.py b/bitbots_misc/bitbots_utils/scripts/motor_goals_viz_helper.py index a8221e942..49d563501 100755 --- a/bitbots_misc/bitbots_utils/scripts/motor_goals_viz_helper.py +++ b/bitbots_misc/bitbots_utils/scripts/motor_goals_viz_helper.py @@ -68,11 +68,11 @@ def __init__(self): float(0), 0.7, float(-1), - float(-0.4), + -0.4, float(0), float(0), float(0), - float(-0.7), + -0.7, float(1), 0.4, float(0), diff --git a/bitbots_misc/bitbots_utils/src/utils.cpp b/bitbots_misc/bitbots_utils/src/utils.cpp index a0aea990a..2131dec2e 100644 --- a/bitbots_misc/bitbots_utils/src/utils.cpp +++ b/bitbots_misc/bitbots_utils/src/utils.cpp @@ -1,4 +1,4 @@ -#include "bitbots_utils/utils.hpp" +#include namespace bitbots_utils { diff --git a/bitbots_misc/system_monitor/package.xml b/bitbots_misc/system_monitor/package.xml index 46545bde4..4284ff58c 100644 --- a/bitbots_misc/system_monitor/package.xml +++ b/bitbots_misc/system_monitor/package.xml @@ -11,7 +11,7 @@ Hamburg Bit-Bots MIT - + Finn-Thorben Sell ament_cmake @@ -21,7 +21,10 @@ rclpy bitbots_msgs - ament_python + python3-pytest + + + ament_python - + diff --git a/bitbots_misc/system_monitor/setup.py b/bitbots_misc/system_monitor/setup.py index eb10b08e6..0de29d43a 100644 --- a/bitbots_misc/system_monitor/setup.py +++ b/bitbots_misc/system_monitor/setup.py @@ -6,7 +6,7 @@ setup( name=package_name, - packages=find_packages(), + packages=find_packages(exclude=["test"]), data_files=[ ("share/" + package_name, ["package.xml"]), ("share/ament_index/resource_index/packages", ["resource/" + package_name]), @@ -18,6 +18,7 @@ install_requires=[ "setuptools", ], + tests_require=["pytest"], entry_points={ "console_scripts": [ "monitor = system_monitor.monitor:main", diff --git a/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/animation_recording.py b/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/animation_recording.py index 075036004..24c5fe077 100644 --- a/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/animation_recording.py +++ b/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/animation_recording.py @@ -240,7 +240,7 @@ def save_animation(self, path: str, file_name: Optional[str] = None) -> str: with open(path, "w") as fp: json.dump(animation_dict, fp, sort_keys=True, indent=4) - return "Saving to '%s'" % path + ". Done." + return f"Saving to '{path}'. Done." def load_animation(self, path: str) -> Optional[str]: """Record command, load a animation '.json' file @@ -298,9 +298,9 @@ def play(self, from_frame: int = 0, until_frame: int = -1) -> tuple[str, bool]: else: # Check if the given frame id is in bounds assert until_frame > 0, "Upper bound must be positive" - assert until_frame <= len( - self.current_state.key_frames - ), "Upper bound must be less than or equal to the number of frames" + assert until_frame <= len(self.current_state.key_frames), ( + "Upper bound must be less than or equal to the number of frames" + ) assert from_frame >= 0, "Lower bound must be positive" # Create name for the temporary animation that is send to the animation server diff --git a/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/utils.py b/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/utils.py index 6217bed78..688a2c8be 100644 --- a/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/utils.py +++ b/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/utils.py @@ -21,8 +21,8 @@ def dropEvent(self, e): # noqa: N802 # fmt: on super().dropEvent(e) items = [] - for i in range(0, self.count()): - items.append(self.item(i).text()) + for i in range(self.count()): + items.append(self.item(i).text()) # type: ignore[union-attr] self.frame_order_callback(items) # fmt: off diff --git a/bitbots_motion/bitbots_animation_rqt/package.xml b/bitbots_motion/bitbots_animation_rqt/package.xml index f8af2aefb..2801efdac 100644 --- a/bitbots_motion/bitbots_animation_rqt/package.xml +++ b/bitbots_motion/bitbots_animation_rqt/package.xml @@ -23,6 +23,8 @@ std_srvs ament_mypy + python3-pytest + diff --git a/bitbots_motion/bitbots_animation_rqt/setup.py b/bitbots_motion/bitbots_animation_rqt/setup.py index 45e680dd3..639dc194a 100644 --- a/bitbots_motion/bitbots_animation_rqt/setup.py +++ b/bitbots_motion/bitbots_animation_rqt/setup.py @@ -4,7 +4,7 @@ setup( name=package_name, - packages=find_packages(), + packages=find_packages(exclude=["test"]), data_files=[ ("share/" + package_name + "/resource", ["resource/RecordUI.ui"]), ("share/ament_index/resource_index/packages", ["resource/" + package_name]), @@ -12,8 +12,8 @@ ("share/" + package_name, ["plugin.xml"]), ], install_requires=["setuptools"], - zip_safe=True, tests_require=["pytest"], + zip_safe=True, entry_points={ "console_scripts": [ "animation_gui = " + package_name + ".record_ui:main", diff --git a/bitbots_motion/bitbots_animation_server/bitbots_animation_server/resource_manager.py b/bitbots_motion/bitbots_animation_server/bitbots_animation_server/resource_manager.py index 315f23466..262d5f775 100644 --- a/bitbots_motion/bitbots_animation_server/bitbots_animation_server/resource_manager.py +++ b/bitbots_motion/bitbots_animation_server/bitbots_animation_server/resource_manager.py @@ -71,12 +71,8 @@ def search(self, path, folders, filename=""): path = next_path if not folders: - return OSError( - "Resource '%s' not found. folders was empty, \ - only filename provided" - % (filename) - ) - return OSError("Resource '%s' not found" % (str(folders) + filename)) + return OSError(f"Resource '{filename}' not found. folders was empty, only filename provided") + return OSError(f"Resource '{str(folders) + filename}' not found") def find(self, name, filename=""): """ @@ -115,7 +111,7 @@ def find_animation(self, name): should be given without ``.json``. path = find_animation('walkready') """ - return self.find(self.animpath, "%s.json" % name) + return self.find(self.animpath, f"{name}.json") def find_resource(self, name): """Finds a resource relative to self.basepath""" diff --git a/bitbots_motion/bitbots_animation_server/package.xml b/bitbots_motion/bitbots_animation_server/package.xml index a1e94693e..3b00445bf 100644 --- a/bitbots_motion/bitbots_animation_server/package.xml +++ b/bitbots_motion/bitbots_animation_server/package.xml @@ -23,6 +23,8 @@ std_msgs ament_mypy + python3-pytest + tested_integration diff --git a/bitbots_motion/bitbots_animation_server/setup.py b/bitbots_motion/bitbots_animation_server/setup.py index 7a1b78643..c41689c5f 100644 --- a/bitbots_motion/bitbots_animation_server/setup.py +++ b/bitbots_motion/bitbots_animation_server/setup.py @@ -18,10 +18,10 @@ "launch", "setuptools", ], + tests_require=["pytest"], zip_safe=True, keywords=["ROS"], license="MIT", - tests_require=["pytest"], entry_points={ "console_scripts": [ "animation_node = bitbots_animation_server.animation_node:main", diff --git a/bitbots_motion/bitbots_dynamic_kick/CMakeLists.txt b/bitbots_motion/bitbots_dynamic_kick/CMakeLists.txt index e9ca70b50..fa4fccec7 100644 --- a/bitbots_motion/bitbots_dynamic_kick/CMakeLists.txt +++ b/bitbots_motion/bitbots_dynamic_kick/CMakeLists.txt @@ -17,7 +17,6 @@ find_package(biped_interfaces REQUIRED) find_package(bitbots_docs REQUIRED) find_package(bitbots_msgs REQUIRED) find_package(bitbots_splines REQUIRED) -find_package(control_msgs REQUIRED) find_package(control_toolbox REQUIRED) find_package(Eigen3 REQUIRED) find_package(geometry_msgs REQUIRED) @@ -32,7 +31,7 @@ find_package(tf2_eigen REQUIRED) find_package(tf2_geometry_msgs REQUIRED) find_package(tf2_ros REQUIRED) -find_package(PythonLibs COMPONENTS Interpreter Development) +find_package(Python3 COMPONENTS Interpreter Development) rosidl_generate_interfaces(${PROJECT_NAME} "msg/KickDebug.msg" DEPENDENCIES std_msgs geometry_msgs Python3) @@ -53,7 +52,6 @@ ament_target_dependencies( biped_interfaces bitbots_msgs bitbots_splines - control_msgs control_toolbox geometry_msgs moveit_ros_planning_interface @@ -76,7 +74,7 @@ target_link_libraries(KickNode "${cpp_typesupport_target}") # pybind11_add_module(py_dynamic_kick SHARED src/walk_pywrapper.cpp ${SOURCES}) # ament_target_dependencies(py_dynamic_kick PUBLIC ament_cmake biped_interfaces -# bitbots_msgs bitbots_splines control_msgs control_toolbox geometry_msgs +# bitbots_msgs bitbots_splines control_toolbox geometry_msgs # moveit_ros_planning_interface rclcpp ros2_python_extension rot_conv # sensor_msgs std_msgs tf2 tf2_eigen tf2_geometry_msgs tf2_ros) # target_link_libraries(py_dynamic_kick PRIVATE "${cpp_typesupport_target}") diff --git a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_engine.hpp b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_engine.hpp index b9d9c1e50..87dd56cd4 100644 --- a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_engine.hpp +++ b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_engine.hpp @@ -2,9 +2,6 @@ #define BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_KICK_ENGINE_H_ #include -#include -#include -#include #include #include @@ -13,6 +10,9 @@ #include #include #include +#include +#include +#include #include #include diff --git a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_ik.hpp b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_ik.hpp index 894a05bd9..1cd86bacc 100644 --- a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_ik.hpp +++ b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_ik.hpp @@ -1,18 +1,17 @@ #ifndef BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_KICK_IK_H_ #define BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_KICK_IK_H_ -#include -#include - #include #include #include +#include +#include namespace bitbots_dynamic_kick { class KickIK : public bitbots_splines::AbstractIK { public: - KickIK() = default; + KickIK() : legs_joints_group_(), left_leg_joints_group_(), right_leg_joints_group_(){}; void init(moveit::core::RobotModelPtr kinematic_model) override; bitbots_splines::JointGoals calculate(const KickPositions &positions) override; void reset() override; diff --git a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_node.hpp b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_node.hpp index 926c23a90..70214945c 100644 --- a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_node.hpp +++ b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_node.hpp @@ -1,7 +1,6 @@ #ifndef BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_KICK_NODE_H_ #define BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_KICK_NODE_H_ -#include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include namespace bitbots_dynamic_kick { diff --git a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_pywrapper.hpp b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_pywrapper.hpp index 5336cb7b5..1cc5083a3 100644 --- a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_pywrapper.hpp +++ b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/kick_pywrapper.hpp @@ -2,13 +2,13 @@ #define BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_KICK_PYWRAPPER_H_ #include -#include #include #include #include #include #include +#include #include #include diff --git a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/stabilizer.hpp b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/stabilizer.hpp index 2878dc286..3eac1d78a 100644 --- a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/stabilizer.hpp +++ b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/stabilizer.hpp @@ -1,12 +1,12 @@ #ifndef BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_STABILIZER_H_ #define BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_STABILIZER_H_ -#include #include #include #include #include +#include #include #include "kick_utils.hpp" diff --git a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/visualizer.hpp b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/visualizer.hpp index 5471d9b91..7f0170fef 100644 --- a/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/visualizer.hpp +++ b/bitbots_motion/bitbots_dynamic_kick/include/bitbots_dynamic_kick/visualizer.hpp @@ -5,10 +5,6 @@ #ifndef BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_VISUALIZER_H_ #define BITBOTS_DYNAMIC_KICK_INCLUDE_BITBOTS_DYNAMIC_KICK_VISUALIZER_H_ -#include -#include -#include - #include #include #include @@ -16,8 +12,11 @@ #include #include #include +#include #include #include +#include +#include #include #include diff --git a/bitbots_motion/bitbots_dynamic_kick/src/kick_engine.cpp b/bitbots_motion/bitbots_dynamic_kick/src/kick_engine.cpp index b09847137..679d79739 100644 --- a/bitbots_motion/bitbots_dynamic_kick/src/kick_engine.cpp +++ b/bitbots_motion/bitbots_dynamic_kick/src/kick_engine.cpp @@ -1,5 +1,4 @@ -#include "bitbots_dynamic_kick/kick_engine.hpp" - +#include #include namespace bitbots_dynamic_kick { diff --git a/bitbots_motion/bitbots_dynamic_kick/src/kick_ik.cpp b/bitbots_motion/bitbots_dynamic_kick/src/kick_ik.cpp index a562c2da6..a44013df1 100644 --- a/bitbots_motion/bitbots_dynamic_kick/src/kick_ik.cpp +++ b/bitbots_motion/bitbots_dynamic_kick/src/kick_ik.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynamic_kick/kick_ik.hpp" +#include namespace bitbots_dynamic_kick { diff --git a/bitbots_motion/bitbots_dynamic_kick/src/kick_node.cpp b/bitbots_motion/bitbots_dynamic_kick/src/kick_node.cpp index 89d85824f..9b47bd922 100644 --- a/bitbots_motion/bitbots_dynamic_kick/src/kick_node.cpp +++ b/bitbots_motion/bitbots_dynamic_kick/src/kick_node.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynamic_kick/kick_node.hpp" +#include namespace bitbots_dynamic_kick { using namespace std::chrono_literals; diff --git a/bitbots_motion/bitbots_dynamic_kick/src/stabilizer.cpp b/bitbots_motion/bitbots_dynamic_kick/src/stabilizer.cpp index e78689de6..d74688364 100644 --- a/bitbots_motion/bitbots_dynamic_kick/src/stabilizer.cpp +++ b/bitbots_motion/bitbots_dynamic_kick/src/stabilizer.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynamic_kick/stabilizer.hpp" +#include namespace bitbots_dynamic_kick { @@ -23,8 +23,8 @@ Stabilizer::Stabilizer(std::string ns) { pid_trunk_fused_pitch_ = std::make_shared(pitch_node_, ""); pid_trunk_fused_roll_ = std::make_shared(roll_node_, ""); - pid_trunk_fused_pitch_->initPid(); - pid_trunk_fused_roll_->initPid(); + pid_trunk_fused_pitch_->initialize_from_ros_parameters(); + pid_trunk_fused_roll_->initialize_from_ros_parameters(); reset(); } @@ -51,8 +51,8 @@ KickPositions Stabilizer::stabilize(const KickPositions &positions, const rclcpp cop_x_error = cop_x - positions.trunk_pose.translation().x(); cop_y_error = cop_y - positions.trunk_pose.translation().y(); - double x_correction = pid_trunk_fused_roll_->computeCommand(cop_x_error, dt); - double y_correction = pid_trunk_fused_pitch_->computeCommand(cop_y_error, dt); + double x_correction = pid_trunk_fused_roll_->compute_command(cop_x_error, dt); + double y_correction = pid_trunk_fused_pitch_->compute_command(cop_y_error, dt); stabilized_positions.trunk_pose.translation().x() += x_correction; stabilized_positions.trunk_pose.translation().y() += y_correction; diff --git a/bitbots_motion/bitbots_dynamic_kick/src/visualizer.cpp b/bitbots_motion/bitbots_dynamic_kick/src/visualizer.cpp index 266243737..69f3d3103 100644 --- a/bitbots_motion/bitbots_dynamic_kick/src/visualizer.cpp +++ b/bitbots_motion/bitbots_dynamic_kick/src/visualizer.cpp @@ -1,5 +1,4 @@ -#include "bitbots_dynamic_kick/visualizer.hpp" - +#include #include namespace bitbots_dynamic_kick { diff --git a/bitbots_motion/bitbots_dynup/CMakeLists.txt b/bitbots_motion/bitbots_dynup/CMakeLists.txt index e64bcbc9c..863b2d722 100644 --- a/bitbots_motion/bitbots_dynup/CMakeLists.txt +++ b/bitbots_motion/bitbots_dynup/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.9) project(bitbots_dynup) # Add support for C++20 @@ -6,6 +6,17 @@ if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 20) endif() +# Include CheckIPOSupported module +include(CheckIPOSupported) + +# Check if IPO is supported +check_ipo_supported(RESULT ipo_supported) +if(ipo_supported) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + # Set the number of parallel LTO jobs + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=4") +endif() + # Build with release optimizations and debug symbols by default if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebug) @@ -20,7 +31,6 @@ find_package(bio_ik REQUIRED) find_package(bitbots_msgs REQUIRED) find_package(bitbots_splines REQUIRED) find_package(bitbots_utils REQUIRED) -find_package(control_msgs REQUIRED) find_package(control_toolbox REQUIRED) find_package(Eigen3 REQUIRED) find_package(generate_parameter_library REQUIRED) @@ -36,10 +46,11 @@ find_package(tf2_eigen REQUIRED) find_package(tf2_geometry_msgs REQUIRED) find_package(tf2_ros REQUIRED) -find_package(ros2_python_extension REQUIRED) find_package(pybind11 REQUIRED) find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +find_package(ros2_python_extension REQUIRED) + generate_parameter_library(dynup_parameters config/dynup_config.yaml) rosidl_generate_interfaces( @@ -53,7 +64,6 @@ rosidl_generate_interfaces( include_directories(include ${PYTHON_INCLUDE_DIRS}) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) add_compile_options(-Wall -Werror -Wno-unused -fPIC) set(SOURCES @@ -74,7 +84,6 @@ ament_target_dependencies( bitbots_msgs bitbots_splines bitbots_utils - control_msgs control_toolbox generate_parameter_library geometry_msgs @@ -105,7 +114,6 @@ ament_target_dependencies( bitbots_msgs bitbots_splines bitbots_utils - control_msgs control_toolbox geometry_msgs moveit_ros_planning_interface diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_engine.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_engine.hpp index 9710d6138..5a04b90d7 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_engine.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_engine.hpp @@ -1,8 +1,7 @@ #ifndef BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_ENGINE_H_ #define BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_ENGINE_H_ -#include - +#include #include #include #include @@ -12,10 +11,10 @@ #include #include #include +#include #include #include -#include "dynup_parameters.hpp" #include "dynup_stabilizer.hpp" namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_ik.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_ik.hpp index 50a8a6b3b..f14e95c86 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_ik.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_ik.hpp @@ -1,16 +1,15 @@ #ifndef BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_IK_H_ #define BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_IK_H_ -#include -#include -#include -#include - +#include +#include #include +#include +#include #include +#include #include -#include "dynup_parameters.hpp" #include "dynup_utils.hpp" namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_node.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_node.hpp index 9111452a8..028b35f43 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_node.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_node.hpp @@ -1,40 +1,39 @@ #ifndef BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_NODE_H_ #define BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_NODE_H_ -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include +#include +#include #include #include #include #include #include #include +#include +#include +#include #include #include #include +#include #include #include #include +#include +#include +#include +#include #include #include -#include "bitbots_dynup/dynup_engine.hpp" -#include "bitbots_dynup/dynup_ik.hpp" -#include "bitbots_dynup/dynup_stabilizer.hpp" -#include "bitbots_dynup/visualizer.hpp" -#include "bitbots_msgs/action/dynup.hpp" -#include "dynup_parameters.hpp" -#include "rclcpp_action/rclcpp_action.hpp" - namespace bitbots_dynup { using DynupGoal = bitbots_msgs::action::Dynup; using DynupGoalHandle = rclcpp_action::ServerGoalHandle; diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_pywrapper.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_pywrapper.hpp index 5a3bc0532..82fe8a14e 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_pywrapper.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_pywrapper.hpp @@ -4,14 +4,13 @@ #include #include +#include +#include #include #include #include #include -#include "bitbots_dynup/dynup_node.hpp" -#include "bitbots_dynup/dynup_utils.hpp" - namespace py = pybind11; using namespace ros2_python_extension; diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_stabilizer.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_stabilizer.hpp index 6c461c892..d4d2b861f 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_stabilizer.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_stabilizer.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -11,7 +12,6 @@ #include #include -#include "dynup_parameters.hpp" #include "dynup_utils.hpp" namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_utils.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_utils.hpp index f2f7bdf50..abbe41380 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_utils.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/dynup_utils.hpp @@ -1,11 +1,10 @@ #ifndef BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_UTILS_H_ #define BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_DYNUP_UTILS_H_ -#include - #include #include #include +#include namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/visualizer.hpp b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/visualizer.hpp index 12078bb70..35a8195dd 100644 --- a/bitbots_motion/bitbots_dynup/include/bitbots_dynup/visualizer.hpp +++ b/bitbots_motion/bitbots_dynup/include/bitbots_dynup/visualizer.hpp @@ -1,10 +1,7 @@ #ifndef BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_VISUALIZER_H_ #define BITBOTS_DYNUP_INCLUDE_BITBOTS_DYNUP_VISUALIZER_H_ -#include -#include -#include - +#include #include #include #include @@ -12,13 +9,14 @@ #include #include #include +#include +#include #include #include +#include #include #include -#include "dynup_parameters.hpp" - namespace bitbots_dynup { class Visualizer : bitbots_splines::AbstractVisualizer { diff --git a/bitbots_motion/bitbots_dynup/src/dynup_engine.cpp b/bitbots_motion/bitbots_dynup/src/dynup_engine.cpp index be90f21e8..157c32631 100644 --- a/bitbots_motion/bitbots_dynup/src/dynup_engine.cpp +++ b/bitbots_motion/bitbots_dynup/src/dynup_engine.cpp @@ -1,5 +1,4 @@ -#include "bitbots_dynup/dynup_engine.hpp" - +#include #include namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_dynup/src/dynup_node.cpp b/bitbots_motion/bitbots_dynup/src/dynup_node.cpp index f05953faf..a37f009f3 100644 --- a/bitbots_motion/bitbots_dynup/src/dynup_node.cpp +++ b/bitbots_motion/bitbots_dynup/src/dynup_node.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynup/dynup_node.hpp" +#include namespace bitbots_dynup { using namespace std::chrono_literals; diff --git a/bitbots_motion/bitbots_dynup/src/dynup_pywrapper.cpp b/bitbots_motion/bitbots_dynup/src/dynup_pywrapper.cpp index 8062bdb82..0ceb2aa34 100644 --- a/bitbots_motion/bitbots_dynup/src/dynup_pywrapper.cpp +++ b/bitbots_motion/bitbots_dynup/src/dynup_pywrapper.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynup/dynup_pywrapper.hpp" +#include PyDynupWrapper::PyDynupWrapper(const std::string ns) { // initialize rclcpp if not already done diff --git a/bitbots_motion/bitbots_dynup/src/dynup_stabilizer.cpp b/bitbots_motion/bitbots_dynup/src/dynup_stabilizer.cpp index e1e33c7f5..92cb29805 100644 --- a/bitbots_motion/bitbots_dynup/src/dynup_stabilizer.cpp +++ b/bitbots_motion/bitbots_dynup/src/dynup_stabilizer.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynup/dynup_stabilizer.hpp" +#include namespace bitbots_dynup { @@ -6,8 +6,8 @@ Stabilizer::Stabilizer(rclcpp::Node::SharedPtr node, bitbots_dynup::Params::Stab : params_(params), pid_trunk_pitch_(node, "stabilizer.trunk_pid.pitch"), pid_trunk_roll_(node, "stabilizer.trunk_pid.roll") { - pid_trunk_pitch_.initPid(); - pid_trunk_roll_.initPid(); + pid_trunk_pitch_.initialize_from_ros_parameters(); + pid_trunk_roll_.initialize_from_ros_parameters(); reset(); } @@ -43,8 +43,8 @@ DynupResponse Stabilizer::stabilize(const DynupResponse &ik_goals, const rclcpp: // Adapt trunk based on PID controller goal_fused.fusedPitch += - pid_trunk_pitch_.computeCommand(goal_fused.fusedPitch - current_orientation.fusedPitch, dt); - goal_fused.fusedRoll += pid_trunk_roll_.computeCommand(goal_fused.fusedRoll - current_orientation.fusedRoll, dt); + pid_trunk_pitch_.compute_command(goal_fused.fusedPitch - current_orientation.fusedPitch, dt); + goal_fused.fusedRoll += pid_trunk_roll_.compute_command(goal_fused.fusedRoll - current_orientation.fusedRoll, dt); // Check if the trunk is stable, meaning it isn't leaning too much // TODO it would be better to use the rotational velocity of the imu to determine stability diff --git a/bitbots_motion/bitbots_dynup/src/dynup_utils.cpp b/bitbots_motion/bitbots_dynup/src/dynup_utils.cpp index 6cf758090..b7a54e703 100644 --- a/bitbots_motion/bitbots_dynup/src/dynup_utils.cpp +++ b/bitbots_motion/bitbots_dynup/src/dynup_utils.cpp @@ -1,4 +1,4 @@ -#include "bitbots_dynup/dynup_utils.hpp" +#include namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_dynup/src/visualizer.cpp b/bitbots_motion/bitbots_dynup/src/visualizer.cpp index 07bbaaf30..5228b28e5 100644 --- a/bitbots_motion/bitbots_dynup/src/visualizer.cpp +++ b/bitbots_motion/bitbots_dynup/src/visualizer.cpp @@ -1,5 +1,4 @@ -#include "bitbots_dynup/visualizer.hpp" - +#include #include namespace bitbots_dynup { diff --git a/bitbots_motion/bitbots_hcm/CMakeLists.txt b/bitbots_motion/bitbots_hcm/CMakeLists.txt index 4fd72f3cd..c23b259af 100644 --- a/bitbots_motion/bitbots_hcm/CMakeLists.txt +++ b/bitbots_motion/bitbots_hcm/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(bitbots_hcm) # Build with release optimizations and debug symbols by default @@ -16,8 +16,7 @@ find_package(bitbots_msgs REQUIRED) find_package(builtin_interfaces REQUIRED) find_package(geometry_msgs REQUIRED) find_package(pybind11 REQUIRED) -find_package(Python3 REQUIRED) -find_package(PythonLibs REQUIRED) +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) find_package(rclpy REQUIRED) find_package(ros2_python_extension REQUIRED) find_package(sensor_msgs REQUIRED) @@ -44,7 +43,7 @@ ament_target_dependencies( sensor_msgs std_msgs) -target_link_libraries(HCM ${PYTHON_LIBRARIES}) +target_link_libraries(HCM Python3::Python) enable_bitbots_docs() diff --git a/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/play_animation.py b/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/play_animation.py index 882ae4624..a9bc34640 100644 --- a/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/play_animation.py +++ b/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/play_animation.py @@ -88,9 +88,9 @@ def animation_feedback_cb(self, msg): self.publish_debug_data("Animation Percent Done", str(feedback.percent_done)) def animation_finished(self): - assert ( - self.blackboard.animation_action_current_goal is not None - ), "No animation action goal set, so we cannot check if it is finished" + assert self.blackboard.animation_action_current_goal is not None, ( + "No animation action goal set, so we cannot check if it is finished" + ) return ( self.blackboard.animation_action_current_goal.done() and self.blackboard.animation_action_current_goal.result().status @@ -248,9 +248,9 @@ def animation_feedback_cb(self, msg): self.publish_debug_data("Dynup Percent Done", str(feedback.percent_done)) def animation_finished(self): - assert ( - self.blackboard.dynup_action_current_goal is not None - ), "No dynup action goal set, so we cannot check if it is finished" + assert self.blackboard.dynup_action_current_goal is not None, ( + "No dynup action goal set, so we cannot check if it is finished" + ) return ( self.blackboard.dynup_action_current_goal.done() and self.blackboard.dynup_action_current_goal.result().status diff --git a/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/wait_for.py b/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/wait_for.py index 25705eac8..b8ddd4d91 100644 --- a/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/wait_for.py +++ b/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/wait_for.py @@ -52,6 +52,6 @@ class WaitForMotors(AbstractHCMActionElement): def perform(self, reevaluate=False): self.blackboard.node.get_logger().warn( - "HCM gets no data from the motors (/joint_states). Waiting for the motors to " "connect.", + "HCM gets no data from the motors (/joint_states). Waiting for the motors to connect.", throttle_duration_sec=10, ) diff --git a/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/decisions/animation.py b/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/decisions/animation.py index c7072a5c0..99d94e234 100644 --- a/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/decisions/animation.py +++ b/bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/decisions/animation.py @@ -29,9 +29,9 @@ def perform(self, reevaluate=False): # We can safely assume that the last animation start time is set because the animation is running # Calculate time since last animation start - assert ( - self.blackboard.last_animation_start_time is not None - ), "Last animation start time is not set, this should be impossible" + assert self.blackboard.last_animation_start_time is not None, ( + "Last animation start time is not set, this should be impossible" + ) time_delta_since_last_animation_start = ( self.blackboard.node.get_clock().now().nanoseconds / 1e9 - self.blackboard.last_animation_start_time.nanoseconds / 1e9 diff --git a/bitbots_motion/bitbots_hcm/src/hcm.cpp b/bitbots_motion/bitbots_hcm/src/hcm.cpp index 4e36e3f11..c0295ba36 100644 --- a/bitbots_motion/bitbots_hcm/src/hcm.cpp +++ b/bitbots_motion/bitbots_hcm/src/hcm.cpp @@ -1,22 +1,21 @@ #include +#include +#include +#include +#include +#include #include +#include #include #include #include #include +#include +#include +#include #include -#include "bitbots_msgs/msg/animation.hpp" -#include "bitbots_msgs/msg/foot_pressure.hpp" -#include "bitbots_msgs/msg/joint_command.hpp" -#include "bitbots_msgs/msg/robot_control_state.hpp" -#include "builtin_interfaces/msg/time.hpp" -#include "geometry_msgs/msg/point_stamped.hpp" -#include "sensor_msgs/msg/imu.hpp" -#include "sensor_msgs/msg/joint_state.hpp" -#include "std_msgs/msg/header.hpp" - using std::placeholders::_1; namespace py = pybind11; namespace bitbots_hcm { diff --git a/bitbots_motion/bitbots_head_mover/CMakeLists.txt b/bitbots_motion/bitbots_head_mover/CMakeLists.txt index eafa503d9..d4f3f7cfa 100644 --- a/bitbots_motion/bitbots_head_mover/CMakeLists.txt +++ b/bitbots_motion/bitbots_head_mover/CMakeLists.txt @@ -27,8 +27,6 @@ find_package(std_msgs REQUIRED) find_package(tf2_geometry_msgs REQUIRED) find_package(tf2_ros REQUIRED) -# uncomment the following section in order to fill in further dependencies -# manually. find_package( REQUIRED) generate_parameter_library( head_parameters # cmake target name for the parameter library config/head_config.yml) diff --git a/bitbots_motion/bitbots_head_mover/src/move_head.cpp b/bitbots_motion/bitbots_head_mover/src/move_head.cpp index 1a03edde7..01758e2eb 100644 --- a/bitbots_motion/bitbots_head_mover/src/move_head.cpp +++ b/bitbots_motion/bitbots_head_mover/src/move_head.cpp @@ -1,13 +1,9 @@ -#include -#include -#include -#include -#include -#include #include #include +#include #include +#include #include #include #include @@ -17,6 +13,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -26,11 +26,10 @@ #include #include #include +#include #include #include -#include "head_parameters.hpp" - using std::placeholders::_1; using namespace std::chrono_literals; @@ -648,7 +647,7 @@ class HeadMover { * @param tilt The current tilt position * @return int The index of the pattern keypoint that is closest to the current head position */ - int get_near_pattern_position(std::vector> pattern, double pan, double tilt) { + int get_near_pattern_position(const std::vector>& pattern, double pan, double tilt) { // Store the index and distance of the closest keypoint std::pair min_distance_point = {10000.0, -1}; // Iterate over all keypoints and calculate the distance to the current head position diff --git a/bitbots_motion/bitbots_moveit_bindings/CMakeLists.txt b/bitbots_motion/bitbots_moveit_bindings/CMakeLists.txt index 4d90c35e7..6693eb350 100644 --- a/bitbots_motion/bitbots_moveit_bindings/CMakeLists.txt +++ b/bitbots_motion/bitbots_moveit_bindings/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.9) project(bitbots_moveit_bindings) # Add support for C++17 @@ -6,6 +6,17 @@ if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) endif() +# Include CheckIPOSupported module +include(CheckIPOSupported) + +# Check if IPO is supported +check_ipo_supported(RESULT ipo_supported) +if(ipo_supported) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + # Set the number of parallel LTO jobs + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=4") +endif() + # Build with release optimizations and debug symbols by default if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebug) diff --git a/bitbots_motion/bitbots_moveit_bindings/src/bitbots_moveit_bindings.cpp b/bitbots_motion/bitbots_moveit_bindings/src/bitbots_moveit_bindings.cpp index e4b7ebd41..3507e0d16 100644 --- a/bitbots_motion/bitbots_moveit_bindings/src/bitbots_moveit_bindings.cpp +++ b/bitbots_motion/bitbots_moveit_bindings/src/bitbots_moveit_bindings.cpp @@ -1,26 +1,25 @@ -#include -#include -#include -#include -#include #include #include -#include +#include #include #include +#include +#include +#include +#include #include #include #include #include +#include #include #include #include #include #include +#include #include - -#include "rcl_interfaces/srv/get_parameters.hpp" namespace py = pybind11; using namespace std::chrono_literals; using std::placeholders::_1; @@ -315,15 +314,15 @@ class BitbotsMoveitBindings { ik_options.goals.emplace_back(new bio_ik::LineGoal(m.link_name, p(m.position), p(m.direction), w(m.weight))); } - for (auto& m : ik_request.avoid_joint_limits_goals) { + for (const auto& m : ik_request.avoid_joint_limits_goals) { ik_options.goals.emplace_back(new bio_ik::AvoidJointLimitsGoal(w(m.weight), !m.primary)); } - for (auto& m : ik_request.minimal_displacement_goals) { + for (const auto& m : ik_request.minimal_displacement_goals) { ik_options.goals.emplace_back(new bio_ik::MinimalDisplacementGoal(w(m.weight), !m.primary)); } - for (auto& m : ik_request.center_joints_goals) { + for (const auto& m : ik_request.center_joints_goals) { ik_options.goals.emplace_back(new bio_ik::CenterJointsGoal(w(m.weight), !m.primary)); } diff --git a/bitbots_motion/bitbots_quintic_walk/CMakeLists.txt b/bitbots_motion/bitbots_quintic_walk/CMakeLists.txt index 818f1d42a..26c03b7a1 100644 --- a/bitbots_motion/bitbots_quintic_walk/CMakeLists.txt +++ b/bitbots_motion/bitbots_quintic_walk/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.9) project(bitbots_quintic_walk) # Add support for C++20 @@ -6,6 +6,17 @@ if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 20) endif() +# Include CheckIPOSupported module +include(CheckIPOSupported) + +# Check if IPO is supported +check_ipo_supported(RESULT ipo_supported) +if(ipo_supported) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + # Set the number of parallel LTO jobs + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=4") +endif() + # Build with release optimizations and debug symbols by default if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebug) @@ -13,12 +24,12 @@ endif() set(PYBIND11_PYTHON_VERSION 3) set(PYBIND11_FINDPYTHON ON) + find_package(ament_cmake REQUIRED) find_package(backward_ros REQUIRED) find_package(biped_interfaces REQUIRED) find_package(bitbots_msgs REQUIRED) find_package(bitbots_splines REQUIRED) -find_package(control_msgs REQUIRED) find_package(control_toolbox REQUIRED) find_package(generate_parameter_library REQUIRED) find_package(geometry_msgs REQUIRED) @@ -34,20 +45,16 @@ find_package(tf2_eigen REQUIRED) find_package(tf2_geometry_msgs REQUIRED) find_package(tf2_ros REQUIRED) -find_package(ros2_python_extension REQUIRED) find_package(pybind11 REQUIRED) find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +find_package(ros2_python_extension REQUIRED) + generate_parameter_library(bitbots_quintic_walk_parameters src/parameters.yaml) rosidl_generate_interfaces( - ${PROJECT_NAME} - "msg/WalkDebug.msg" - "msg/WalkEngineDebug.msg" - DEPENDENCIES - std_msgs - geometry_msgs - Python3) + ${PROJECT_NAME} "msg/WalkDebug.msg" "msg/WalkEngineDebug.msg" DEPENDENCIES + std_msgs geometry_msgs) include_directories(include ${PYTHON_INCLUDE_DIRS}) @@ -65,7 +72,6 @@ ament_target_dependencies( biped_interfaces bitbots_msgs bitbots_splines - control_msgs control_toolbox geometry_msgs moveit_ros_planning_interface @@ -94,7 +100,6 @@ ament_target_dependencies( biped_interfaces bitbots_msgs bitbots_splines - control_msgs control_toolbox geometry_msgs moveit_ros_planning_interface diff --git a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_engine.hpp b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_engine.hpp index a57676d96..5b9cf96cd 100644 --- a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_engine.hpp +++ b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_engine.hpp @@ -6,16 +6,14 @@ The original files can be found at: #ifndef BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_ENGINE_H_ #define BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_ENGINE_H_ -#include -#include - +#include +#include +#include +#include +#include #include - -#include "bitbots_quintic_walk/walk_utils.hpp" -#include "bitbots_quintic_walk_parameters.hpp" -#include "bitbots_splines/abstract_engine.hpp" -#include "bitbots_splines/pose_spline.hpp" -#include "bitbots_splines/smooth_spline.hpp" +#include +#include namespace bitbots_quintic_walk { diff --git a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_ik.hpp b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_ik.hpp index 806943bfd..20da32c54 100644 --- a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_ik.hpp +++ b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_ik.hpp @@ -1,12 +1,10 @@ #ifndef BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_IK_H_ #define BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_IK_H_ -#include - +#include +#include +#include +#include #include - -#include "bitbots_quintic_walk/walk_utils.hpp" -#include "bitbots_quintic_walk_parameters.hpp" -#include "bitbots_splines/abstract_ik.hpp" namespace bitbots_quintic_walk { class WalkIK : public bitbots_splines::AbstractIK { diff --git a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_node.hpp b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_node.hpp index ad2da928c..9b847ba28 100644 --- a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_node.hpp +++ b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_node.hpp @@ -6,17 +6,20 @@ The original files can be found at: #ifndef BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_NODE_H_ #define BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_NODE_H_ -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -24,6 +27,9 @@ The original files can be found at: #include #include #include +#include +#include +#include #include #include #include @@ -35,20 +41,13 @@ The original files can be found at: #include #include #include +#include +#include +#include +#include #include #include -#include "biped_interfaces/msg/phase.hpp" -#include "bitbots_msgs/msg/foot_pressure.hpp" -#include "bitbots_msgs/msg/joint_command.hpp" -#include "bitbots_msgs/msg/robot_control_state.hpp" -#include "bitbots_quintic_walk/walk_engine.hpp" -#include "bitbots_quintic_walk/walk_ik.hpp" -#include "bitbots_quintic_walk/walk_stabilizer.hpp" -#include "bitbots_quintic_walk/walk_visualizer.hpp" -#include "bitbots_quintic_walk_parameters.hpp" -#include "bitbots_splines/abstract_ik.hpp" - namespace bitbots_quintic_walk { class WalkNode { diff --git a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_pywrapper.hpp b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_pywrapper.hpp index 258689f77..2436bd40d 100644 --- a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_pywrapper.hpp +++ b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_pywrapper.hpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -15,9 +17,6 @@ #include #include -#include "bitbots_quintic_walk/walk_node.hpp" -#include "bitbots_quintic_walk/walk_utils.hpp" - namespace py = pybind11; using namespace ros2_python_extension; diff --git a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_stabilizer.hpp b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_stabilizer.hpp index 9ca5c46e9..7b5387833 100644 --- a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_stabilizer.hpp +++ b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_stabilizer.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -11,9 +12,6 @@ #include #include -#include "bitbots_quintic_walk/walk_utils.hpp" -#include "bitbots_splines/abstract_stabilizer.hpp" - namespace bitbots_quintic_walk { class WalkStabilizer : public bitbots_splines::AbstractStabilizer { diff --git a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_visualizer.hpp b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_visualizer.hpp index 490296fab..df7f38cbe 100644 --- a/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_visualizer.hpp +++ b/bitbots_motion/bitbots_quintic_walk/include/bitbots_quintic_walk/walk_visualizer.hpp @@ -1,25 +1,23 @@ #ifndef BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_VISUALIZER_H_ #define BITBOTS_QUINTIC_WALK_INCLUDE_BITBOTS_QUINTIC_WALK_WALK_VISUALIZER_H_ -#include -#include -#include -#include -#include - +#include +#include #include #include +#include +#include +#include #include #include #include +#include +#include +#include +#include #include #include -#include "bitbots_quintic_walk/msg/walk_debug.hpp" -#include "bitbots_quintic_walk/msg/walk_engine_debug.hpp" -#include "bitbots_splines/abstract_ik.hpp" -#include "bitbots_splines/abstract_visualizer.hpp" - namespace bitbots_quintic_walk { class WalkVisualizer : public bitbots_splines::AbstractVisualizer { public: diff --git a/bitbots_motion/bitbots_quintic_walk/src/walk_engine.cpp b/bitbots_motion/bitbots_quintic_walk/src/walk_engine.cpp index 331dcc627..bfa04c282 100644 --- a/bitbots_motion/bitbots_quintic_walk/src/walk_engine.cpp +++ b/bitbots_motion/bitbots_quintic_walk/src/walk_engine.cpp @@ -3,7 +3,7 @@ This code is partly based on the original code by Quentin "Leph" Rouxel and Team The original files can be found at: https://github.com/Rhoban/model/ */ -#include "bitbots_quintic_walk/walk_engine.hpp" +#include namespace bitbots_quintic_walk { diff --git a/bitbots_motion/bitbots_quintic_walk/src/walk_ik.cpp b/bitbots_motion/bitbots_quintic_walk/src/walk_ik.cpp index 7ef787e74..14b4d5a0e 100644 --- a/bitbots_motion/bitbots_quintic_walk/src/walk_ik.cpp +++ b/bitbots_motion/bitbots_quintic_walk/src/walk_ik.cpp @@ -1,4 +1,4 @@ -#include "bitbots_quintic_walk/walk_ik.hpp" +#include namespace bitbots_quintic_walk { diff --git a/bitbots_motion/bitbots_quintic_walk/src/walk_node.cpp b/bitbots_motion/bitbots_quintic_walk/src/walk_node.cpp index 74e41eb37..4e48a6028 100644 --- a/bitbots_motion/bitbots_quintic_walk/src/walk_node.cpp +++ b/bitbots_motion/bitbots_quintic_walk/src/walk_node.cpp @@ -1,7 +1,6 @@ #define M_TAU M_PI * 2 -#include "bitbots_quintic_walk/walk_node.hpp" - +#include #include #include using std::placeholders::_1; diff --git a/bitbots_motion/bitbots_quintic_walk/src/walk_pywrapper.cpp b/bitbots_motion/bitbots_quintic_walk/src/walk_pywrapper.cpp index 3d83ae465..e0f2ac570 100644 --- a/bitbots_motion/bitbots_quintic_walk/src/walk_pywrapper.cpp +++ b/bitbots_motion/bitbots_quintic_walk/src/walk_pywrapper.cpp @@ -1,4 +1,4 @@ -#include "bitbots_quintic_walk/walk_pywrapper.hpp" +#include void PyWalkWrapper::spin_some() { rclcpp::spin_some(node_); } diff --git a/bitbots_motion/bitbots_quintic_walk/src/walk_stabilizer.cpp b/bitbots_motion/bitbots_quintic_walk/src/walk_stabilizer.cpp index 3e27e6ce3..abf539ae1 100644 --- a/bitbots_motion/bitbots_quintic_walk/src/walk_stabilizer.cpp +++ b/bitbots_motion/bitbots_quintic_walk/src/walk_stabilizer.cpp @@ -1,11 +1,11 @@ -#include "bitbots_quintic_walk/walk_stabilizer.hpp" +#include namespace bitbots_quintic_walk { WalkStabilizer::WalkStabilizer(rclcpp::Node::SharedPtr node) : pid_trunk_fused_pitch_(node, "node.trunk_pid.pitch"), pid_trunk_fused_roll_(node, "node.trunk_pid.roll") { - pid_trunk_fused_pitch_.initPid(); - pid_trunk_fused_roll_.initPid(); + pid_trunk_fused_pitch_.initialize_from_ros_parameters(); + pid_trunk_fused_roll_.initialize_from_ros_parameters(); reset(); } @@ -29,9 +29,9 @@ WalkResponse WalkStabilizer::stabilize(const WalkResponse& response, const rclcp // adapt trunk values based on PID controllers double fused_roll_correction = - pid_trunk_fused_roll_.computeCommand(goal_fused.fusedRoll - response.current_fused_roll, dt); + pid_trunk_fused_roll_.compute_command(goal_fused.fusedRoll - response.current_fused_roll, dt); double fused_pitch_correction = - pid_trunk_fused_pitch_.computeCommand(goal_fused.fusedPitch - response.current_fused_pitch, dt); + pid_trunk_fused_pitch_.compute_command(goal_fused.fusedPitch - response.current_fused_pitch, dt); // Change trunk x offset (in the trunks frame of reference) based on the PID controllers WalkResponse stabilized_response{response}; diff --git a/bitbots_motion/bitbots_quintic_walk/src/walk_visualizer.cpp b/bitbots_motion/bitbots_quintic_walk/src/walk_visualizer.cpp index 0fc9e7823..a4e5d5151 100644 --- a/bitbots_motion/bitbots_quintic_walk/src/walk_visualizer.cpp +++ b/bitbots_motion/bitbots_quintic_walk/src/walk_visualizer.cpp @@ -1,4 +1,4 @@ -#include "bitbots_quintic_walk/walk_visualizer.hpp" +#include namespace bitbots_quintic_walk { WalkVisualizer::WalkVisualizer(rclcpp::Node::SharedPtr node, walking::Params::Node::Tf tf_config) diff --git a/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_ik.hpp b/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_ik.hpp index 3be7d2bed..93b8fac25 100644 --- a/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_ik.hpp +++ b/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_ik.hpp @@ -2,8 +2,7 @@ #ifndef BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_ABSTRACT_IK_H_ #define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_ABSTRACT_IK_H_ -#include - +#include #include #include #include diff --git a/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_visualizer.hpp b/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_visualizer.hpp index 0a64c73fc..49fb8c159 100644 --- a/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_visualizer.hpp +++ b/bitbots_motion/bitbots_splines/include/bitbots_splines/abstract_visualizer.hpp @@ -1,9 +1,8 @@ #ifndef BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_ABSTRACT_VISUALIZER_H_ #define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_ABSTRACT_VISUALIZER_H_ -#include - #include +#include #include #include diff --git a/bitbots_motion/bitbots_splines/include/bitbots_splines/pose_spline.hpp b/bitbots_motion/bitbots_splines/include/bitbots_splines/pose_spline.hpp index 8da987b65..e1fce694f 100644 --- a/bitbots_motion/bitbots_splines/include/bitbots_splines/pose_spline.hpp +++ b/bitbots_motion/bitbots_splines/include/bitbots_splines/pose_spline.hpp @@ -1,17 +1,15 @@ #ifndef BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_POSE_SPLINE_H_ #define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_POSE_SPLINE_H_ -#include -#include -#include - #include #include #include #include #include - -#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp" +#include +#include +#include +#include namespace bitbots_splines { diff --git a/bitbots_motion/bitbots_splines/include/bitbots_splines/position_spline.hpp b/bitbots_motion/bitbots_splines/include/bitbots_splines/position_spline.hpp index 73a04587d..7f07740bc 100644 --- a/bitbots_motion/bitbots_splines/include/bitbots_splines/position_spline.hpp +++ b/bitbots_motion/bitbots_splines/include/bitbots_splines/position_spline.hpp @@ -1,11 +1,10 @@ #ifndef BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_POSITION_SPLINE_H_ #define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_POSITION_SPLINE_H_ -#include - #include #include #include +#include namespace bitbots_splines { diff --git a/bitbots_motion/bitbots_splines/src/Spline/polynom.cpp b/bitbots_motion/bitbots_splines/src/Spline/polynom.cpp index 691dbcc7d..546526193 100644 --- a/bitbots_motion/bitbots_splines/src/Spline/polynom.cpp +++ b/bitbots_motion/bitbots_splines/src/Spline/polynom.cpp @@ -3,9 +3,8 @@ This code is largely based on the original code by Quentin "Leph" Rouxel and Tea The original files can be found at: https://github.com/Rhoban/model/ */ -#include "bitbots_splines/polynom.hpp" - -#include "bitbots_splines/newton_binomial.hpp" +#include +#include namespace bitbots_splines { diff --git a/bitbots_motion/bitbots_splines/src/Spline/pose_spline.cpp b/bitbots_motion/bitbots_splines/src/Spline/pose_spline.cpp index 3e8392cb7..55721fbc7 100644 --- a/bitbots_motion/bitbots_splines/src/Spline/pose_spline.cpp +++ b/bitbots_motion/bitbots_splines/src/Spline/pose_spline.cpp @@ -1,4 +1,4 @@ -#include "bitbots_splines/pose_spline.hpp" +#include namespace bitbots_splines { diff --git a/bitbots_motion/bitbots_splines/src/Spline/position_spline.cpp b/bitbots_motion/bitbots_splines/src/Spline/position_spline.cpp index c979e9c6f..e2716e929 100644 --- a/bitbots_motion/bitbots_splines/src/Spline/position_spline.cpp +++ b/bitbots_motion/bitbots_splines/src/Spline/position_spline.cpp @@ -1,4 +1,4 @@ -#include "bitbots_splines/position_spline.hpp" +#include namespace bitbots_splines { diff --git a/bitbots_motion/bitbots_splines/src/Spline/smooth_spline.cpp b/bitbots_motion/bitbots_splines/src/Spline/smooth_spline.cpp index 682eaa761..1a3f2cc86 100644 --- a/bitbots_motion/bitbots_splines/src/Spline/smooth_spline.cpp +++ b/bitbots_motion/bitbots_splines/src/Spline/smooth_spline.cpp @@ -3,11 +3,10 @@ This code is largely based on the original code by Quentin "Leph" Rouxel and Tea The original files can be found at: https://github.com/Rhoban/model/ */ -#include "bitbots_splines/smooth_spline.hpp" - #include #include +#include #include namespace bitbots_splines { @@ -98,7 +97,7 @@ Polynom SmoothSpline::polynomFit(double t, double pos_1, double vel_1, double ac std::string SmoothSpline::getDebugString() { std::string output; int i = 0; - for (auto &p : points_) { + for (const auto &p : points_) { output += "Point:" + std::to_string(i) + "\n"; output += " Time: " + std::to_string(p.time) + "\n"; output += " Pos: " + std::to_string(p.position) + "\n"; diff --git a/bitbots_motion/bitbots_splines/src/Spline/spline.cpp b/bitbots_motion/bitbots_splines/src/Spline/spline.cpp index c43037270..12a83b4a7 100644 --- a/bitbots_motion/bitbots_splines/src/Spline/spline.cpp +++ b/bitbots_motion/bitbots_splines/src/Spline/spline.cpp @@ -3,8 +3,7 @@ This code is largely based on the original code by Quentin "Leph" Rouxel and Tea The original files can be found at: https://github.com/Rhoban/model/ */ -#include "bitbots_splines/spline.hpp" - +#include #include #include diff --git a/bitbots_motion/bitbots_splines/src/Utils/combination.cpp b/bitbots_motion/bitbots_splines/src/Utils/combination.cpp index eb985e418..414aaf6bb 100644 --- a/bitbots_motion/bitbots_splines/src/Utils/combination.cpp +++ b/bitbots_motion/bitbots_splines/src/Utils/combination.cpp @@ -3,8 +3,7 @@ This code is largely based on the original code by Quentin "Leph" Rouxel and Tea The original files can be found at: https://github.com/Rhoban/model/ */ -#include "bitbots_splines/combination.hpp" - +#include #include #include diff --git a/bitbots_motion/bitbots_splines/src/Utils/newton_binomial.cpp b/bitbots_motion/bitbots_splines/src/Utils/newton_binomial.cpp index 5c8dcc641..543c19548 100644 --- a/bitbots_motion/bitbots_splines/src/Utils/newton_binomial.cpp +++ b/bitbots_motion/bitbots_splines/src/Utils/newton_binomial.cpp @@ -3,8 +3,7 @@ This code is largely based on the original code by Quentin "Leph" Rouxel and Tea The original files can be found at: https://github.com/Rhoban/model/ */ -#include "bitbots_splines/newton_binomial.hpp" - +#include #include namespace bitbots_splines { diff --git a/bitbots_msgs/pyproject.toml b/bitbots_msgs/pyproject.toml index 3ed6ff7a4..3e23bc6c4 100644 --- a/bitbots_msgs/pyproject.toml +++ b/bitbots_msgs/pyproject.toml @@ -3,6 +3,8 @@ line-length = 120 [tool.ruff] line-length = 120 + +[tool.ruff.lint] # Never enforce `E501` (line length violations), as black takes care of this. ignore = ["E501"] # Additionally enable the following rules diff --git a/bitbots_navigation/bitbots_localization/CMakeLists.txt b/bitbots_navigation/bitbots_localization/CMakeLists.txt index 4eadc1f07..595009865 100644 --- a/bitbots_navigation/bitbots_localization/CMakeLists.txt +++ b/bitbots_navigation/bitbots_localization/CMakeLists.txt @@ -15,7 +15,10 @@ find_package(ament_cmake REQUIRED) find_package(ament_index_cpp REQUIRED) find_package(backward_ros REQUIRED) find_package(bitbots_utils REQUIRED) -find_package(Boost COMPONENTS filesystem REQUIRED) +find_package( + Boost + COMPONENTS filesystem + REQUIRED) find_package(builtin_interfaces REQUIRED) find_package(cv_bridge REQUIRED) find_package(generate_parameter_library REQUIRED) diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/MotionModel.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/MotionModel.hpp index d767c4edc..b91480c6f 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/MotionModel.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/MotionModel.hpp @@ -5,14 +5,13 @@ #ifndef BITBOTS_LOCALIZATION_MOTIONMODEL_H #define BITBOTS_LOCALIZATION_MOTIONMODEL_H -#include -#include - #include #include #include #include #include +#include +#include namespace bitbots_localization { /** @@ -61,5 +60,5 @@ class RobotMotionModel : public particle_filter::MovementModel { double sample(double b) const; }; -}; // namespace bitbots_localization +}; // namespace bitbots_localization #endif // BITBOTS_LOCALIZATION_MOTIONMODEL_H diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/ObservationModel.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/ObservationModel.hpp index 79065d1ff..f6c53a97b 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/ObservationModel.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/ObservationModel.hpp @@ -5,19 +5,18 @@ #ifndef BITBOTS_LOCALIZATION_OBSERVATIONMODEL_H #define BITBOTS_LOCALIZATION_OBSERVATIONMODEL_H -#include #include #include +#include #include #include +#include #include #include #include #include -#include "localization_parameters.hpp" - namespace sm = sensor_msgs; namespace bl = bitbots_localization; namespace sv3dm = soccer_vision_3d_msgs; diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/Resampling.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/Resampling.hpp index b4dcbb190..2b3d6e554 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/Resampling.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/Resampling.hpp @@ -6,9 +6,8 @@ #define IMPORTANCERESAMPLINGWE_H #include - -#include "particle_filter/CRandomNumberGenerator.h" -#include "particle_filter/ImportanceResampling.h" +#include +#include namespace bitbots_localization { // ImportanceResampling with explorers @@ -97,5 +96,5 @@ void ImportanceResamplingWE::resample(const ParticleList &sourceList, // template // void ParticleFilter::drawAllFromDistribution(const // std::shared_ptr>& distribution) { -}; // namespace bitbots_localization +}; // namespace bitbots_localization #endif // IMPORTANCERESAMPLINGWE_H diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/RobotState.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/RobotState.hpp index 3104ccc76..d457b09cd 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/RobotState.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/RobotState.hpp @@ -5,14 +5,13 @@ #ifndef BITBOTS_LOCALIZATION_ROBOTSTATE_H #define BITBOTS_LOCALIZATION_ROBOTSTATE_H -#include -#include -#include -#include - #include #include #include +#include +#include +#include +#include #include namespace bitbots_localization { diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/StateDistribution.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/StateDistribution.hpp index ca564ad80..8e5b9b02a 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/StateDistribution.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/StateDistribution.hpp @@ -5,10 +5,9 @@ #ifndef BITBOTS_LOCALIZATION_STATEDISTRIBUTION_H #define BITBOTS_LOCALIZATION_STATEDISTRIBUTION_H -#include -#include - #include +#include +#include #include #include diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/localization.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/localization.hpp index 2519bf53c..b0309060b 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/localization.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/localization.hpp @@ -6,14 +6,6 @@ #define BITBOTS_LOCALIZATION_LOCALIZATION_H #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -25,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -44,20 +37,26 @@ #include #include #include +#include +#include +#include #include #include #include #include #include #include +#include +#include +#include +#include +#include #include #include #include #include #include -#include "localization_parameters.hpp" - namespace sm = sensor_msgs; namespace gm = geometry_msgs; namespace pf = particle_filter; diff --git a/bitbots_navigation/bitbots_localization/include/bitbots_localization/map.hpp b/bitbots_navigation/bitbots_localization/include/bitbots_localization/map.hpp index b451634a5..bee35e365 100644 --- a/bitbots_navigation/bitbots_localization/include/bitbots_localization/map.hpp +++ b/bitbots_navigation/bitbots_localization/include/bitbots_localization/map.hpp @@ -53,5 +53,5 @@ class Map { private: double out_of_map_value_; }; -}; // namespace bitbots_localization +}; // namespace bitbots_localization #endif // BITBOTS_LOCALIZATION_MAP_H diff --git a/bitbots_navigation/bitbots_localization/src/RobotState.cpp b/bitbots_navigation/bitbots_localization/src/RobotState.cpp index 5cc5a9186..3f1cde1e2 100644 --- a/bitbots_navigation/bitbots_localization/src/RobotState.cpp +++ b/bitbots_navigation/bitbots_localization/src/RobotState.cpp @@ -74,7 +74,7 @@ void RobotState::convertParticleListToEigen(const std::vector *particle : particle_list) { if (!particle->is_explorer_) { matrix(counter, 0) = particle->getState().getXPos(); @@ -86,7 +86,7 @@ void RobotState::convertParticleListToEigen(const std::vectorgetState().getXPos(); matrix(i, 1) = particle_list[i]->getState().getYPos(); diff --git a/bitbots_navigation/bitbots_localization/src/localization.cpp b/bitbots_navigation/bitbots_localization/src/localization.cpp index 708fdf0d4..89c2e1a92 100644 --- a/bitbots_navigation/bitbots_localization/src/localization.cpp +++ b/bitbots_navigation/bitbots_localization/src/localization.cpp @@ -1,5 +1,4 @@ -#include "bitbots_localization/localization.hpp" - +#include #include #include diff --git a/bitbots_navigation/bitbots_localization/src/map.cpp b/bitbots_navigation/bitbots_localization/src/map.cpp index b20a9045c..6491368c4 100644 --- a/bitbots_navigation/bitbots_localization/src/map.cpp +++ b/bitbots_navigation/bitbots_localization/src/map.cpp @@ -2,9 +2,8 @@ // Created by judith on 08.03.19. // -#include "bitbots_localization/map.hpp" - #include +#include #include namespace fs = boost::filesystem; diff --git a/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization_blackboard.py b/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization_blackboard.py index 5e9341c92..4e85eba1b 100644 --- a/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization_blackboard.py +++ b/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization_blackboard.py @@ -1,4 +1,4 @@ -from typing import Optional, Type +from typing import Optional import numpy as np import tf2_ros as tf2 @@ -55,7 +55,7 @@ def __init__(self, node: Node): self.last_state_get_up = False # IMU - self.accel: Float[np.ndarray, "3"] = np.array([0.0, 0.0, 0.0]) + self.accel: Float[np.ndarray, "3"] = np.zeros(3) self.imu_orientation = Quaternion(w=1.0) # Falling odometry / imu interpolation during falls @@ -66,7 +66,7 @@ def __init__(self, node: Node): self.pickup_accel_buffer_long: list[Float[np.ndarray, "3"]] = [] # Last init action - self.last_init_action_type: Optional[Type] = None + self.last_init_action_type: Optional[type] = None self.last_init_odom_transform: TransformStamped | None = None def _callback_pose(self, msg: PoseWithCovarianceStamped): diff --git a/bitbots_navigation/bitbots_odometry/include/bitbots_odometry/motion_odometry.hpp b/bitbots_navigation/bitbots_odometry/include/bitbots_odometry/motion_odometry.hpp index b734adb8b..82cc247ed 100644 --- a/bitbots_navigation/bitbots_odometry/include/bitbots_odometry/motion_odometry.hpp +++ b/bitbots_navigation/bitbots_odometry/include/bitbots_odometry/motion_odometry.hpp @@ -1,20 +1,19 @@ -#include #include #include #include #include #include +#include #include #include #include #include #include #include +#include #include -#include "odometry_parameters.hpp" - using std::placeholders::_1; namespace bitbots_odometry { diff --git a/bitbots_navigation/bitbots_odometry/src/odometry_fuser.cpp b/bitbots_navigation/bitbots_odometry/src/odometry_fuser.cpp index 48d85f40b..694495d9c 100644 --- a/bitbots_navigation/bitbots_odometry/src/odometry_fuser.cpp +++ b/bitbots_navigation/bitbots_odometry/src/odometry_fuser.cpp @@ -12,11 +12,6 @@ imu (rX, rY) #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -32,6 +27,11 @@ imu (rX, rY) #include #include #include +#include +#include +#include +#include +#include #include #include diff --git a/bitbots_simulation/bitbots_robocup_api/wolfgang_robocup_api/__init__.py b/bitbots_simulation/bitbots_robocup_api/bitbots_robocup_api/__init__.py similarity index 100% rename from bitbots_simulation/bitbots_robocup_api/wolfgang_robocup_api/__init__.py rename to bitbots_simulation/bitbots_robocup_api/bitbots_robocup_api/__init__.py diff --git a/bitbots_simulation/bitbots_robocup_api/wolfgang_robocup_api/command_proxy.py b/bitbots_simulation/bitbots_robocup_api/bitbots_robocup_api/command_proxy.py similarity index 100% rename from bitbots_simulation/bitbots_robocup_api/wolfgang_robocup_api/command_proxy.py rename to bitbots_simulation/bitbots_robocup_api/bitbots_robocup_api/command_proxy.py diff --git a/bitbots_simulation/bitbots_robocup_api/launch/robocup_teamplayer.launch b/bitbots_simulation/bitbots_robocup_api/launch/robocup_teamplayer.launch index 7c145e37a..90d0d21e2 100644 --- a/bitbots_simulation/bitbots_robocup_api/launch/robocup_teamplayer.launch +++ b/bitbots_simulation/bitbots_robocup_api/launch/robocup_teamplayer.launch @@ -2,13 +2,6 @@ - - - - - - - diff --git a/bitbots_simulation/bitbots_robocup_api/package.xml b/bitbots_simulation/bitbots_robocup_api/package.xml index b7b2c2954..3d390044e 100644 --- a/bitbots_simulation/bitbots_robocup_api/package.xml +++ b/bitbots_simulation/bitbots_robocup_api/package.xml @@ -29,6 +29,8 @@ topic_tools rosbag2 + python3-pytest + ament_python diff --git a/bitbots_simulation/bitbots_robocup_api/setup.py b/bitbots_simulation/bitbots_robocup_api/setup.py index 94fdf23af..2ab578e4e 100644 --- a/bitbots_simulation/bitbots_robocup_api/setup.py +++ b/bitbots_simulation/bitbots_robocup_api/setup.py @@ -7,7 +7,7 @@ setup( name=package_name, - packages=find_packages(), + packages=find_packages(exclude=["test"]), data_files=[ ("share/ament_index/resource_index/packages", ["resource/" + package_name]), (os.path.join("share", package_name), ["package.xml"]), @@ -18,6 +18,7 @@ "launch", "setuptools", ], + tests_require=["pytest"], zip_safe=True, keywords=["ROS"], license="MIT", diff --git a/bitbots_simulation/bitbots_webots_sim/CMakeLists.txt b/bitbots_simulation/bitbots_webots_sim/CMakeLists.txt index cb326d372..25acc517d 100644 --- a/bitbots_simulation/bitbots_webots_sim/CMakeLists.txt +++ b/bitbots_simulation/bitbots_webots_sim/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.5) project(bitbots_webots_sim) +# Add support for C++17 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + find_package(ament_cmake REQUIRED) find_package(bitbots_docs REQUIRED) diff --git a/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_robot_controller.py b/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_robot_controller.py index a16c6e99a..c158cb940 100644 --- a/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_robot_controller.py +++ b/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_robot_controller.py @@ -779,7 +779,7 @@ def get_joint_values(self, used_joint_names, scaled=False): def get_joint_state_msg(self): js = JointState() js.name = [] - js.header.stamp = Time(seconds=int(self.time), nanoseconds=self.time % 1 * 1e9).to_msg() + js.header.stamp = Time(seconds=int(self.time), nanoseconds=int(self.time % 1 * 1e9)).to_msg() js.position = [] js.effort = [] for joint_name in self.external_motor_names: @@ -796,7 +796,7 @@ def publish_joint_states(self): def get_imu_msg(self, head=False): msg = Imu() - msg.header.stamp = Time(seconds=int(self.time), nanoseconds=self.time % 1 * 1e9).to_msg() + msg.header.stamp = Time(seconds=int(self.time), nanoseconds=int(self.time % 1 * 1e9)).to_msg() if head: msg.header.frame_id = self.head_imu_frame else: @@ -841,7 +841,7 @@ def publish_imu(self): def publish_camera(self): img_msg = Image() - img_msg.header.stamp = Time(seconds=int(self.time), nanoseconds=self.time % 1 * 1e9).to_msg() + img_msg.header.stamp = Time(seconds=int(self.time), nanoseconds=int(self.time % 1 * 1e9)).to_msg() img_msg.header.frame_id = self.camera_optical_frame img_msg.height = self.camera.getHeight() img_msg.width = self.camera.getWidth() @@ -917,7 +917,7 @@ def get_image(self): return self.camera.getImage() def get_pressure_message(self): - current_time = Time(seconds=int(self.time), nanoseconds=self.time % 1 * 1e9).to_msg() + current_time = Time(seconds=int(self.time), nanoseconds=int(self.time % 1 * 1e9)).to_msg() if not self.foot_sensors_active or self.pressure_sensors is None: cop_r = PointStamped() cop_r.header.frame_id = self.r_sole_frame diff --git a/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_supervisor_controller.py b/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_supervisor_controller.py index cce9a575f..8ab69da26 100644 --- a/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_supervisor_controller.py +++ b/bitbots_simulation/bitbots_webots_sim/bitbots_webots_sim/webots_supervisor_controller.py @@ -193,7 +193,7 @@ def handle_gui(self): return key def publish_clock(self): - self.clock_msg.clock = Time(seconds=int(self.time), nanoseconds=self.time % 1 * 1e9).to_msg() + self.clock_msg.clock = Time(seconds=int(self.time), nanoseconds=int(self.time % 1 * 1e9)).to_msg() self.clock_publisher.publish(self.clock_msg) def set_gravity(self, active): diff --git a/bitbots_simulation/bitbots_webots_sim/protos/robots/Wolfgang/Wolfgang.proto b/bitbots_simulation/bitbots_webots_sim/protos/robots/Wolfgang/Wolfgang.proto index e2d546987..6d41cc9b0 100644 --- a/bitbots_simulation/bitbots_webots_sim/protos/robots/Wolfgang/Wolfgang.proto +++ b/bitbots_simulation/bitbots_webots_sim/protos/robots/Wolfgang/Wolfgang.proto @@ -71,7 +71,7 @@ PROTO Wolfgang [ field SFBool enableBoundingObject TRUE # Is `Robot.enableBoundingObject`. field SFBool enablePhysics TRUE # Is `Robot.enablePhysics`. field SFBool enableFootSensors TRUE # Is `Robot.enableFootSensors`. - field SFFloat cameraFOV 1.04 + field SFFloat cameraFOV 1.517 field SFInt32 cameraWidth 800 field SFInt32 cameraHeight 600 field SFFloat MX64-torque 7.3 diff --git a/bitbots_simulation/bitbots_webots_sim/scripts/imu_lut_gen.py b/bitbots_simulation/bitbots_webots_sim/scripts/imu_lut_gen.py index 65f98713b..bc594d1b3 100644 --- a/bitbots_simulation/bitbots_webots_sim/scripts/imu_lut_gen.py +++ b/bitbots_simulation/bitbots_webots_sim/scripts/imu_lut_gen.py @@ -4,13 +4,13 @@ def noise_table(my_min, noise, iters, indent): for i in range(iters): val = my_min / 2**i print(indent * " ", end="") - print(f" {val:f} {val:f} {noise/-val:f},") + print(f" {val:f} {val:f} {noise / -val:f},") print(indent * " ", end="") print(" 0 0 0") for i in range(iters): val = -my_min / 2 ** (iters - i - 1) print(indent * " ", end="") - print(f" {val:f} {val:f} {noise/val:f},") + print(f" {val:f} {val:f} {noise / val:f},") print(indent * " ", end="") print("]") diff --git a/bitbots_team_communication/bitbots_team_communication/CMakeLists.txt b/bitbots_team_communication/bitbots_team_communication/CMakeLists.txt index 93f0dece8..7066585ea 100644 --- a/bitbots_team_communication/bitbots_team_communication/CMakeLists.txt +++ b/bitbots_team_communication/bitbots_team_communication/CMakeLists.txt @@ -6,19 +6,21 @@ find_package(ament_cmake_python REQUIRED) find_package(bitbots_docs REQUIRED) find_package(Protobuf REQUIRED) -protobuf_generate_python( - PROTO_PY bitbots_team_communication/RobocupProtocol/robocup_extension.proto) - add_custom_target( - bitbots_team_communication ALL - DEPENDS ${PROTO_PY} - COMMENT "Generating protobuf") + ${PROJECT_NAME}_generate_proto ALL + COMMENT "Generating protobuf python interface including stubs") + +set(PROTO_FILES + bitbots_team_communication/RobocupProtocol/robocup_extension.proto) + add_custom_command( - TARGET bitbots_team_communication - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${PROTO_PY} - ${CMAKE_SOURCE_DIR}/bitbots_team_communication - COMMENT "Copying protobuf to source dir") + TARGET ${PROJECT_NAME}_generate_proto + COMMAND + protoc --pyi_out ${CMAKE_SOURCE_DIR}/bitbots_team_communication/ + --python_out ${CMAKE_SOURCE_DIR}/bitbots_team_communication/ --proto_path + ${CMAKE_SOURCE_DIR}/bitbots_team_communication/RobocupProtocol + ${CMAKE_SOURCE_DIR}/${PROTO_FILES} + COMMENT "Generating protobuf python interface including stubs") enable_bitbots_docs() ament_python_install_package(${PROJECT_NAME}) @@ -50,7 +52,32 @@ if(BUILD_TESTING) endforeach() find_package(ament_cmake_mypy REQUIRED) - ament_mypy(CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/mypy.ini") + + # The following logic for manually filtering out the files can be removed if + # https://github.com/ament/ament_lint/pull/516 is merged and released in our + # ROS distro + + # Collect all .py and .pyi files + file(GLOB_RECURSE PY_FILES "${CMAKE_CURRENT_LIST_DIR}/**/*.py") + file(GLOB_RECURSE PYI_FILES "${CMAKE_CURRENT_LIST_DIR}/**/*.pyi") + + # Filter out .py files if a corresponding .pyi file exists + foreach(py_file IN LISTS PY_FILES) + # Get the directory and basename (without extension) + get_filename_component(py_dir "${py_file}" DIRECTORY) + get_filename_component(py_basename "${py_file}" NAME_WE) + + # Construct the corresponding .pyi file path + set(PYI_FILE "${py_dir}/${py_basename}.pyi") + + # If a corresponding .pyi file exists, remove the .py file from the list + if(EXISTS "${PYI_FILE}") + list(REMOVE_ITEM PY_FILES "${py_file}") + endif() + endforeach() + + ament_mypy(CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/mypy.ini" ${PY_FILES} + ${PYI_FILES}) endif() ament_package() diff --git a/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/message_to_team_data_converter.py b/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/message_to_team_data_converter.py index e08e22b4c..754385d54 100644 --- a/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/message_to_team_data_converter.py +++ b/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/message_to_team_data_converter.py @@ -1,4 +1,4 @@ -from typing import Iterable, Sequence +from collections.abc import Iterable, Sequence import numpy as np import transforms3d diff --git a/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/robocup_protocol_converter.py b/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/robocup_protocol_converter.py index 68cb2eb3d..b3ca448c7 100644 --- a/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/robocup_protocol_converter.py +++ b/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/robocup_protocol_converter.py @@ -16,40 +16,40 @@ class TeamColor(IntEnum): class RobocupProtocolConverter: def __init__(self, own_team_color: TeamColor): self.role_mapping = ( - (Proto.Role.ROLE_UNDEFINED, Strategy.ROLE_UNDEFINED), - (Proto.Role.ROLE_IDLING, Strategy.ROLE_IDLING), - (Proto.Role.ROLE_OTHER, Strategy.ROLE_OTHER), - (Proto.Role.ROLE_STRIKER, Strategy.ROLE_STRIKER), - (Proto.Role.ROLE_SUPPORTER, Strategy.ROLE_SUPPORTER), - (Proto.Role.ROLE_DEFENDER, Strategy.ROLE_DEFENDER), - (Proto.Role.ROLE_GOALIE, Strategy.ROLE_GOALIE), + (Proto.ROLE_UNDEFINED, Strategy.ROLE_UNDEFINED), + (Proto.ROLE_IDLING, Strategy.ROLE_IDLING), + (Proto.ROLE_OTHER, Strategy.ROLE_OTHER), + (Proto.ROLE_STRIKER, Strategy.ROLE_STRIKER), + (Proto.ROLE_SUPPORTER, Strategy.ROLE_SUPPORTER), + (Proto.ROLE_DEFENDER, Strategy.ROLE_DEFENDER), + (Proto.ROLE_GOALIE, Strategy.ROLE_GOALIE), ) self.action_mapping = ( - (Proto.Action.ACTION_UNDEFINED, Strategy.ACTION_UNDEFINED), - (Proto.Action.ACTION_POSITIONING, Strategy.ACTION_POSITIONING), - (Proto.Action.ACTION_GOING_TO_BALL, Strategy.ACTION_GOING_TO_BALL), - (Proto.Action.ACTION_TRYING_TO_SCORE, Strategy.ACTION_TRYING_TO_SCORE), - (Proto.Action.ACTION_WAITING, Strategy.ACTION_WAITING), - (Proto.Action.ACTION_KICKING, Strategy.ACTION_KICKING), - (Proto.Action.ACTION_SEARCHING, Strategy.ACTION_SEARCHING), - (Proto.Action.ACTION_LOCALIZING, Strategy.ACTION_LOCALIZING), + (Proto.ACTION_UNDEFINED, Strategy.ACTION_UNDEFINED), + (Proto.ACTION_POSITIONING, Strategy.ACTION_POSITIONING), + (Proto.ACTION_GOING_TO_BALL, Strategy.ACTION_GOING_TO_BALL), + (Proto.ACTION_TRYING_TO_SCORE, Strategy.ACTION_TRYING_TO_SCORE), + (Proto.ACTION_WAITING, Strategy.ACTION_WAITING), + (Proto.ACTION_KICKING, Strategy.ACTION_KICKING), + (Proto.ACTION_SEARCHING, Strategy.ACTION_SEARCHING), + (Proto.ACTION_LOCALIZING, Strategy.ACTION_LOCALIZING), ) self.side_mapping = ( - (Proto.OffensiveSide.SIDE_UNDEFINED, Strategy.SIDE_UNDEFINED), - (Proto.OffensiveSide.SIDE_LEFT, Strategy.SIDE_LEFT), - (Proto.OffensiveSide.SIDE_MIDDLE, Strategy.SIDE_MIDDLE), - (Proto.OffensiveSide.SIDE_RIGHT, Strategy.SIDE_RIGHT), + (Proto.SIDE_UNDEFINED, Strategy.SIDE_UNDEFINED), + (Proto.SIDE_LEFT, Strategy.SIDE_LEFT), + (Proto.SIDE_MIDDLE, Strategy.SIDE_MIDDLE), + (Proto.SIDE_RIGHT, Strategy.SIDE_RIGHT), ) self.proto_to_team_data_team_mapping = { - Proto.Team.UNKNOWN_TEAM: RobotRelative.ROBOT_UNDEFINED, - Proto.Team.BLUE: RobotRelative.ROBOT_BLUE, - Proto.Team.RED: RobotRelative.ROBOT_RED, + Proto.UNKNOWN_TEAM: RobotRelative.ROBOT_UNDEFINED, + Proto.BLUE: RobotRelative.ROBOT_BLUE, + Proto.RED: RobotRelative.ROBOT_RED, } self.state_to_proto_team_mapping = { - RobotAttributes.TEAM_OWN: Proto.Team.RED if own_team_color == TeamColor.RED else Proto.Team.BLUE, - RobotAttributes.TEAM_OPPONENT: Proto.Team.BLUE if own_team_color == TeamColor.RED else Proto.Team.RED, - RobotAttributes.TEAM_UNKNOWN: Proto.Team.UNKNOWN_TEAM, + RobotAttributes.TEAM_OWN: Proto.RED if own_team_color == TeamColor.RED else Proto.BLUE, + RobotAttributes.TEAM_OPPONENT: Proto.BLUE if own_team_color == TeamColor.RED else Proto.RED, + RobotAttributes.TEAM_UNKNOWN: Proto.UNKNOWN_TEAM, } proto_to_team_data_mappings = { diff --git a/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/state_to_message_converter.py b/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/state_to_message_converter.py index e41d2e9a0..41ea6a62e 100644 --- a/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/state_to_message_converter.py +++ b/bitbots_team_communication/bitbots_team_communication/bitbots_team_communication/converter/state_to_message_converter.py @@ -25,9 +25,9 @@ def convert( ) -> Proto.Message: def convert_gamestate(gamestate: Optional[GameState], message: Proto.Message): if gamestate is not None and is_still_valid_checker(gamestate.header.stamp): - message.state = Proto.State.PENALISED if gamestate.penalized else Proto.State.UNPENALISED + message.state = Proto.PENALISED if gamestate.penalized else Proto.UNPENALISED else: - message.state = Proto.State.UNKNOWN_STATE + message.state = Proto.UNKNOWN_STATE return message diff --git a/bitbots_team_communication/bitbots_team_communication/mypy.ini b/bitbots_team_communication/bitbots_team_communication/mypy.ini index 6b19e8374..6f30984fe 100644 --- a/bitbots_team_communication/bitbots_team_communication/mypy.ini +++ b/bitbots_team_communication/bitbots_team_communication/mypy.ini @@ -3,3 +3,6 @@ [mypy] check_untyped_defs = True ignore_missing_imports = True + +# Ignore var-annotations because it is in autogenerated code from protobuf +disable_error_code = var-annotated diff --git a/bitbots_team_communication/bitbots_team_communication/setup.py b/bitbots_team_communication/bitbots_team_communication/setup.py index c7defe03d..e84961b43 100644 --- a/bitbots_team_communication/bitbots_team_communication/setup.py +++ b/bitbots_team_communication/bitbots_team_communication/setup.py @@ -8,7 +8,5 @@ install_requires=[ "setuptools", ], - extras_require={ - "dev": ["pytest", "syrupy"], - }, + tests_require=["pytest", "syrupy"], ) diff --git a/bitbots_team_communication/bitbots_team_communication/test/converter/__snapshots__/test_state_to_message_converter.ambr b/bitbots_team_communication/bitbots_team_communication/test/converter/__snapshots__/test_state_to_message_converter.ambr index 0e54919e2..972bf4400 100644 --- a/bitbots_team_communication/bitbots_team_communication/test/converter/__snapshots__/test_state_to_message_converter.ambr +++ b/bitbots_team_communication/bitbots_team_communication/test/converter/__snapshots__/test_state_to_message_converter.ambr @@ -2,14 +2,14 @@ # name: test_convert_ball_position ''' position { - x: 4.599999904632568 - y: 2.799999952316284 - z: 2.9000000953674316 + x: 4.6 + y: 2.8 + z: 2.9 } velocity { - x: 1.100000023841858 - y: 0.20000000298023224 - z: 0.30000001192092896 + x: 1.1 + y: 0.2 + z: 0.3 } covariance { x { @@ -33,9 +33,9 @@ # --- # name: test_convert_current_pose ''' - x: 3.5999999046325684 - y: 1.7999999523162842 - z: 1.2167989015579224 + x: 3.6 + y: 1.8 + z: 1.2167989 ''' # --- @@ -72,23 +72,23 @@ ''' [player_id: 2 position { - x: 3.5999999046325684 - y: 1.7999999523162842 - z: 1.2167989015579224 + x: 3.6 + y: 1.8 + z: 1.2167989 } team: BLUE , player_id: 3 position { - x: 3.5999999046325684 - y: 1.7999999523162842 - z: 1.2167989015579224 + x: 3.6 + y: 1.8 + z: 1.2167989 } team: RED , player_id: 4 position { - x: 3.5999999046325684 - y: 1.7999999523162842 - z: 1.2167989015579224 + x: 3.6 + y: 1.8 + z: 1.2167989 } ] ''' @@ -103,9 +103,9 @@ # name: test_convert_target_pose ''' position { - x: 2.5999999046325684 - y: 0.800000011920929 - z: 1.2167989015579224 + x: 2.6 + y: 0.8 + z: 1.2167989 } ''' diff --git a/bitbots_team_communication/bitbots_team_communication/test/converter/test_message_to_team_data_converter.py b/bitbots_team_communication/bitbots_team_communication/test/converter/test_message_to_team_data_converter.py index e98bedd7c..31c606c37 100644 --- a/bitbots_team_communication/bitbots_team_communication/test/converter/test_message_to_team_data_converter.py +++ b/bitbots_team_communication/bitbots_team_communication/test/converter/test_message_to_team_data_converter.py @@ -60,9 +60,9 @@ def convert_from_message(message: Proto.Message, team_data: TeamData | None = No @pytest.fixture def message_with_strategy(message) -> Proto.Message: - message.role = Proto.Role.ROLE_STRIKER - message.action = Proto.Action.ACTION_KICKING - message.offensive_side = Proto.OffensiveSide.SIDE_RIGHT + message.role = Proto.ROLE_STRIKER + message.action = Proto.ACTION_KICKING + message.offensive_side = Proto.SIDE_RIGHT return message @@ -111,9 +111,9 @@ def message() -> Proto.Message: def robot_message(player_id, is_own_team): robot = Proto.Robot() robot.player_id = player_id - robot.team = own_team_id + robot.team = own_team_id # type: ignore[assignment] if not is_own_team: - robot.team = own_team_id + 1 + robot.team = own_team_id + 1 # type: ignore[assignment] set_position(robot.position) set_covariance_matrix(robot.covariance) diff --git a/bitbots_team_communication/bitbots_team_communication/test/converter/test_robocup_protocol_converter.py b/bitbots_team_communication/bitbots_team_communication/test/converter/test_robocup_protocol_converter.py index c776238f4..59e5b83e8 100644 --- a/bitbots_team_communication/bitbots_team_communication/test/converter/test_robocup_protocol_converter.py +++ b/bitbots_team_communication/bitbots_team_communication/test/converter/test_robocup_protocol_converter.py @@ -20,9 +20,9 @@ def test_setup_of_mappings(snapshot): def test_setup_of_team_color_mapping(snapshot): converter = protocol_converter() - assert converter.state_to_proto_team_mapping[RobotAttributes.TEAM_OWN] == Proto.Team.BLUE - assert converter.state_to_proto_team_mapping[RobotAttributes.TEAM_OPPONENT] == Proto.Team.RED - assert converter.state_to_proto_team_mapping[RobotAttributes.TEAM_UNKNOWN] == Proto.Team.UNKNOWN_TEAM + assert converter.state_to_proto_team_mapping[RobotAttributes.TEAM_OWN] == Proto.BLUE + assert converter.state_to_proto_team_mapping[RobotAttributes.TEAM_OPPONENT] == Proto.RED + assert converter.state_to_proto_team_mapping[RobotAttributes.TEAM_UNKNOWN] == Proto.UNKNOWN_TEAM assert converter.proto_to_team_data_team_mapping == snapshot diff --git a/bitbots_team_communication/bitbots_team_communication/test/converter/test_state_to_message_converter.py b/bitbots_team_communication/bitbots_team_communication/test/converter/test_state_to_message_converter.py index b3513245a..16d8511f7 100644 --- a/bitbots_team_communication/bitbots_team_communication/test/converter/test_state_to_message_converter.py +++ b/bitbots_team_communication/bitbots_team_communication/test/converter/test_state_to_message_converter.py @@ -1,3 +1,4 @@ +from typing import Optional from unittest.mock import Mock import numpy @@ -44,11 +45,11 @@ def test_convert_gamestate(state_with_gamestate): gamestate.penalized = False result = convert_to_message(state_with_gamestate) - assert result.state == Proto.State.UNPENALISED + assert result.state == Proto.UNPENALISED gamestate.penalized = True result = convert_to_message(state_with_gamestate) - assert result.state == Proto.State.PENALISED + assert result.state == Proto.PENALISED assert validity_checker_valid.call_count == 2 validity_checker_valid.assert_called_with(gamestate.header.stamp) @@ -56,11 +57,11 @@ def test_convert_gamestate(state_with_gamestate): def test_convert_gamestate_expired_headers(state_with_gamestate): message = Proto.Message() - message.state = Proto.State.UNPENALISED + message.state = Proto.UNPENALISED result = convert_to_message(state_with_gamestate, message, is_state_expired=True) - assert result.state == Proto.State.UNKNOWN_STATE + assert result.state == Proto.UNKNOWN_STATE def test_convert_current_pose(snapshot, state_with_current_pose): @@ -164,22 +165,22 @@ def test_convert_obstacles_to_robots_expired_headers(state_with_seen_robots): def test_convert_strategy(state_with_strategy): result = convert_to_message(state_with_strategy) - assert result.role == Proto.Role.ROLE_STRIKER - assert result.action == Proto.Action.ACTION_KICKING - assert result.offensive_side == Proto.OffensiveSide.SIDE_RIGHT + assert result.role == Proto.ROLE_STRIKER + assert result.action == Proto.ACTION_KICKING + assert result.offensive_side == Proto.SIDE_RIGHT validity_checker_valid.assert_called_with(state_with_strategy.strategy_time) def test_convert_strategy_expired_headers(state_with_strategy): message = Proto.Message() - message.role = Proto.Role.ROLE_DEFENDER + message.role = Proto.ROLE_DEFENDER result = convert_to_message(state_with_strategy, message, is_state_expired=True) - assert result.role == Proto.Role.ROLE_DEFENDER - assert result.action == Proto.Action.ACTION_UNDEFINED - assert result.offensive_side == Proto.OffensiveSide.SIDE_UNDEFINED + assert result.role == Proto.ROLE_DEFENDER + assert result.action == Proto.ACTION_UNDEFINED + assert result.offensive_side == Proto.SIDE_UNDEFINED def test_convert_time_to_ball(state_with_time_to_ball): @@ -208,7 +209,7 @@ def test_convert_time_to_ball_expired_headers(state_with_time_to_ball): assert pytest.approx(result.time_to_ball) == 9999.0 -def convert_to_message(team_data_state, message: Proto.Message = None, is_state_expired=False): +def convert_to_message(team_data_state, message: Optional[Proto.Message] = None, is_state_expired=False): message = message if message else Proto.Message() validity_checker = validity_checker_expired if is_state_expired else validity_checker_valid return RobocupProtocolConverter(own_team_color).convert_to_message(team_data_state, message, validity_checker) diff --git a/bitbots_team_communication/bitbots_team_data_sim_rqt/package.xml b/bitbots_team_communication/bitbots_team_data_sim_rqt/package.xml index 10982eb69..ec97049c4 100644 --- a/bitbots_team_communication/bitbots_team_data_sim_rqt/package.xml +++ b/bitbots_team_communication/bitbots_team_data_sim_rqt/package.xml @@ -23,6 +23,8 @@ std_srvs ament_mypy + python3-pytest + diff --git a/bitbots_team_communication/bitbots_team_data_sim_rqt/setup.py b/bitbots_team_communication/bitbots_team_data_sim_rqt/setup.py index c99f36617..65fc7a504 100644 --- a/bitbots_team_communication/bitbots_team_data_sim_rqt/setup.py +++ b/bitbots_team_communication/bitbots_team_data_sim_rqt/setup.py @@ -4,7 +4,7 @@ setup( name=package_name, - packages=find_packages(), + packages=find_packages(exclude=["test"]), data_files=[ ("share/" + package_name + "/resource", ["resource/RobotTeamDataSimulator.ui"]), ("share/ament_index/resource_index/packages", ["resource/" + package_name]), @@ -12,8 +12,8 @@ ("share/" + package_name, ["plugin.xml"]), ], install_requires=["setuptools"], - zip_safe=True, tests_require=["pytest"], + zip_safe=True, entry_points={ "console_scripts": [ "team_data_sim_gui = " + package_name + ".team_data_ui:main", diff --git a/bitbots_vision/bitbots_vision/vision_modules/debug.py b/bitbots_vision/bitbots_vision/vision_modules/debug.py index df97333a7..63cda382d 100644 --- a/bitbots_vision/bitbots_vision/vision_modules/debug.py +++ b/bitbots_vision/bitbots_vision/vision_modules/debug.py @@ -1,4 +1,5 @@ -from typing import Callable, Optional, Sequence +from collections.abc import Sequence +from typing import Callable, Optional import cv2 import numpy as np diff --git a/bitbots_vision/bitbots_vision/vision_modules/yoeo/detectors.py b/bitbots_vision/bitbots_vision/vision_modules/yoeo/detectors.py index 50bcb623e..ccaa81b8e 100644 --- a/bitbots_vision/bitbots_vision/vision_modules/yoeo/detectors.py +++ b/bitbots_vision/bitbots_vision/vision_modules/yoeo/detectors.py @@ -179,8 +179,7 @@ def set_image(self, image) -> None: self._yoeo_handler.set_image(image) @abstractmethod - def get_mask(self): - ... + def get_mask(self): ... class BackgroundSegmentation(SegmentationTemplate): diff --git a/bitbots_vision/bitbots_vision/vision_modules/yoeo/object_manager.py b/bitbots_vision/bitbots_vision/vision_modules/yoeo/object_manager.py index aeb9e28d9..3aadfb974 100644 --- a/bitbots_vision/bitbots_vision/vision_modules/yoeo/object_manager.py +++ b/bitbots_vision/bitbots_vision/vision_modules/yoeo/object_manager.py @@ -1,5 +1,5 @@ import os.path as osp -from typing import Optional, Type +from typing import Optional import rclpy @@ -16,7 +16,7 @@ class YOEOObjectManager: This class manages the creation and update of the YOEO handler instance. """ - _HANDLERS_BY_NAME: dict[str, Type[yoeo_handlers.YOEOHandlerTemplate]] = { + _HANDLERS_BY_NAME: dict[str, type[yoeo_handlers.YOEOHandlerTemplate]] = { "openvino": yoeo_handlers.YOEOHandlerOpenVino, "onnx": yoeo_handlers.YOEOHandlerONNX, "pytorch": yoeo_handlers.YOEOHandlerPytorch, diff --git a/bitbots_vision/bitbots_vision/vision_modules/yoeo/yoeo_handlers.py b/bitbots_vision/bitbots_vision/vision_modules/yoeo/yoeo_handlers.py index a621fe7b7..9409dc3ea 100644 --- a/bitbots_vision/bitbots_vision/vision_modules/yoeo/yoeo_handlers.py +++ b/bitbots_vision/bitbots_vision/vision_modules/yoeo/yoeo_handlers.py @@ -131,9 +131,9 @@ def get_available_segmentation_class_names(self) -> list[str]: return self._seg_class_names def get_detection_candidates_for(self, class_name: str) -> list[Candidate]: - assert ( - class_name in self._det_class_names - ), f"Class '{class_name}' is not available for the current YOEO model (detection)" + assert class_name in self._det_class_names, ( + f"Class '{class_name}' is not available for the current YOEO model (detection)" + ) self.predict() @@ -143,9 +143,9 @@ def get_robot_class_ids(self) -> list[int]: return self._det_robot_class_ids def get_segmentation_mask_for(self, class_name: str): - assert ( - class_name in self._seg_class_names - ), f"Class '{class_name}' ist not available for the current YOEO model (segmentation)" + assert class_name in self._seg_class_names, ( + f"Class '{class_name}' ist not available for the current YOEO model (segmentation)" + ) self.predict() @@ -188,8 +188,7 @@ def _update_image(self, img: np.ndarray) -> None: @staticmethod @abstractmethod - def model_files_exist(model_directory: str) -> bool: - ... + def model_files_exist(model_directory: str) -> bool: ... @abstractmethod def _compute_new_prediction_for(self, image: np.ndarray) -> tuple[np.ndarray, np.ndarray]: diff --git a/bitbots_vision/package.xml b/bitbots_vision/package.xml index fa0dd650d..6f5b75f5e 100644 --- a/bitbots_vision/package.xml +++ b/bitbots_vision/package.xml @@ -41,6 +41,8 @@ vision_opencv ament_mypy + python3-pytest + python3 diff --git a/bitbots_vision/scripts/extract_from_rosbag.py b/bitbots_vision/scripts/extract_from_rosbag.py index e3de043b1..941846dc5 100755 --- a/bitbots_vision/scripts/extract_from_rosbag.py +++ b/bitbots_vision/scripts/extract_from_rosbag.py @@ -119,7 +119,7 @@ def int_input(question, min_int=None, max_int=None): exit() elif len(image_topics_and_info) == 1: # 1 topic found print( - f"Found exactly one topic ({image_topics_and_info[0][0],}) of type sensor_msgs/Image with {image_topics_and_info[0][1].message_count} messages." + f"Found exactly one topic ({(image_topics_and_info[0][0],)}) of type sensor_msgs/Image with {image_topics_and_info[0][1].message_count} messages." ) if image_topics_and_info[0][0] == args.topic: chosen_set_num = 0 diff --git a/bitbots_vision/setup.py b/bitbots_vision/setup.py index 421cb95ee..96b053d04 100755 --- a/bitbots_vision/setup.py +++ b/bitbots_vision/setup.py @@ -23,10 +23,10 @@ "launch", "setuptools", ], + tests_require=["pytest"], zip_safe=True, keywords=["ROS"], license="MIT", - tests_require=["pytest"], entry_points={ "console_scripts": [ "vision = bitbots_vision.vision:main", diff --git a/bitbots_world_model/bitbots_ball_filter/bitbots_ball_filter/ball_filter.py b/bitbots_world_model/bitbots_ball_filter/bitbots_ball_filter/ball_filter.py index f91316ab8..8d9a5e66c 100755 --- a/bitbots_world_model/bitbots_ball_filter/bitbots_ball_filter/ball_filter.py +++ b/bitbots_world_model/bitbots_ball_filter/bitbots_ball_filter/ball_filter.py @@ -206,7 +206,7 @@ def is_estimate_in_fov(self, header: Header) -> bool: # Transform to camera frame try: ball_in_camera_optical_frame = self.tf_buffer.transform( - ball_pose, self.camera_info.header.frame_id, timeout=Duration(nanoseconds=0.5 * (10**9)) + ball_pose, self.camera_info.header.frame_id, timeout=Duration(nanoseconds=int(0.5 * 1e9)) ) except (tf2.ConnectivityException, tf2.LookupException, tf2.ExtrapolationException) as e: self.logger.warning(str(e)) diff --git a/bitbots_world_model/bitbots_ball_filter/package.xml b/bitbots_world_model/bitbots_ball_filter/package.xml index 85f944fa4..73df18f0f 100644 --- a/bitbots_world_model/bitbots_ball_filter/package.xml +++ b/bitbots_world_model/bitbots_ball_filter/package.xml @@ -24,6 +24,8 @@ tf2_geometry_msgs ament_mypy + python3-pytest + python3 diff --git a/bitbots_world_model/bitbots_ball_filter/setup.py b/bitbots_world_model/bitbots_ball_filter/setup.py index c9ed710f2..c98cbb296 100644 --- a/bitbots_world_model/bitbots_ball_filter/setup.py +++ b/bitbots_world_model/bitbots_ball_filter/setup.py @@ -24,10 +24,10 @@ "launch", "setuptools", ], + tests_require=["pytest"], zip_safe=True, keywords=["ROS"], license="MIT", - tests_require=["pytest"], entry_points={ "console_scripts": [ "ball_filter = bitbots_ball_filter.ball_filter:main", diff --git a/bitbots_world_model/bitbots_robot_filter/setup.py b/bitbots_world_model/bitbots_robot_filter/setup.py index 3c1d1b074..ce4c50c38 100644 --- a/bitbots_world_model/bitbots_robot_filter/setup.py +++ b/bitbots_world_model/bitbots_robot_filter/setup.py @@ -1,13 +1,13 @@ import glob -from setuptools import setup +from setuptools import find_packages, setup package_name = "bitbots_robot_filter" setup( name=package_name, version="0.0.0", - packages=[package_name], + packages=find_packages(exclude=["test"]), data_files=[ ("share/ament_index/resource_index/packages", ["resource/" + package_name]), ("share/" + package_name, ["package.xml"]), diff --git a/pyproject.toml b/pyproject.toml index b848a36d3..9864c6719 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,8 +2,14 @@ line-length = 120 [tool.ruff.lint] -# Never enforce `E501` (line length violations) -ignore = ["E501", "UP007", "F722"] +# Never enforce +# - `E501` (line length violations) +# - `UP007` (usage of | instead of Union and Optional) +# - `F722` (no forward type references by quoting) +# - `UP037` (non quoted annotations for type hints) +# quotes are required for correct numpy/jax type hinting +# e.g. https://github.com/astral-sh/ruff/issues/13121 +ignore = ["E501", "UP007", "F722", "UP037"] # Additionally enable the following rules # - pycodestyle warnings (`W`) # - flake8-bugbear warnings (`B`) diff --git a/requirements/common.txt b/requirements/common.txt index e48c44278..81ad75960 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -3,6 +3,9 @@ pip transforms3d==0.4.1 git+https://github.com/bit-bots/YOEO git+https://github.com/bit-bots/bitbots_rust_nav +git+https://github.com/timonegk/colcon-core.git@colors +git+https://github.com/timonegk/colcon-notification.git@colors +git+https://github.com/timonegk/colcon-output.git@colors simpleeval beartype jaxtyping diff --git a/scripts/deploy/misc.py b/scripts/deploy/misc.py index 1e43758c3..50ead7e49 100644 --- a/scripts/deploy/misc.py +++ b/scripts/deploy/misc.py @@ -3,7 +3,8 @@ import os import subprocess import sys -from typing import Any, Iterable, Optional +from collections.abc import Iterable +from typing import Any, Optional import yaml from fabric import Connection, GroupResult, ThreadingGroup diff --git a/scripts/deploy/tasks/build.py b/scripts/deploy/tasks/build.py index feb7f68c4..610d413d2 100644 --- a/scripts/deploy/tasks/build.py +++ b/scripts/deploy/tasks/build.py @@ -76,7 +76,7 @@ def _build(self, connections: Group) -> GroupResult: cmd = ( "sync;" f"cd {self._remote_workspace};" - "source /opt/ros/iron/setup.zsh;" + "source /opt/ros/jazzy/setup.zsh;" "ISOLATED_CPUS=\"$(grep -oP 'isolcpus=\\K([\\d-]+)' /proc/cmdline)\";" # type: ignore[reportInvalidStringEscapeSequence] f"chrt -r 1 taskset -c ${{ISOLATED_CPUS:-0-15}} colcon build --symlink-install {package_option} --continue-on-error || exit 1;" "sync;" diff --git a/scripts/deploy/tasks/install.py b/scripts/deploy/tasks/install.py index ffb52ba04..2c9c5dac4 100644 --- a/scripts/deploy/tasks/install.py +++ b/scripts/deploy/tasks/install.py @@ -135,7 +135,7 @@ def _install_rosdeps(self, connections: Group) -> GroupResult: remote_src_path = os.path.join(self._remote_workspace, "src") print_debug(f"Gathering rosdep install commands in {remote_src_path}") - cmd = f"rosdep update --include-eol-distros && rosdep install --simulate --default-yes --ignore-src --from-paths {remote_src_path}" + cmd = f"rosdep update && rosdep install --rosdistro jazzy --simulate --default-yes --ignore-src --from-paths {remote_src_path}" print_debug(f"Calling {cmd}") try: gather_results = connections.run(cmd, hide=hide_output()) @@ -177,9 +177,9 @@ def _install_commands_on_single_host(connection: Connection, result: Result) -> apt_command_prefix = "sudo -H apt-get install -y " apt_packages: list[str] = [] - install_result: Optional[ - Result - ] = None # This collects the result of the last run install command, failed if exception occurred + install_result: Optional[Result] = ( + None # This collects the result of the last run install command, failed if exception occurred + ) for install_command in install_commands: if install_command.startswith(apt_command_prefix): # Remove prefix from command, as we collect all apt commands into one @@ -232,7 +232,7 @@ def _pip_upgrade(self, connections: Group) -> GroupResult: """ print_debug("Upgrading pip packages") - cmd = f"pip3 install --upgrade -r {self._remote_workspace}/src/requirements/robot.txt" + cmd = f"pip3 install --user --upgrade --break-system-packages -r {self._remote_workspace}/src/requirements/robot.txt" print_debug(f"Calling {cmd}") try: upgrade_results = connections.run(cmd, hide=hide_output()) diff --git a/scripts/robot_compile.py b/scripts/robot_compile.py deleted file mode 100755 index f8ade01d5..000000000 --- a/scripts/robot_compile.py +++ /dev/null @@ -1,534 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import ipaddress -import os -import subprocess -import sys - -import yaml - -print( - DeprecationWarning( - "WARNING: This script is deprecated. Use 'deploy_robot.py' instead. Please remove this script in the future." - ) -) - - -class LOGLEVEL: - current = 2 - DEBUG = 3 - INFO = 2 - WARN = 1 - ERR_SUCCESS = 0 - - -BITBOTS_MAIN = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -def print_err(msg): - if LOGLEVEL.current >= LOGLEVEL.ERR_SUCCESS: - print("\033[91m\033[1m##" + "".join(["#"] * len(str(msg))) + "##\033[0m") - print("\033[91m\033[1m# " + "".join([" "] * len(str(msg))) + " #\033[0m") - print("\033[91m\033[1m# " + str(msg) + " #\033[0m") - print("\033[91m\033[1m# " + "".join([" "] * len(str(msg))) + " #\033[0m") - print("\033[91m\033[1m##" + "".join(["#"] * len(str(msg))) + "##\033[0m") - - -def print_warn(msg): - if LOGLEVEL.current >= LOGLEVEL.WARN: - print("\033[93m\033[1m# " + "".join([" "] * len(str(msg))) + " #\033[0m") - print("\033[93m\033[1m# " + str(msg) + " #\033[0m") - print("\033[93m\033[1m# " + "".join([" "] * len(str(msg))) + " #\033[0m") - - -def print_success(msg): - if LOGLEVEL.current >= LOGLEVEL.ERR_SUCCESS: - print("\033[92m\033[1m# " + "".join([" "] * len(str(msg))) + " #\033[0m") - print("\033[92m\033[1m# " + str(msg) + " #\033[0m") - print("\033[92m\033[1m# " + "".join([" "] * len(str(msg))) + " #\033[0m") - - -def print_info(msg): - if LOGLEVEL.current >= LOGLEVEL.INFO: - print("\033[96m" + str(msg) + "\033[0m") - - -def print_debug(msg): - if LOGLEVEL.current >= LOGLEVEL.DEBUG: - print(msg) - - -def print_bit_bot(): - print( - """\033[1m - `/shNMoyymmmmmmmmmmys+NmNs/` - `+mmdddmmmddddddddddddmmmdddmm/ - ymdddddddmmmmmmmmmmmmmmdddddddms - .dmdddddddddddmddddddmmddddddddddmy` - .mmdddddddddddmyoooooosddddddddddddms` - .ssshmdddddddddddddmhsooshddddddddddddddmhsss. - -+shysshddddmddddmdddddddddddddddmdhhhhdmdddhssyhs+- - :ddyyyyydddy+/////+shddddddddddddy+//////+sdddyyyyydd: - `mmh/+hdddh///////////sdddddddddd+///++++////hdddh+/hmm` - omdddddmmy///sdNNNmy///omddddddd+//odNMMNmo///hdmdddddmo - `dddddddmm+//yMMMMMMMh///hdddmddh//oNMMMMMMNo//smmddddddd` - .Nddddddmm+//hMMMMMMMd///hdhNNddh//+NMMMMMMNo//ymmddddddN. - .mNNNNNNNdh///yNMMMNd+//sdddddddds//+hmNNmho//oddmmNNNNNm. --ydddmmmmNmdh+///+++////yddddddddddy//////////sddmNmmmmdddy- -:sddddddymNdddyo+////oyddddddddddddddys++++oyddddddydddddds: -/hddddddh::Nddddmdddmdddddddddddddddddddmmdddddmm.:hdddddhh/ -:dhhhhyhh. :dmddddddddddddddddddddddddddddddddmy. .hhyhhhhd: -/mhhhhyo/ `omdddddddddddddddddddddddddddddmmo` /oyhhhhm/ -/hhhhd` `ommddddddddddddddddddddddddmmo` `dhhhh/ -/hhhhd+ `+ymdddddddddddddddddddddy:` +dhhhh/ -mhhhhds +:mhhdhmmmmmddmmmmNmhhhs/: sdhhhhm -mhhhhm. .mNhsshmN.-//:///-hNdyoydMm .mhhhhm -mhhhhs oNNy//ymN` yNho:omNd shhhhm -dhhss` +NMNsyNNN` yNNm+dNNd `sshhd -dhdh/. +NNdyyNNm` yNNdyhNNd ./hdhd -mhssy+ +dddddddm` ydddddddd +ysshm -hy- +dddddddm` ydddddddd -yh - `hmmmmmmmm+ -dmmmmmmmm: - `Nddddddddy :mdddddddm+ - `Nddddddddy :mdddddddm+ - `Ndddddddmy :mdddddddm+ - `mddddddddy :mdddddddd+ - `mddddddddy :mdddddddd+ - `mmNmohNNdy :mmNmohmNm+ - `NNmdhdmNmh /NmmdhddNms - `/mms+-/ymm: ymho-:odmh/. - yo+hsoooshs -hsooosys+y: - h+++++++oo+ `ho+++++++s: - dysssssssy+ `dsssssssyh: -\033[0m""" - ) - - -class Target: - class Workspaces: - amy = "colcon_ws" - rory = "colcon_ws" - jack = "colcon_ws" - donna = "colcon_ws" - melody = "colcon_ws" - rose = "colcon_ws" - - class RobotComputers: - amy = ["nuc1"] - rory = ["nuc2"] - jack = ["nuc3"] - donna = ["nuc4"] - melody = ["nuc5"] - rose = ["nuc6"] - - class IPs: - __prefix__ = "172.20.1." - nuc1 = __prefix__ + "11" - nuc2 = __prefix__ + "12" - nuc3 = __prefix__ + "13" - nuc4 = __prefix__ + "14" - nuc5 = __prefix__ + "15" - nuc6 = __prefix__ + "16" - - def __init__(self, ip, ssh_target, hostname=None, robot_name=None): - """ - :type ip: str - :type ssh_target: str - """ - self.ip = ip # type: str - self.ssh_target = ssh_target # type: str - - # figure out hostname - if hostname: - self.hostname = hostname - else: - for name, iip in self.IPs.__dict__.items(): - if isinstance(ip, str) and iip == ip: - self.hostname = name - - # figure out robot_name - if robot_name: - self.robot_name = robot_name - else: - for name, computers in self.RobotComputers.__dict__.items(): - if isinstance(computers, list) and self.hostname in computers: - self.robot_name = name - - self.workspace = getattr(self.Workspaces, self.robot_name) # type: str - - self.sync_includes_file = os.path.join(BITBOTS_MAIN, f"sync_includes_wolfgang_{self.hostname[:-1]}.yaml") - - -def parse_arguments(): - parser = argparse.ArgumentParser( - description="Compile and configure software for the Wolfgang humanoid robot " "platform" - ) - parser.add_argument( - "target", - type=str, - help="The target robot or computer you want to compile for. Multiple " - "targets can be specified seperated by ,", - ) - - mode = parser.add_mutually_exclusive_group(required=False) - mode.add_argument("-s", "--sync-only", action="store_true", help="Only sync file from you to the target") - mode.add_argument("-c", "--compile-only", action="store_true", help="Only build on the target") - mode.add_argument("-k", "--configure", action="store_true", help="Configure the target as well as everything else") - mode.add_argument("-K", "--configure-only", action="store_true", help="Only configure the target") - - parser.add_argument("-p", "--package", default="", help="Sync/Compile only the given ROS package") - parser.add_argument("-y", "--yes-to-all", action="store_true", help="Answer yes to all questions") - parser.add_argument( - "--clean-build", - action="store_true", - help="Clean workspace before building. If --package is given, clean only that package", - ) - parser.add_argument("--clean-src", action="store_true", help="Clean source directory before syncing") - parser.add_argument( - "--no-rosdeps", - action="store_false", - default=True, - dest="install_rosdeps", - help="Don't install rosdeps on the target." "Might be useful when no internet connection is available.", - ) - parser.add_argument("--print-bit-bot", action="store_true", default=False, help="Print our logo at script start") - parser.add_argument("-v", "--verbose", action="count", default=0, help="More output") - parser.add_argument("-q", "--quiet", action="count", default=0, help="Less output") - return parser.parse_args() - - -def parse_targets(targets): - """ - Parse target argument into usable Targets - - :type targets: str - :rtype: list - """ - res = [] - - for target in targets.split(","): - # this means, a whole robot is meant - if hasattr(Target.RobotComputers, target): - for computer in getattr(Target.RobotComputers, target): - res.append(Target(getattr(Target.IPs, computer), getattr(Target.IPs, computer))) - print_info( - f"Using robot={res[-1].robot_name} hostname={res[-1].hostname} ip={res[-1].ip} for target {target}" - ) - - # this mean, a hostname was specified - elif hasattr(Target.IPs, target): - res.append(Target(getattr(Target.IPs, target), target)) - print_info( - f"Using robot={res[-1].robot_name} hostname={res[-1].hostname} ip={res[-1].ip} for target {target}" - ) - - # this means a known IP address was specified - elif target in Target.IPs.__dict__.values(): - res.append(Target(target, target)) - print_info( - f"Using robot={res[-1].robot_name} hostname={res[-1].hostname} ip={res[-1].ip} for target {target}" - ) - - # this means an arbitrary target (likely an IP) was specified - else: - try: - ipaddress.ip_address(target) - except ValueError: - print_err(f"{target} is neither a known target nor a valid ip address") - sys.exit(1) - - cmd = ["ssh", f"bitbots@{target}", "cat /etc/hostname"] - host_inspect_result = subprocess.run(cmd, stdout=subprocess.PIPE, encoding="utf-8") - - if host_inspect_result.returncode != 0: - print_err(f"Unable to connect to {target}") - sys.exit(1) - - hostname = host_inspect_result.stdout.strip() - robot_name = None - for robot, computers in Target.RobotComputers.__dict__.items(): - if isinstance(computers, list) and hostname in computers: - robot_name = robot - break - - if robot_name is None: - print_err(f"{target} does not seem to be part of a known robot") - sys.exit(1) - - res.append(Target(target, target, hostname=hostname, robot_name=robot_name)) - print_info(f"Using robot={robot_name}, hostname={hostname} ip={target} for target {target}") - - return res - - -def get_includes_from_file(file_path, package=""): - """ - Retrieve a list of file to sync from and includes-file - - :param file_path: Path of the includes-file - :type file_path: str - :param package: Limit to file from this package - :type package: str - :returns: (a list of included files, a list of excluded files) - :rtype: tuple[list, list] - """ - includes = list() - with open(file_path) as file: - data = yaml.safe_load(file) - for entry in data["exclude"]: - # --include is right here. No worries. - includes.append(f"--include=- {entry}") - for entry in data["include"]: - if isinstance(entry, dict): - for folder, subfolders in entry.items(): - if package == "": - includes.append(f"--include=+ {folder}") - for subfolder in subfolders: - includes.append(f"--include=+ {folder}/{subfolder}") - includes.append(f"--include=+ {folder}/{subfolder}/**") - elif package in subfolders: - includes.append(f"--include=+ {folder}") - includes.append(f"--include=+ {folder}/{package}") - includes.append(f"--include=+ {folder}/{package}/**") - elif isinstance(entry, str): - if package == "" or package == entry: - includes.append(f"--include=+ {entry}") - includes.append(f"--include=+ {entry}/**") - includes.append("--include=- *") - return includes - - -def _execute_on_target(target, command, catch_output=False): - """ - Execute a command on the given target over ssh - - :type target: Target - :type command: str - :type catch_output: bool - :rtype: subprocess.CompletedProcess - """ - real_cmd = ["ssh", "-t", f"bitbots@{target.ssh_target}", command] - print_debug("Calling {}".format(" ".join(real_cmd))) - - if not catch_output: - return subprocess.run(real_cmd) - else: - return subprocess.run(real_cmd, text=True, capture_output=True) - - -def _should_run_quietly(): - return LOGLEVEL.current < LOGLEVEL.INFO - - -def sync(target, package="", pre_clean=False): - """ - :type target: Target - :type package: str - :type pre_clean: bool - """ - if pre_clean: - print_info(f"Pre-cleaning on {target.hostname}") - clean_result = _execute_on_target(target, f"rm -rf {target.workspace}/src/*") - if clean_result.returncode != 0: - print_warn(f"Cleaning of source directory on {target.hostname} failed. Continuing anyways") - - print_info(f"Synchronizing {target.hostname}") - cmd = [ - "rsync", - "--checksum", - "--archive", - "--delete", - ] - - if not _should_run_quietly(): - cmd.append("--verbose") - - cmd.extend(get_includes_from_file(target.sync_includes_file, package)) - cmd.extend([BITBOTS_MAIN + "/", f"bitbots@{target.ssh_target}:{target.workspace}/src/"]) - - print_debug("Calling {}".format(" ".join(cmd))) - sync_result = subprocess.run(cmd) - if sync_result.returncode != 0: - print_err(f"Synchronizing {target.hostname} failed with error code {sync_result.returncode}") - sys.exit(sync_result.returncode) - - print_success(f"Synchronization of {target.hostname} successful") - - -def build(target, package="", pre_clean=False): - """ - :type target: Target - :type package: str - :type pre_clean: bool - """ - print_info(f"Building on {target.hostname}") - - if package and pre_clean: - print_err("Cleaning a specific package is not supported! Not cleaning.") - elif pre_clean: - cmd_clean = "rm -rf build install log;" - else: - cmd_clean = "" - - cmd = ( - "sync;" - "cd {workspace};" - "source /opt/ros/iron/setup.zsh;" - "source install/setup.zsh;" - "{cmd_clean}" - "ISOLATED_CPUS=\"$(grep -oP 'isolcpus=\\K([\\d-]+)' /proc/cmdline)\";" - "chrt -r 1 taskset -c ${{ISOLATED_CPUS:-0-15}} colcon build --symlink-install {package} --continue-on-error {quiet_option} || exit 1;" - "sync;" - ).format( - **{ - "workspace": target.workspace, - "cmd_clean": cmd_clean, - "quiet_option": "> /dev/null" if LOGLEVEL.current < LOGLEVEL.INFO else "", - "package": "--packages-up-to " + package if package else "", - } - ) - - build_result = _execute_on_target(target, cmd) - if build_result.returncode != 0: - print_err(f"Build on {target.hostname} failed") - sys.exit(build_result.returncode) - - print_success(f"Build on {target.hostname} succeeded") - - -def install_rosdeps(target): - """ - Install dependencies on a target with rosdep - - :type target: Target - """ - if internet_available(target): - print_info(f"Installing rosdeps on {target.hostname}") - target_src_path = os.path.join(target.workspace, "src") - extra_flags = "-q" if _should_run_quietly() else "" - - cmd = f"rosdep install -y {extra_flags} --rosdistro iron --ignore-src --from-paths {target_src_path}" - - rosdep_result = _execute_on_target(target, cmd) - if rosdep_result.returncode == 0: - print_success(f"Rosdeps on {target.hostname} installed successfully") - else: - print_warn(f"Rosdep install on {target.hostname} had non-zero exit code. Check its output for more info") - else: - print_info(f"Skipping rosdep install on {target.hostname} as we do not have internet") - - -def configure_game_settings(target): - print_info("Configuring game settings") - _execute_on_target( - target, - "python3 ~/colcon_ws/src/bitbots_misc/bitbots_parameter_blackboard/bitbots_parameter_blackboard/game_settings.py", - ) - print_success(f"Game settings on {target.hostname} configured") - - -def configure_wifi(target): - """ - Configure default wifi network on given target. - - :type target: Target - """ - print_info("Configuring Wifi") - - _execute_on_target(target, "nmcli connection show").check_returncode() - connection_id = input("UUID or name of connection which should be enabled [leave unchanged]: ") - - if connection_id != "": - # disable all other connections - connection_ids = ( - str( - _execute_on_target( - target, "nmcli --fields UUID,TYPE connection show | grep wifi | awk '{print $1}'", catch_output=True - ).stdout - ) - .strip() - .split("\n") - ) - for i in connection_ids: - _execute_on_target( - target, f"sudo nmcli connection modify {i} connection.autoconnect FALSE" - ).check_returncode() - _execute_on_target( - target, f"sudo nmcli connection modify {i} connection.autoconnect-priority 0" - ).check_returncode() - - _execute_on_target(target, f"sudo nmcli connection up {connection_id}").check_returncode() - _execute_on_target( - target, f"sudo nmcli connection modify {connection_id} connection.autoconnect TRUE" - ).check_returncode() - _execute_on_target( - target, f"sudo nmcli connection modify {connection_id} connection.autoconnect-priority 100" - ).check_returncode() - - -def internet_available(target): - """ - Check if target has an internet connection by pinging apt repos. - - :type target: Target - :rtype: bool - """ - print_info(f"Checking internet connection on {target.hostname}") - - apt_mirror = "de.archive.ubuntu.com" - redirect_output = "> /dev/null" if _should_run_quietly() else "" - return ( - _execute_on_target(target, f"timeout --foreground 0.5 curl -sSLI {apt_mirror} {redirect_output}").returncode - == 0 - ) - - -def main(): - args = parse_arguments() - - LOGLEVEL.current = LOGLEVEL.current + args.verbose - args.quiet - - if args.print_bit_bot: - print_bit_bot() - - targets = parse_targets(args.target) - - for target in targets: - # sync - if args.compile_only: - print_info(f"Not syncing to {target.hostname} due to compile-only mode") - elif args.configure_only: - print_info(f"Not syncing to {target.hostname} due to configure-only mode") - else: - sync(target, args.package, pre_clean=args.clean_src) - - # configure - if args.sync_only: - print_info(f"Not configuring {target.hostname} due to sync-only mode") - elif args.compile_only: - print_info(f"Not configuring {target.hostname} due to compile-only mode") - elif not (args.configure or args.configure_only): - print_info(f"Not configuring {target.hostname} due to missing --configure") - else: - print_info(f"Running game-settings script for {target.hostname}") - configure_game_settings(target) - configure_wifi(target) - - # build - if args.sync_only: - print_info(f"Not compiling on {target.hostname} due to sync-only mode") - elif args.configure_only: - print_info(f"Not compiling on {target.hostname} due to configure-only mode") - else: - if args.install_rosdeps: - install_rosdeps(target) - build(target, args.package, pre_clean=args.clean_build) - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - print_err("Interrupted by user") - sys.exit(1) diff --git a/scripts/ros.plugin.sh b/scripts/ros.plugin.sh index 5012a0c1f..3fe2f1096 100644 --- a/scripts/ros.plugin.sh +++ b/scripts/ros.plugin.sh @@ -1,7 +1,9 @@ ### Aliases and functions for ROS 2 and colcon usage. Usage for either -### Ubuntu 22.04 or in rosdocked/dev docker container +### Ubuntu 22.04/24.04 or in rosdocked/dev docker container shell="$(basename "$SHELL")" +ros_releases=(iron jazzy rolling) +distro="$ROS_DISTRO" rid() { export ROS_DOMAIN_ID="$1" @@ -12,13 +14,21 @@ rid() { # This needs to be called every time we source something ROS 2 related. # Previous loading of bashcompinit is required. update_ros2_argcomplete() { - eval "$(register-python-argcomplete3 colcon)" - eval "$(register-python-argcomplete3 ros2)" + eval "$(register-python-argcomplete colcon)" + eval "$(register-python-argcomplete ros2)" } -# Source the ROS 2 setup files if iron is installed -if [[ -d /opt/ros/iron ]]; then - source "/opt/ros/iron/setup.$shell" &> /dev/null +# Source the ROS 2 setup files if jazzy is installed +if [[ -n "$distro" ]]; then + source "/opt/ros/$distro/setup.$shell" &> /dev/null +else + for release in "${ros_releases[@]}"; do + if [[ -d "/opt/ros/$release" ]]; then + source "/opt/ros/$release/setup.$shell" &> /dev/null + distro="$release" + break + fi + done fi # Update the tab completion @@ -44,8 +54,9 @@ alias cbs='cdc && colcon build --symlink-install --packages-select' alias cb='cdc && colcon build --symlink-install --continue-on-error --packages-up-to' alias cc='cdc && colcon clean packages --packages-select' alias cca='cdc && colcon clean packages' +alias ct='cdc && colcon test --event-handlers console_direct+ --return-code-on-test-failure' -alias sr="source /opt/ros/iron/setup.$shell && update_ros2_argcomplete" +alias sr="source /opt/ros/$distro/setup.$shell && update_ros2_argcomplete" alias sc="source \$COLCON_WS/install/setup.$shell && update_ros2_argcomplete" alias sa='sr && sc' diff --git a/scripts/setup.sh b/scripts/setup.sh index 4cb63208c..e3a3ecea3 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -2,16 +2,20 @@ set -eEuo pipefail # static/global variables -ROS_DISTRO=${ROS_DISTRO:-"iron"} DIR="$(dirname "$(readlink -f "$0")")" +BRANCH="${1:-main}" +ROS_DISTRO=${ROS_DISTRO:-"jazzy"} COLCON_WS="${COLCON_WS:-"$HOME/colcon_ws"}" REPO_URL="git@github.com:bit-bots/bitbots_main.git" SHELL_CONFIG="$(cat <>> bit-bots initialize >>> +# Add python pip bins to PATH +export PATH="\$HOME/.local/bin:\$PATH" + # Ignore some deprecation warnings -export PYTHONWARNINGS=ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources +export PYTHONWARNINGS="ignore:::setuptools.command.install,ignore:::setuptools.command.easy_install,ignore:::pkg_resources,ignore:easy_install command is deprecated,ignore:setup.py install is deprecated" # Limit ROS 2 communication to localhost (can be overridden when needed) export ROS_DOMAIN_ID=24 @@ -59,7 +63,7 @@ setup_ros() { if [[ ! -f /etc/apt/sources.list.d/ros2.list ]]; then echo "Adding ROS 2 repository..." sudo apt install -y curl lsb-release - curl -fsSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key > /usr/share/keyrings/ros-archive-keyring.gpg + sudo sh -c "curl -fsSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key > /usr/share/keyrings/ros-archive-keyring.gpg" sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main' > /etc/apt/sources.list.d/ros2.list" fi @@ -86,9 +90,11 @@ setup_repo() { if (( in_repo )); then cd "$meta_dir" || exit + git checkout "$BRANCH" else if [[ ! -d "$PWD/bitbots_main" ]]; then git clone "$REPO_URL" + git checkout "$BRANCH" fi meta_dir="$(realpath "$PWD/bitbots_main")" @@ -108,7 +114,7 @@ setup_colcon() { echo "Installing/Updating colcon extensions..." # Install/Update colcon extensions / patches - python3 -m pip install --upgrade --user \ + python3 -m pip install --upgrade --user --break-system-packages \ git+https://github.com/timonegk/colcon-core.git@colors \ git+https://github.com/timonegk/colcon-notification.git@colors \ git+https://github.com/timonegk/colcon-output.git@colors diff --git a/sync_includes_wolfgang_nuc.yaml b/sync_includes_wolfgang_nuc.yaml index 9f8005637..d4ec2808f 100644 --- a/sync_includes_wolfgang_nuc.yaml +++ b/sync_includes_wolfgang_nuc.yaml @@ -57,7 +57,6 @@ include: - game_controller_hl - game_controller_hl_interfaces - humanoid_base_footprint - - imu_tools - ipm - particle_filter - ros2_numpy diff --git a/workspace.repos b/workspace.repos index bcb41fa6b..672de0f73 100644 --- a/workspace.repos +++ b/workspace.repos @@ -3,22 +3,30 @@ repositories: type: git url: git@github.com:bit-bots/RobocupProtocol.git version: master + lib/audio_common: + type: git + url: git@github.com:bit-bots/audio_common.git + version: ros2 + lib/bio_ik: + type: git + url: git@github.com:bit-bots/bio_ik.git + version: ros2 + lib/bio_ik_msgs: + type: git + url: git@github.com:bit-bots/bio_ik_msgs.git + version: master lib/bitbots_tf_buffer: type: git url: git@github.com:bit-bots/bitbots_tf_buffer.git - version: iron + version: main + lib/biped_interfaces: + type: git + url: git@github.com:ros-sports/biped_interfaces.git + version: rolling lib/dynamic_stack_decider: type: git url: git@github.com:bit-bots/dynamic_stack_decider.git version: master - lib/udp_bridge: - type: git - url: git@github.com:bit-bots/udp_bridge.git - version: master - lib/bio_ik_msgs: - type: git - url: git@github.com:bit-bots/bio_ik_msgs.git - version: master lib/DynamixelSDK: type: git url: git@github.com:bit-bots/DynamixelSDK.git @@ -27,26 +35,10 @@ repositories: type: git url: git@github.com:bit-bots/dynamixel-workbench.git version: master - lib/particle_filter: - type: git - url: git@github.com:bit-bots/particle_filter.git - version: iron - lib/ros2_python_extension: - type: git - url: git@github.com:bit-bots/ros2_python_extension.git - version: main - lib/audio_common: - type: git - url: git@github.com:bit-bots/audio_common.git - version: ros2 - lib/biped_interfaces: + lib/game_controller_hl: type: git - url: git@github.com:ros-sports/biped_interfaces.git + url: git@github.com:ros-sports/game_controller_hl.git version: rolling - lib/bio_ik: - type: git - url: git@github.com:bit-bots/bio_ik.git - version: iron lib/hlvs_player: type: git url: git@github.com:ros-sports/hlvs_player.git @@ -55,27 +47,31 @@ repositories: type: git url: git@github.com:ros-sports/humanoid_base_footprint.git version: master - lib/imu_tools: - type: git - url: git@github.com:ccny-ros-pkg/imu_tools.git - version: iron lib/ipm: type: git url: git@github.com:ros-sports/ipm.git version: rolling + lib/particle_filter: + type: git + url: git@github.com:bit-bots/particle_filter.git + version: master lib/ros2_numpy: type: git - url: git@github.com:Bit-Bots/ros2_numpy.git + url: git@github.com:bit-bots/ros2_numpy.git version: rolling - lib/soccer_ipm: + lib/ros2_python_extension: type: git - url: git@github.com:ros-sports/soccer_ipm.git - version: rolling + url: git@github.com:bit-bots/ros2_python_extension.git + version: main lib/soccer_field_map_generator: type: git url: git@github.com:ros-sports/soccer_field_map_generator.git version: rolling - lib/game_controller_hl: + lib/soccer_ipm: type: git - url: git@github.com:ros-sports/game_controller_hl.git + url: git@github.com:ros-sports/soccer_ipm.git version: rolling + lib/udp_bridge: + type: git + url: git@github.com:bit-bots/udp_bridge.git + version: master