在一次ros工程功能包的編譯過程中,像往常一樣,在catkin_ws目錄下使用了catkin_make命令,卻突然遇到了自己新添加的功能包無法正常編譯的bug。
初步懷疑可能是因為在系統里裝了anaconda,gym-gazebo,opencv以及一些深度學習環境,導致某些包之間發生了沖突???但是排查了好久,檢查了好多遍環境變量的設置,依舊未果(希望有懂的大佬不吝賜教呀)。
現在暫時找到了可以避免這個問題的方法,記錄之:
- 在此之前,使用catkin_make編譯ros工程一切正常。當在工程中加入新的功能包后,再次使用catkin_make命令(先刪除根目錄下的/devel,/build文件夾,再使用catkin_make),顯示以下界面,沒有任何報錯提示,就是沒有編譯功能包,心態有點炸啊啊啊:
1 xy@xy:~/catkin_ws$ catkin_make 2 Base path: /home/xy/catkin_ws 3 Source space: /home/xy/catkin_ws/src 4 Build space: /home/xy/catkin_ws/build 5 Devel space: /home/xy/catkin_ws/devel 6 Install space: /home/xy/catkin_ws/install 7 #### 8 #### Running command: "cmake /home/xy/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/xy/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/xy/catkin_ws/install -G Unix Makefiles" in "/home/xy/catkin_ws/build" 9 #### 10 -- The C compiler identification is GNU 5.4.0 11 -- The CXX compiler identification is GNU 5.4.0 12 -- Check for working C compiler: /usr/bin/cc 13 -- Check for working C compiler: /usr/bin/cc -- works 14 -- Detecting C compiler ABI info 15 -- Detecting C compiler ABI info - done 16 -- Detecting C compile features 17 -- Detecting C compile features - done 18 -- Check for working CXX compiler: /usr/bin/c++ 19 -- Check for working CXX compiler: /usr/bin/c++ -- works 20 -- Detecting CXX compiler ABI info 21 -- Detecting CXX compiler ABI info - done 22 -- Detecting CXX compile features 23 -- Detecting CXX compile features - done 24 -- Using CATKIN_DEVEL_PREFIX: /home/xy/catkin_ws/devel 25 -- Using CMAKE_PREFIX_PATH: /home/xy/catkin_ws/devel;/home/xy/gazebo_ws/devel;/home/xy/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/devel;/opt/ros/kinetic 26 -- This workspace overlays: /home/xy/catkin_ws/devel;/home/xy/gazebo_ws/devel;/home/xy/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/devel;/opt/ros/kinetic 27 -- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.12", minimum required is "2") 28 -- Using PYTHON_EXECUTABLE: /usr/bin/python2 29 -- Using Debian Python package layout 30 -- Using empy: /usr/bin/empy 31 -- Using CATKIN_ENABLE_TESTING: ON 32 -- Call enable_testing() 33 -- Using CATKIN_TEST_RESULTS_DIR: /home/xy/catkin_ws/build/test_results 34 -- Found gtest sources under '/usr/src/gmock': gtests will be built 35 -- Found gmock sources under '/usr/src/gmock': gmock will be built 36 -- Found PythonInterp: /usr/bin/python2 (found version "2.7.12") 37 -- Looking for pthread.h 38 -- Looking for pthread.h - found 39 -- Looking for pthread_create 40 -- Looking for pthread_create - not found 41 -- Looking for pthread_create in pthreads 42 -- Looking for pthread_create in pthreads - not found 43 -- Looking for pthread_create in pthread 44 -- Looking for pthread_create in pthread - found 45 -- Found Threads: TRUE 46 -- Using Python nosetests: /usr/bin/nosetests-2.7 47 -- catkin 0.7.20 48 -- BUILD_SHARED_LIBS is on 49 -- Configuring done 50 -- Generating done 51 -- Build files have been written to: /home/xy/catkin_ws/build 52 #### 53 #### Running command: "make -j12 -l12" in "/home/xuyang/catkin_ws/build" 54 ####
- 使用catkin build替代catkin_make進行編譯可以暫時避免它,如果又遇到catkin:command not found的情況,可以通過以下命令解決:
1 sudo apt-get update 2 sudo apt-get install python-catkin-tools
- 編譯完成后,在使用roslaunch命令時遇到以下問題:
1 xy@xy:~/new_ws$ roslaunch maze_solver main.launch 2 ... logging to /home/xy/.ros/log/16438e56-a869-11ea-8090-e86a642b9771/roslaunch-xy-13728.log 3 Checking log directory for disk usage. This may take awhile. 4 Press Ctrl-C to interrupt 5 Done checking log file disk usage. Usage is <1GB. 6 7 started roslaunch server http://xy:41011/ 8 9 SUMMARY 10 ======== 11 12 PARAMETERS 13 * /rosdistro: kinetic 14 * /rosversion: 1.12.14 15 16 NODES 17 / 18 lidar_process (maze_solver/LidarProcess.py) 19 main_node (maze_solver/MainNode.py) 20 state_controller (maze_solver/StateController.py) 21 22 auto-starting new master 23 process[master]: started with pid [13738] 24 ROS_MASTER_URI=http://localhost:11311 25 26 setting /run_id to 16438e56-a869-11ea-8090-e86a642b9771 27 process[rosout-1]: started with pid [13767] 28 started core service [/rosout] 29 ERROR: cannot launch node of type [maze_solver/StateController.py]: can't locate node [StateController.py] in package [maze_solver] 30 ERROR: cannot launch node of type [maze_solver/LidarProcess.py]: can't locate node [LidarProcess.py] in package [maze_solver] 31 ERROR: cannot launch node of type [maze_solver/MainNode.py]: can't locate node [MainNode.py] in package [maze_solver]
只要對功能包下的源碼或者腳本文件給予777權限即可解決:
1 sudo chmod -R 777 *