1.问题描述
ROS版本:ROS2(foxy)
PX4版本: 主线版本(main)
protobuf版本:3.6.1
Gazebo版本:gazebo11
根据PX4官方网站( PX4 User Guide)安装PX4和ROS2在Gazebo上的仿真测试时,执行make px4_sitl gazebo-classic出现下图问题,说没有找到某些Targets没有定义,只能说冤枉啊,全部都有啊!!!(具体报错提示图片如下所示)
CMake Error at /usr/local/lib/cmake/protobuf/protobuf-targets.cmake:42 (message):
Some (but not all) targets in this export set were already defined.
Targets Defined: protobuf::libprotobuf-lite, protobuf::libprotobuf,
protobuf::libprotoc, protobuf::protoc
Targets not yet defined: protobuf::libupb, protobuf::protoc-gen-upb,
protobuf::protoc-gen-upbdefs, protobuf::protoc-gen-upb_minitable,
protobuf::gmock
Call Stack (most recent call first):
/usr/local/lib/cmake/protobuf/protobuf-config.cmake:16 (include)
/usr/share/cmake/ignition-cmake2/cmake2/FindIgnProtobuf.cmake:29 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/ignition-transport8/ignition-transport8-config.cmake:92 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/gazebo/gazebo-config.cmake:244 (find_package)
src/modules/simulation/simulator_mavlink/sitl_targets_gazebo-classic.cmake:2 (find_package)
src/modules/simulation/simulator_mavlink/CMakeLists.txt:59 (include)
make px4_sitl gazebo-classic
2.解决方法
推测是在编译PX4在寻找Protobuf是没有找到对于的protobuf库导致(在这里感谢同门@scalet-smash帮助,不然又是摸黑查几天啊),在这里直接修改 /usr/share/cmake/ignition-cmake2/cmake2/FindIgnProtobuf.cmake的第29行
cd /usr/share/cmake/ignition-cmake2/cmake2
sudo vim /usr/share/cmake/ignition-cmake2/cmake2/FindIgnProtobuf.cmake
的中find_package(Protobuf ${IgnProtobuf_FIND_VERSION} CONFIG QUIET),删除CONFIG,这样可以直接查找一个名为FindXXX.cmake 的模块文件,而不是查找软件包自带的配置文件XXXConfig.cmake 或 xxx-config.cmake。
#find_package(Protobuf ${IgnProtobuf_FIND_VERSION} CONFIG QUIET)
find_package(Protobuf ${IgnProtobuf_FIND_VERSION} QUIET)
最后我们在再编译,便可以得到下图啦,然后就可以愉快的玩无人机啦!
make px4_sitl gazebo-classic