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)就可以完美運行了
總結
以上是生活随笔為你收集整理的rosrun无法执行相应的可执行程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL内外连接
- 下一篇: 手机的android版本怎么升级,华为H