diff --git a/CMakeLists.txt b/CMakeLists.txt index a04557178f1..309774445c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") # Because we use ninja, we have to explicitly turn on color output for the compiler if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -Werror=return-stack-address -Werror=switch") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld-16") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld") else() message(WARNING "You are using GCC; prefer to use clang if it is installed with the flags `-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++`.") diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 00000000000..c251ec1316a --- /dev/null +++ b/changelog.txt @@ -0,0 +1,49 @@ +Important changes were made when upgrading the stack to ROS2 Humble. A list +of changes and the reasoning behind them is listed below: + +As of Nov 19, 2023: +1. The makefile was changed to work with the newer version of CMake + that installs by default on Ubuntu 22.04. In particular, the + cmake commands no longer need the --target flag. The CMAKE_PREFIX_PATH + variable at the beginning of the file has also been changed. + +############## This change is important ############### +2. install/setup.bash - This has not been changed, but it is important + to note that distutils is deprecated and slated for removal in + Python 3.12. There are no direct replacements for distutils, so + a ticket should be opened ASAP to fix this. However, there is no + immediate issue with leaving it as is because Ubuntu 22.04 comes with + Python 3.10 by default. Do note that this is also the case in + install/setup.zsh. + +3. source.bash - Source commands now reference humble and Ubuntu 22.04 + instead of foxy and Ubuntu 20.04. + +4. rj_common/testing/rj_common_convert_test.cpp - the rclcpp::Duration + class no longer accepts a single integer argument for milliseconds. + Updated a line referencing this outdated constructor to use + a std::chrono::milliseconds instead. + +5. rj_common/include/rj_common/time.hpp - Changed for similar reasons to (4) + +6. rj_utils/src/logging.cpp - RCLCPP_DEBUG and similar macros accept + C strings now; updated calls to these macros + +7. rj_config/CMakeLists.txt - added find_package(fmt), this change complements + change number 6. + +8. soccer/src/soccer/strategy/agent/agent_action_client.cpp and hpp - + Updated lines 211 to 219 to use lambda expressions instead of std::bind, + Changed a method to take in a different parameter type. + Previously took a future template holding a GoalHandleRobotMove::SharedPtr, + Now just takes in the GoalHandleRobotMove::SharedPtr. + +9. soccer/src/soccer/ui/field_view.cpp - Added a preprocessor directive + to include QPainterPath, which has been separated into its own namespace. + Qt5 likely has other changes as well + +10. soccer/src/soccer/ui/robot_status_widget.hpp - Added a preprocessor + directive to include the std::optional namespace. + +This changelog should be updated to reflect any further changes completed +before this upgrade is fully adopted. diff --git a/install/setup.bash b/install/setup.bash index 3d79b9501cc..b84bbe02bab 100755 --- a/install/setup.bash +++ b/install/setup.bash @@ -30,6 +30,10 @@ _pythonpath_add() { fi } +# NOTE: Distutils is deprecated and scheduled to be removed in Python3.12. +# No direct replacement for the command exists, and in Ubuntu 22.04, +# this script will produce a warning about this. We may need to find a +# replacement library in the future. _PYTHON_LIB_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix='${_INSTALL_PATH}'))") _pythonpath_add "${_PYTHON_LIB_PATH}" unset _PYTHON_LIB_PATH diff --git a/makefile b/makefile index 8782b85929a..4ddb5959fb1 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ SHELL=/bin/bash -o pipefail MAKE_FLAGS = --no-print-directory TESTS = * FIRMWR_TESTS = -i2c -io-expander -fpga -piezo -neopixel -attiny -led -radio-sender -radio-receiver -export CMAKE_PREFIX_PATH=/opt/ros/foxy +export CMAKE_PREFIX_PATH=/opt/ros/humble # circleci has 2 cores, but advertises 32, which causes OOMs ifeq ($(CIRCLECI), true) @@ -20,17 +20,17 @@ CMAKE_FLAGS=-DCMAKE_INSTALL_PREFIX="$(shell pwd)/install" -DNO_WALL=ON -DCMAKE_C # usage: $(call cmake_build_target, target, extraCmakeFlags) define cmake_build_target mkdir -p build-debug - cd build-debug && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=Debug $(DEBUG_FLAGS) $(CMAKE_FLAGS) --target -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install + cd build-debug && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=Debug $(DEBUG_FLAGS) $(CMAKE_FLAGS) -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install endef define cmake_build_target_release mkdir -p build-release - cd build-release && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=Release $(CMAKE_FLAGS) --target -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install + cd build-release && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=Release $(CMAKE_FLAGS) -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install endef define cmake_build_target_perf mkdir -p build-release-debug - cd build-release-debug && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo $(CMAKE_FLAGS) --target -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install + cd build-release-debug && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo $(CMAKE_FLAGS) -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install endef all-perf: diff --git a/rj_common/include/rj_common/time.hpp b/rj_common/include/rj_common/time.hpp index d3ed6e9d2fd..6f812525aa4 100644 --- a/rj_common/include/rj_common/time.hpp +++ b/rj_common/include/rj_common/time.hpp @@ -98,13 +98,11 @@ struct RosConverter { return RosConverter::from_ros(value); } }; - +// std::chrono::duration_cast(value).count() template <> struct RosConverter { static rclcpp::Duration to_ros(const RJ::Seconds& value) { - return rclcpp::Duration( - std::chrono::duration_cast(value) - .count()); + return rclcpp::Duration(std::chrono::duration_cast(value)); } static RJ::Seconds from_ros(const rclcpp::Duration& value) { const std::chrono::nanoseconds dur(value.nanoseconds()); @@ -126,4 +124,4 @@ struct RosConverter { ASSOCIATE_CPP_ROS(RJ::Seconds, builtin_interfaces::msg::Duration); -} // namespace rj_convert \ No newline at end of file +} // namespace rj_convert diff --git a/rj_common/testing/rj_common_convert_test.cpp b/rj_common/testing/rj_common_convert_test.cpp index 4a257b2c588..4d7ed851bb2 100644 --- a/rj_common/testing/rj_common_convert_test.cpp +++ b/rj_common/testing/rj_common_convert_test.cpp @@ -12,5 +12,7 @@ TEST(ROSConvert, duration_lossless_convert) { // We don't expect perfect equality for seconds, because float comparisons. using Cvt = rj_convert::RosConverter; EXPECT_NEAR(Cvt::from_ros(Cvt::to_ros(RJ::Seconds(1.0))).count(), 1.0, 1e-6); - EXPECT_NEAR(Cvt::to_ros(Cvt::from_ros(rclcpp::Duration(12345))).nanoseconds(), 12345, 1); + EXPECT_NEAR( + Cvt::to_ros(Cvt::from_ros(rclcpp::Duration(std::chrono::nanoseconds(12345)))).nanoseconds(), + 12345, 1); } diff --git a/rj_config/CMakeLists.txt b/rj_config/CMakeLists.txt index 2616e51842f..9a47df81319 100644 --- a/rj_config/CMakeLists.txt +++ b/rj_config/CMakeLists.txt @@ -9,6 +9,7 @@ project(rj_config) # ====================================================================== find_package(rclcpp REQUIRED) find_package(rj_msgs REQUIRED) +find_package(fmt REQUIRED) # ====================================================================== # Define Targets @@ -25,7 +26,7 @@ add_subdirectory(src) # ====================================================================== set(RJ_CONFIG_DEPS_INCLUDE_DIRS include) -set(RJ_CONFIG_DEPS_LIBRARIES rj_constants rj_common rj_utils) +set(RJ_CONFIG_DEPS_LIBRARIES rj_constants rj_common rj_utils fmt) # ====================================================================== # Include and Linking diff --git a/rj_utils/src/logging.cpp b/rj_utils/src/logging.cpp index d6311b9a077..c4999ea0451 100644 --- a/rj_utils/src/logging.cpp +++ b/rj_utils/src/logging.cpp @@ -30,19 +30,19 @@ void Ros2Sink::sink_it_(const spdlog::details::log_msg& msg) { switch (msg.level) { case spdlog::level::trace: case spdlog::level::debug: - RCLCPP_DEBUG(logger, string); // NOLINT + RCLCPP_DEBUG(logger, string.c_str()); // NOLINT break; case spdlog::level::info: - RCLCPP_INFO(logger, string); // NOLINT + RCLCPP_INFO(logger, string.c_str()); // NOLINT break; case spdlog::level::warn: - RCLCPP_WARN(logger, string); // NOLINT + RCLCPP_WARN(logger, string.c_str()); // NOLINT break; case spdlog::level::err: - RCLCPP_ERROR(logger, string); // NOLINT + RCLCPP_ERROR(logger, string.c_str()); // NOLINT break; case spdlog::level::critical: - RCLCPP_FATAL(logger, string); // NOLINT + RCLCPP_FATAL(logger, string.c_str()); // NOLINT break; case spdlog::level::off: break; @@ -58,4 +58,4 @@ void set_spdlog_default_ros2(const std::string& logger_name) { ros2_logger->set_pattern("[%s:%#] %v"); spdlog::set_default_logger(std::move(ros2_logger)); } -} // namespace rj_utils \ No newline at end of file +} // namespace rj_utils diff --git a/soccer/src/soccer/strategy/agent/agent_action_client.cpp b/soccer/src/soccer/strategy/agent/agent_action_client.cpp index ed457d28f1d..9355eb151cd 100644 --- a/soccer/src/soccer/strategy/agent/agent_action_client.cpp +++ b/soccer/src/soccer/strategy/agent/agent_action_client.cpp @@ -177,11 +177,11 @@ void AgentActionClient::send_new_goal() { goal_msg.robot_intent = rj_convert::convert_to_ros(last_task_); auto send_goal_options = rclcpp_action::Client::SendGoalOptions(); - send_goal_options.goal_response_callback = - std::bind(&AgentActionClient::goal_response_callback, this, _1); - send_goal_options.feedback_callback = - std::bind(&AgentActionClient::feedback_callback, this, _1, _2); - send_goal_options.result_callback = std::bind(&AgentActionClient::result_callback, this, _1); + send_goal_options.goal_response_callback = [this](auto arg) { goal_response_callback(arg); }; + send_goal_options.feedback_callback = [this](auto arg1, auto arg2) { + feedback_callback(arg1, arg2); + }; + send_goal_options.result_callback = [this](auto arg) { result_callback(arg); }; client_ptr_->async_send_goal(goal_msg, send_goal_options); } @@ -195,9 +195,7 @@ void AgentActionClient::send_new_goal() { // in the initializer. This will call the class which will analyze the // situation based on the current tick. -void AgentActionClient::goal_response_callback( - std::shared_future future) { - auto goal_handle = future.get(); +void AgentActionClient::goal_response_callback(GoalHandleRobotMove::SharedPtr goal_handle) { if (!goal_handle) { current_position_->set_goal_canceled(); } diff --git a/soccer/src/soccer/strategy/agent/agent_action_client.hpp b/soccer/src/soccer/strategy/agent/agent_action_client.hpp index 6434fb36ed9..fd779524b23 100644 --- a/soccer/src/soccer/strategy/agent/agent_action_client.hpp +++ b/soccer/src/soccer/strategy/agent/agent_action_client.hpp @@ -74,7 +74,7 @@ class AgentActionClient : public rclcpp::Node { // ROS ActionClient spec, for calls to planning ActionServer rclcpp_action::Client::SharedPtr client_ptr_; - void goal_response_callback(std::shared_future future); + void goal_response_callback(GoalHandleRobotMove::SharedPtr future); void feedback_callback(GoalHandleRobotMove::SharedPtr, const std::shared_ptr feedback); diff --git a/soccer/src/soccer/ui/field_view.cpp b/soccer/src/soccer/ui/field_view.cpp index 55f6abfeb3a..9e906bf1373 100644 --- a/soccer/src/soccer/ui/field_view.cpp +++ b/soccer/src/soccer/ui/field_view.cpp @@ -6,17 +6,18 @@ #include #include +#include #include #include -#include -#include -#include #include #include #include #include #include +#include +#include +#include using namespace std; diff --git a/soccer/src/soccer/ui/robot_status_widget.hpp b/soccer/src/soccer/ui/robot_status_widget.hpp index 8addccd34e7..15a2a47f5db 100644 --- a/soccer/src/soccer/ui/robot_status_widget.hpp +++ b/soccer/src/soccer/ui/robot_status_widget.hpp @@ -1,9 +1,11 @@ #pragma once -#include +#include +#include #include -#include + +#include #include "ui_RobotStatusWidget.h" diff --git a/source.bash b/source.bash index 6ec594c1db7..85a5e0bedf1 100755 --- a/source.bash +++ b/source.bash @@ -1,11 +1,11 @@ if [[ $SHELL == *"bash"* ]]; then echo "bash detected, sourcing bash" - source /opt/ros/foxy/setup.bash + source /opt/ros/humble/setup.bash source install/setup.bash fi if [[ $SHELL == *"zsh"* ]]; then echo "zsh detected, sourcing zsh" - source /opt/ros/foxy/setup.zsh + source /opt/ros/humble/setup.zsh source install/setup.zsh fi diff --git a/util/ubuntu-packages.txt b/util/ubuntu-packages.txt index 0b6f50e5cc8..174e9653077 100644 --- a/util/ubuntu-packages.txt +++ b/util/ubuntu-packages.txt @@ -9,7 +9,10 @@ cmake ccache # QT -qt5-default +qtbase5-dev +qtchooser +qt5-qmake +qtbase5-dev-tools qttools5-dev-tools libqt5opengl5-dev libqt5svg5-dev @@ -83,4 +86,4 @@ freeglut3-dev libfmt-dev # "everything else" (aka ros) -ros-foxy-rqt* +ros-humble-rqt* diff --git a/util/ubuntu-setup b/util/ubuntu-setup index f76299c6ba5..08921436927 100755 --- a/util/ubuntu-setup +++ b/util/ubuntu-setup @@ -27,12 +27,12 @@ if cat /etc/os-release | grep -iq '^NAME=.*Debian'; then # don't add repositorie SYSTEM="debian" ADD_REPOS=false elif cat /etc/os-release | grep -iq '^NAME=.*Ubuntu'; then # We are using a version of ubuntu... - if cat /etc/os-release | grep -iq '^VERSION=.*20.04'; then # Using Ubuntu 20.04 - echo "Ubuntu 20.04 Detected..." - SYSTEM="ubuntu-20.04" + if cat /etc/os-release | grep -iq '^VERSION=.*22.04'; then # Using Ubuntu 20.04 + echo "Ubuntu 22.04 Detected..." + SYSTEM="ubuntu-22.04" ADD_REPOS=false else - echo "Sorry, we only support 20.04 due to ROS2." >&2 + echo "Sorry, we only support 22.04 due to ROS2." >&2 echo "$DISTRO_STR" >&2 exit 1 fi @@ -108,7 +108,7 @@ fi if $ADD_REPOS; then # add repo for backport of cmake3 from debian testing # TODO remove this once ubuntu ships cmake3 - sudo add-apt-repository -y ppa:george-edison55/cmake-3.x + # sudo add-apt-repository -y ppa:george-edison55/cmake-3.x # for newer compilers add-apt-repository -y ppa:ubuntu-toolchain-r/test @@ -128,10 +128,10 @@ apt-get install $ARGS wget curl # Somehow we don't have wget wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - # Install clang-format-10 using automatic llvm installation script -if [ "$SYSTEM" = "ubuntu-20.04" ]; then +if [ "$SYSTEM" = "ubuntu-22.04" ]; then wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 10 + sudo ./llvm.sh 16 rm llvm.sh fi @@ -145,8 +145,8 @@ sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main sudo apt-get update # Install eloquent for 18.04, foxy for 20.04 -if [ "$SYSTEM" = "ubuntu-20.04" ]; then - sudo apt-get install -y ros-foxy-ros-base +if [ "$SYSTEM" = "ubuntu-22.04" ]; then + sudo apt-get install -y ros-humble-ros-base fi MACH=$(uname -m)