rosrun无法执行相应的可执行程序
【rosrun无法执行相应的可执行程序】问题描述:创建好了功能区和功能包后catkin_make 编译一切正常。rosrun package_name executable_name时找不到可执行程序(按table联想不出来executable_name),编译没有报错;也进行了source devel/setup.bash,最后发现是CMakeList里边少了一句话catkin_package();这句话顺序好像也会影响到能否找到可执行程序,写的时候最好跟在find_package()这句话后面;这样就能在devel/lib/package_name目录下找到相应的可执行程序
CMakeList.txt的内容
cmake_minimum_required(VERSION 2.8.3)
project(test)
find_package(catkin REQUIRED COMPONENTS roscpp)
catkin_package()##----这句话的位置好像也会影响能否找到包,比如第一次我把这句话写在最后一行好像就有问题
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(count count.cpp)
target_link_libraries(count ${catkin_LIBRARIES})
(1)有问题的catkin_make输出:
exbot@ubuntu:~/catkin_ws$ catkin_make
Base path: /home/exbot/catkin_ws
Source space: /home/exbot/catkin_ws/src
Build space: /home/exbot/catkin_ws/build
Devel space: /home/exbot/catkin_ws/devel
Install space: /home/exbot/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/exbot/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/exbot/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/exbot/catkin_ws/devel;
/opt/ros/indigo
-- This workspace overlays: /home/exbot/catkin_ws/devel;
/opt/ros/indigo
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/exbot/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.11
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~traversing 1 packages in topological order:
-- ~~- test
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'test'
-- ==> add_subdirectory(test)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/exbot/catkin_ws/build
####
#### Running command: "make -j1 -l1" in "/home/exbot/catkin_ws/build"
####
Linking CXX executable count
[100%] Built target count
(2)CMakelist里边添加catkin_package()后的输出:
exbot@ubuntu:~/catkin_ws$ catkin_make
Base path: /home/exbot/catkin_ws
Source space: /home/exbot/catkin_ws/src
Build space: /home/exbot/catkin_ws/build
Devel space: /home/exbot/catkin_ws/devel
Install space: /home/exbot/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/exbot/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/exbot/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/exbot/catkin_ws/devel;
/opt/ros/indigo
-- This workspace overlays: /home/exbot/catkin_ws/devel;
/opt/ros/indigo
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/exbot/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.11
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~traversing 1 packages in topological order:
-- ~~- test
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'test'
-- ==> add_subdirectory(test)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/exbot/catkin_ws/build
####
#### Running command: "make -j1 -l1" in "/home/exbot/catkin_ws/build"
####
Linking CXX executable /home/exbot/catkin_ws/devel/lib/test/count
[100%] Built target count
可以看出倒数第二句和之前不一样了,显示链接到了devel/lib下的可执行程序
之后source devel/setup.bash(或者为了每个终端都配置好环境变量将 source ~/catkin_ws/devel/setup.bash 这句话添加到~.bashrc中去)
然后rosrun package_name executable_name(例如我的包名和可执行程序为 rosrun test count)就可以完美运行了
推荐阅读
- CVE-2020-16898|CVE-2020-16898 TCP/IP远程代码执行漏洞
- 解决SpringBoot引用别的模块无法注入的问题
- Android7.0|Android7.0 第三方应用无法访问私有库
- 字符串拼接成段落,换行符(\n)如何只执行n-1次
- 无论你是谁,都有两件事,无法掌控
- 没有思考时
- 2021.4.8日《我们为什么无法摆脱慢性疾病》常斌
- 插件化无法获取或找到.so文件
- R语言|R语言 函数
- springboot中.yml文件的值无法读取的问题及解决