采购我自己的 catkin 工作区后 rosrun 不起作用

rosrun does not work after sourcing my own catkin workspace

我正在关注 ROS-tutorial,但在创建自己的包后我遇到了以下行为: 如果尝试执行任何已安装的包(例如 any_package),我会收到以下错误:

[rosrun] Couldn't find executable named <any_package> below /opt/ros/kinetic/share/<any_package>
[rosrun] Found the following, but they're either not files
[rosrun] or not executable:
[rosrun]   /opt/ros/kinetic/share/<any_package>

有什么帮助吗?

编辑: 如果我执行 catkin_find --without-underlays --libexec --share <any_package>,它会给我以下输出:

Multiple packages found with the same name "my_package":
- my_new_package/my_package
- my_new_package/my_package_2

我假设您有一个受污染的工作区。 我假设您只是将 my_package 复制到 my_package_2,而没有编辑 my_package_2 中的 package.xml 文件。 tutorial 中并没有真正提到它,因为它假定您使用正确的命令来创建具有唯一包名称的清单文件。 只需按如下方式编辑名称标签:

<name>my_package</name>

<name>my_package_2</name>

在相应的文件夹中。

You have to make sure you edit CmakeLists.txt according to your compile version, c++ executable declaration & Specify libraries to link a library

Below are step step modification and then run catkin_make before running your project:

step 1
add_compile_options(-std=c++11)

step 2
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_executable(${PROJECT_NAME}_node src/myproject_node.cpp)

step 3

## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME}_node
   ${catkin_LIBRARIES}
 )