質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

解決済

1回答

2319閲覧

ROSのビルドエラー

YOshim

総合スコア1085

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2022/03/30 09:42

編集2022/03/30 09:54

ROSのcostmapに関して下記のコードをcatkin_makeしたところエラーが発生しました。
ROSのバージョンはmelodic、OSはUbuntu18.04です。

cpp

1#include <ros/ros.h> 2#include <tf/transform_listener.h> 3#include <costmap_2d/costmap_2d_ros.h> 4 5int main(int argc, char** argv){ 6 ros::init(argc, argv, "costmap"); 7 tf2_ros::Buffer tfBuffer(ros::Duration(10)); 8 tf2_ros::TransformListener tfListener(tfBuffer); 9 costmap_2d::Costmap2DROS costmap("my_costmap", tfBuffer); 10 ros::NodeHandle n; 11 costmap.start(); 12 ros::spin(); 13 return 0; 14}

エラーメッセージ等。

CMakeFiles/costmap.dir/src/costmap_test.cpp.o: In function `main': costmap_test.cpp:(.text+0x150): undefined reference to `costmap_2d::Costmap2DROS::Costmap2DROS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tf2_ros::Buffer&)' costmap_test.cpp:(.text+0x20f): undefined reference to `costmap_2d::Costmap2DROS::start()' costmap_test.cpp:(.text+0x237): undefined reference to `costmap_2d::Costmap2DROS::~Costmap2DROS()' costmap_test.cpp:(.text+0x329): undefined reference to `costmap_2d::Costmap2DROS::~Costmap2DROS()' collect2: error: ld returned 1 exit status TestPkg/CMakeFiles/costmap.dir/build.make:117: recipe for target '~/catkin_ws/devel/lib/TestPkg/costmap' failed make[2]: *** [~/catkin_ws/devel/lib/TestPkg/costmap] Error 1 CMakeFiles/Makefile2:567: recipe for target 'TestPkg/CMakeFiles/costmap.dir/all' failed make[1]: *** [TestPkg/CMakeFiles/costmap.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [100%] Built target move_base_node Makefile:140: recipe for target 'all' failed make: *** [all] Error 2

原因がわからず困っております。対処方法をご存じの方がいっらしゃればご教授頂きたく。

以上、宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

CMakeLists.txtに下記を記載することで対応できました。

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs costmap_2d )

投稿2022/03/30 10:45

YOshim

総合スコア1085

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問