Skip to content

Commit 80d5fa4

Browse files
authored
Update to ubuntu 22.04 (#2270)
1 parent 0040240 commit 80d5fa4

File tree

15 files changed

+100
-39
lines changed

15 files changed

+100
-39
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
6767
# Because we use ninja, we have to explicitly turn on color output for the compiler
6868
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
6969
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -Werror=return-stack-address -Werror=switch")
70-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
70+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld-16")
7171
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
7272
else()
7373
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++`.")

changelog.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Important changes were made when upgrading the stack to ROS2 Humble. A list
2+
of changes and the reasoning behind them is listed below:
3+
4+
As of Nov 19, 2023:
5+
1. The makefile was changed to work with the newer version of CMake
6+
that installs by default on Ubuntu 22.04. In particular, the
7+
cmake commands no longer need the --target flag. The CMAKE_PREFIX_PATH
8+
variable at the beginning of the file has also been changed.
9+
10+
############## This change is important ###############
11+
2. install/setup.bash - This has not been changed, but it is important
12+
to note that distutils is deprecated and slated for removal in
13+
Python 3.12. There are no direct replacements for distutils, so
14+
a ticket should be opened ASAP to fix this. However, there is no
15+
immediate issue with leaving it as is because Ubuntu 22.04 comes with
16+
Python 3.10 by default. Do note that this is also the case in
17+
install/setup.zsh.
18+
19+
3. source.bash - Source commands now reference humble and Ubuntu 22.04
20+
instead of foxy and Ubuntu 20.04.
21+
22+
4. rj_common/testing/rj_common_convert_test.cpp - the rclcpp::Duration
23+
class no longer accepts a single integer argument for milliseconds.
24+
Updated a line referencing this outdated constructor to use
25+
a std::chrono::milliseconds instead.
26+
27+
5. rj_common/include/rj_common/time.hpp - Changed for similar reasons to (4)
28+
29+
6. rj_utils/src/logging.cpp - RCLCPP_DEBUG and similar macros accept
30+
C strings now; updated calls to these macros
31+
32+
7. rj_config/CMakeLists.txt - added find_package(fmt), this change complements
33+
change number 6.
34+
35+
8. soccer/src/soccer/strategy/agent/agent_action_client.cpp and hpp -
36+
Updated lines 211 to 219 to use lambda expressions instead of std::bind,
37+
Changed a method to take in a different parameter type.
38+
Previously took a future template holding a GoalHandleRobotMove::SharedPtr,
39+
Now just takes in the GoalHandleRobotMove::SharedPtr.
40+
41+
9. soccer/src/soccer/ui/field_view.cpp - Added a preprocessor directive
42+
to include QPainterPath, which has been separated into its own namespace.
43+
Qt5 likely has other changes as well
44+
45+
10. soccer/src/soccer/ui/robot_status_widget.hpp - Added a preprocessor
46+
directive to include the std::optional namespace.
47+
48+
This changelog should be updated to reflect any further changes completed
49+
before this upgrade is fully adopted.

install/setup.bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ _pythonpath_add() {
3030
fi
3131
}
3232

33+
# NOTE: Distutils is deprecated and scheduled to be removed in Python3.12.
34+
# No direct replacement for the command exists, and in Ubuntu 22.04,
35+
# this script will produce a warning about this. We may need to find a
36+
# replacement library in the future.
3337
_PYTHON_LIB_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix='${_INSTALL_PATH}'))")
3438
_pythonpath_add "${_PYTHON_LIB_PATH}"
3539
unset _PYTHON_LIB_PATH

makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL=/bin/bash -o pipefail
22
MAKE_FLAGS = --no-print-directory
33
TESTS = *
44
FIRMWR_TESTS = -i2c -io-expander -fpga -piezo -neopixel -attiny -led -radio-sender -radio-receiver
5-
export CMAKE_PREFIX_PATH=/opt/ros/foxy
5+
export CMAKE_PREFIX_PATH=/opt/ros/humble
66

77
# circleci has 2 cores, but advertises 32, which causes OOMs
88
ifeq ($(CIRCLECI), true)
@@ -20,17 +20,17 @@ CMAKE_FLAGS=-DCMAKE_INSTALL_PREFIX="$(shell pwd)/install" -DNO_WALL=ON -DCMAKE_C
2020
# usage: $(call cmake_build_target, target, extraCmakeFlags)
2121
define cmake_build_target
2222
mkdir -p build-debug
23-
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
23+
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
2424
endef
2525

2626
define cmake_build_target_release
2727
mkdir -p build-release
28-
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
28+
cd build-release && cmake -GNinja -Wno-dev -DNO_WALL=ON -DCMAKE_BUILD_TYPE=Release $(CMAKE_FLAGS) -DBUILD_TESTS=ON .. && ninja $(NINJA_FLAGS) $1 install
2929
endef
3030

3131
define cmake_build_target_perf
3232
mkdir -p build-release-debug
33-
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
33+
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
3434
endef
3535

3636
all-perf:

rj_common/include/rj_common/time.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,12 @@ struct RosConverter<RJ::Time, builtin_interfaces::msg::Time> {
9898
return RosConverter<RJ::Time, rclcpp::Time>::from_ros(value);
9999
}
100100
};
101-
101+
//std::chrono::duration_cast<std::chrono::nanoseconds>(value).count()
102102
template <>
103103
struct RosConverter<RJ::Seconds, rclcpp::Duration> {
104104
static rclcpp::Duration to_ros(const RJ::Seconds& value) {
105105
return rclcpp::Duration(
106-
std::chrono::duration_cast<std::chrono::nanoseconds>(value)
107-
.count());
106+
std::chrono::duration_cast<std::chrono::nanoseconds>(value));
108107
}
109108
static RJ::Seconds from_ros(const rclcpp::Duration& value) {
110109
const std::chrono::nanoseconds dur(value.nanoseconds());
@@ -126,4 +125,4 @@ struct RosConverter<RJ::Seconds, builtin_interfaces::msg::Duration> {
126125

127126
ASSOCIATE_CPP_ROS(RJ::Seconds, builtin_interfaces::msg::Duration);
128127

129-
} // namespace rj_convert
128+
} // namespace rj_convert

rj_common/testing/rj_common_convert_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ TEST(ROSConvert, duration_lossless_convert) {
1212
// We don't expect perfect equality for seconds, because float comparisons.
1313
using Cvt = rj_convert::RosConverter<RJ::Seconds, rclcpp::Duration>;
1414
EXPECT_NEAR(Cvt::from_ros(Cvt::to_ros(RJ::Seconds(1.0))).count(), 1.0, 1e-6);
15-
EXPECT_NEAR(Cvt::to_ros(Cvt::from_ros(rclcpp::Duration(12345))).nanoseconds(), 12345, 1);
15+
EXPECT_NEAR(Cvt::to_ros(Cvt::from_ros(rclcpp::Duration(std::chrono::nanoseconds(12345)))).nanoseconds(), 12345, 1);
1616
}

rj_config/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ project(rj_config)
99
# ======================================================================
1010
find_package(rclcpp REQUIRED)
1111
find_package(rj_msgs REQUIRED)
12+
find_package(fmt REQUIRED)
1213

1314
# ======================================================================
1415
# Define Targets
@@ -25,7 +26,7 @@ add_subdirectory(src)
2526
# ======================================================================
2627
set(RJ_CONFIG_DEPS_INCLUDE_DIRS include)
2728

28-
set(RJ_CONFIG_DEPS_LIBRARIES rj_constants rj_common rj_utils)
29+
set(RJ_CONFIG_DEPS_LIBRARIES rj_constants rj_common rj_utils fmt)
2930

3031
# ======================================================================
3132
# Include and Linking

rj_utils/src/logging.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ void Ros2Sink<Mutex>::sink_it_(const spdlog::details::log_msg& msg) {
3030
switch (msg.level) {
3131
case spdlog::level::trace:
3232
case spdlog::level::debug:
33-
RCLCPP_DEBUG(logger, string); // NOLINT
33+
RCLCPP_DEBUG(logger, string.c_str()); // NOLINT
3434
break;
3535
case spdlog::level::info:
36-
RCLCPP_INFO(logger, string); // NOLINT
36+
RCLCPP_INFO(logger, string.c_str()); // NOLINT
3737
break;
3838
case spdlog::level::warn:
39-
RCLCPP_WARN(logger, string); // NOLINT
39+
RCLCPP_WARN(logger, string.c_str()); // NOLINT
4040
break;
4141
case spdlog::level::err:
42-
RCLCPP_ERROR(logger, string); // NOLINT
42+
RCLCPP_ERROR(logger, string.c_str()); // NOLINT
4343
break;
4444
case spdlog::level::critical:
45-
RCLCPP_FATAL(logger, string); // NOLINT
45+
RCLCPP_FATAL(logger, string.c_str()); // NOLINT
4646
break;
4747
case spdlog::level::off:
4848
break;
@@ -58,4 +58,4 @@ void set_spdlog_default_ros2(const std::string& logger_name) {
5858
ros2_logger->set_pattern("[%s:%#] %v");
5959
spdlog::set_default_logger(std::move(ros2_logger));
6060
}
61-
} // namespace rj_utils
61+
} // namespace rj_utils

soccer/src/soccer/strategy/agent/agent_action_client.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,15 @@ void AgentActionClient::send_new_goal() {
177177
goal_msg.robot_intent = rj_convert::convert_to_ros(last_task_);
178178

179179
auto send_goal_options = rclcpp_action::Client<RobotMove>::SendGoalOptions();
180-
send_goal_options.goal_response_callback =
181-
std::bind(&AgentActionClient::goal_response_callback, this, _1);
182-
send_goal_options.feedback_callback =
183-
std::bind(&AgentActionClient::feedback_callback, this, _1, _2);
184-
send_goal_options.result_callback = std::bind(&AgentActionClient::result_callback, this, _1);
180+
send_goal_options.goal_response_callback = [this](auto arg) {
181+
goal_response_callback(arg);
182+
};
183+
send_goal_options.feedback_callback = [this](auto arg1, auto arg2) {
184+
feedback_callback(arg1, arg2);
185+
};
186+
send_goal_options.result_callback = [this](auto arg) {
187+
result_callback(arg);
188+
};
185189
client_ptr_->async_send_goal(goal_msg, send_goal_options);
186190
}
187191

@@ -196,8 +200,8 @@ void AgentActionClient::send_new_goal() {
196200
// situation based on the current tick.
197201

198202
void AgentActionClient::goal_response_callback(
199-
std::shared_future<GoalHandleRobotMove::SharedPtr> future) {
200-
auto goal_handle = future.get();
203+
GoalHandleRobotMove::SharedPtr goal_handle) {
204+
201205
if (!goal_handle) {
202206
current_position_->set_goal_canceled();
203207
}

soccer/src/soccer/strategy/agent/agent_action_client.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class AgentActionClient : public rclcpp::Node {
7474

7575
// ROS ActionClient spec, for calls to planning ActionServer
7676
rclcpp_action::Client<RobotMove>::SharedPtr client_ptr_;
77-
void goal_response_callback(std::shared_future<GoalHandleRobotMove::SharedPtr> future);
77+
void goal_response_callback(GoalHandleRobotMove::SharedPtr future);
7878
void feedback_callback(GoalHandleRobotMove::SharedPtr,
7979
const std::shared_ptr<const RobotMove::Feedback> feedback);
8080

0 commit comments

Comments
 (0)