Skip to content

Commit ef412fb

Browse files
committed
Use get_package_share_path
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
1 parent b80774e commit ef412fb

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Take a look at my_publisher.cpp
3838
#include <point_cloud_transport/point_cloud_transport.hpp>
3939

4040
// for reading rosbag
41-
#include <ament_index_cpp/get_package_share_directory.hpp>
41+
#include <ament_index_cpp/get_package_share_path.hpp>
4242
#include <rclcpp/serialization.hpp>
4343
#include <rclcpp/rclcpp.hpp>
4444
#include <rosbag2_cpp/reader.hpp>
@@ -59,7 +59,7 @@ int main(int argc, char ** argv)
5959
point_cloud_transport::Publisher pub = pct.advertise("pct/point_cloud", 100);
6060

6161
const std::string bagged_cloud_topic = "/point_cloud";
62-
const std::string shared_directory = ament_index_cpp::get_package_share_directory(
62+
const std::string shared_directory = ament_index_cpp::get_package_share_path(
6363
"point_cloud_transport_tutorial");
6464
const std::string bag_file = shared_directory + "/resources/rosbag2_2023_08_05-16_08_51";
6565

src/my_encoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2828
// POSSIBILITY OF SUCH DAMAGE.
2929

30-
#include <ament_index_cpp/get_package_share_directory.hpp>
30+
#include <ament_index_cpp/get_package_share_path.hpp>
3131
#include <rclcpp/serialization.hpp>
3232
#include <rclcpp/rclcpp.hpp>
3333
#include <rosbag2_cpp/reader.hpp>
@@ -48,9 +48,9 @@ int main(int /*argc*/, char ** /*argv*/)
4848
RCLCPP_INFO(logger_, "Using transport: %s", transport.c_str());
4949

5050
const std::string bagged_cloud_topic = "/point_cloud";
51-
std::filesystem::path shared_directory;
52-
ament_index_cpp::get_package_share_directory("point_cloud_transport_tutorial", shared_directory);
53-
const std::filesystem::path bag_file = shared_directory / "resources" /
51+
const std::filesystem::path bag_file =
52+
ament_index_cpp::get_package_share_path("point_cloud_transport_tutorial") /
53+
"resources" /
5454
"rosbag2_2023_08_05-16_08_51";
5555

5656
// boiler-plate to tell rosbag2 how to read our bag

src/my_publisher.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <string>
3535

3636
// for reading rosbag
37-
#include <ament_index_cpp/get_package_share_directory.hpp>
37+
#include <ament_index_cpp/get_package_share_path.hpp>
3838

3939
#include <point_cloud_transport/point_cloud_transport.hpp>
4040
#include <rclcpp/serialization.hpp>
@@ -59,10 +59,8 @@ int main(int argc, char ** argv)
5959

6060
const std::string bagged_cloud_topic = "/point_cloud";
6161
std::filesystem::path shared_directory;
62-
ament_index_cpp::get_package_share_directory(
63-
"point_cloud_transport_tutorial",
64-
shared_directory);
65-
std::filesystem::path bag_file = shared_directory / "resources" /
62+
std::filesystem::path bag_file =
63+
ament_index_cpp::get_package_share_path("point_cloud_transport_tutorial") / "resources" /
6664
"rosbag2_2023_08_05-16_08_51";
6765

6866
if (argc > 1) {

0 commit comments

Comments
 (0)