Skip to content

Commit 79df09a

Browse files
authored
Distro compatibility for get_package_share_path <-> get_package_share_directory breaking change (#47)
* removed backward-ros from package.xml (still kept as optional build dependency) * extended CI to check multiple ROS distros * handling of the discrepancy between get_package_share_path and get_package_share_directory across all ROS distros
1 parent f05a294 commit 79df09a

4 files changed

Lines changed: 37 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@ on: [push, pull_request]
55
jobs:
66
build:
77
runs-on: ubuntu-22.04
8-
container: ros:jazzy
8+
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
include:
13+
- ros_distro: humble
14+
allow_failure: false
15+
- ros_distro: jazzy
16+
allow_failure: false
17+
- ros_distro: kilted
18+
allow_failure: false
19+
- ros_distro: lyrical
20+
allow_failure: false
21+
- ros_distro: rolling
22+
allow_failure: true
23+
24+
continue-on-error: ${{ matrix.allow_failure }}
25+
26+
container: ros:${{ matrix.ros_distro }}
27+
928
steps:
1029
- name: Check out repository code
11-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
1231
with:
1332
submodules: recursive
1433
- name: Configure git checkout as safe directory to allow dubious permission-setup

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ The following features are not implemented yet, but would be nice to have. PRs a
3737
- CPU usage is high when using non-hardware-accelerated OpenGL implementation, which is usually the case in VNC connections
3838
- vsync via glfw doesn't work in VNC sessions (leading to even higher CPU usage), enable the manual frame rate limiting to reduce it
3939

40+
## Notes for Building From Source
41+
42+
- the CMakeLists.txt is prepared to use [backward-ros](https://github.com/pal-robotics/backward_ros), but it is more handled like an optional dependency and thus not part of the package.xml
43+
4044
## Usage example
4145

4246
![Usage example](doc/demo.gif)

package.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<depend>libglfw3-dev</depend>
1515
<depend>rclcpp</depend>
1616
<depend>ament_index_cpp</depend>
17-
<depend>backward_ros</depend>
1817

1918
<export>
2019
<build_type>ament_cmake</build_type>

src/utils.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "utils.hpp"
1010

11+
#include <rclcpp/version.h>
1112
#include <ament_index_cpp/get_package_prefix.hpp>
12-
#include <ament_index_cpp/get_package_share_directory.hpp>
1313
#include <cstdint>
1414
#include <rcl_interfaces/msg/parameter_type.hpp>
1515
#include <cmath>
@@ -19,6 +19,12 @@
1919

2020
#include "lodepng.h"
2121

22+
#if RCLCPP_VERSION_GTE(21, 0, 0) // iron and never
23+
#include <ament_index_cpp/get_package_share_path.hpp>
24+
#else
25+
#include <ament_index_cpp/get_package_share_directory.hpp>
26+
#endif
27+
2228
void highlightedText(const std::string &text, std::size_t start, std::size_t end, const ImVec4 &highlightColor) {
2329
if (start == std::string::npos) {
2430
ImGui::Text("%s", text.c_str());
@@ -181,8 +187,12 @@ std::filesystem::path findResourcePath(const std::string &execPath) {
181187

182188
try {
183189
// Try getting package share dir via ament, and use that if it succeeds.
190+
#if RCLCPP_VERSION_GTE(21, 0, 0) // iron and never
191+
resourcePath = ament_index_cpp::get_package_share_path("rig_reconfigure") / "resource";
192+
#else
184193
resourcePath = ament_index_cpp::get_package_share_directory("rig_reconfigure");
185-
resourcePath.append("resource");
194+
resourcePath.append("resource");
195+
#endif
186196
} catch (ament_index_cpp::PackageNotFoundError &e) {
187197
std::cerr << "Warning: Error while looking for package share directory: " << e.what()
188198
<< "\n";

0 commit comments

Comments
 (0)