ros-Qt代碼環境的搭建


1 建立package

catkin_create_pkg beginner_tutorials roscpp

2 導入Qt

Qt中打開整個工作空間的src/CMakeLists.txt 在倒數第二行最后加入,最后一行include是為了寫代碼時候智能提示

FILE(GLOB children ${CMAKE_SOURCE_DIR}/*)
FOREACH(child ${children})
  IF(IS_DIRECTORY ${child})
    file(GLOB_RECURSE dir_files "${child}/*")
    LIST(APPEND extra_files ${dir_files})
  ENDIF()
ENDFOREACH()
add_custom_target(dummy_${PROJECT_NAME} SOURCES ${extra_files})

include_directories(/home/xiaophuang/catkin_ws/devel/include)

右鍵點擊project,執行run cmake,輸入的參數是-DCMAKE_BUILD_TYPE=Debug
這樣workspace下面的所有非空文件夾都會被導入

3 添加文件,文件夾

在package下新建一個srv文件夾(在Qt下面好像不能建文件夾,在外面建立文件夾)

在Qt下新建一個AddTwoInts.srv文件放在srv文件夾下面,輸入

int64 a
int64 b
----
int64 sum

修改package.xml,CMakeLists.txt

測試一下

rossrv  show beginner_tutorials/AddTwoInts

4, Debug

要是按F5提示(注意不要選錯要調試的程序)

This does not seem to be a "Debug" build.
Setting breakpoints by file name and line number may fail.

Section .debug_info: Not found.
Section .debug_abbrev: Not found.
Section .debug_line: Not found.
Section .debug_str: Not found.
Section .debug_loc: Not found.
Section .debug_range: Not found.
Section .gdb_index: Not found.
Section .note.gnu.build-id: Found.
Section .gnu.hash: Found.
Section .gnu_debuglink: Not found.

打開projects, run cmake 輸入-DCMAKE_BUILD_TYPE=Debug

設置斷點,


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM