[ROS2] 워크스페이스

­윤다빈·2022년 8월 17일
0

[Devlog] - ROS

목록 보기
2/9

워크스페이스 폴더 생성 / 빌드

$ source /opt/ros/foxy/setup.bash
$ mkdir -p ~/baqu_ws/src
$ cd ~/baqu_ws/
$ colcon build --symlink-install

=>
"baqu_ws"라는 워크스페이스 생성
--symlink-install 명령어로 빌드하면 워크스페이스 하위 폴더에 src 이외에도 build, install, log 폴더가 생성됨

*--symlink-install 명령어는 빌드 후 파이썬 파일 수정을 해도 재빌드가 필요 없음
but, 1. 같은 파일 내에서의 수정일 때 적용
	2. 빌드시 관련 파일(파이썬 등)을 링크로 연결하기 때문에 쉽게 수정이 가능함*
    

VSCode 개발환경 설정

아래 위치에 해당 json 파일이 없다면 직접 생성하며 작성

$ ~/.config/Code/User/settings.json
$ ~/baqu_ws/.vscode/c_cpp_properties.json
$ ~/baqu_ws/.vscode/tasks.json
$ ~/baqu_ws/.vscode/launch.json

User settings 설정

{
    "workbench.colorTheme": "Default Dark+",
    
    "cmake.configureOnOpen": false,
    "editor.minimap.enabled": false,
    "editor.mouseWheelZoom": true,
    "editor.renderControlCharacters": true,
    "editor.rulers": [100],
    "editor.tabSize": 2,
    
    "ros.distro": "foxy",
    "colcon.provideTasks": true,
    "files.associations": {
    "*.repos": "yaml",
    "*.world": "xml",
    "*.xacro": "xml"
    },
    "files.insertFinalNewline": true,
    "files.trimTrailingWhitespace": true,
    "terminal.integrated.scrollback": 1000000
}

{
  "configurations": [
    {
      "name": "Linux",
      "includePath": [
        "${default}",
        "${workspaceFolder}/**",
        "/opt/ros/foxy/include/**"
      ],
      "defines": [],
      "compilerPath": "/usr/bin/g++",
      "cStandard": "c99",
      "cppStandard": "c++14",
      "intelliSenseMode": "linux-gcc-x64"
    }
  ],
  "version": 4
}

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "colcon: build",
      "type": "shell",
      "command": "colcon build --cmake-args '-DCMAKE_BUILD_TYPE=Debug'",
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    },
    {
      "label": "colcon: test",
      "type": "shell",
      "command": "colcon test && colcon test-result"
    },
    {
      "label": "colcon: clean",
      "type": "shell",
      "command": "rm -rf build install log"
    }
  ]
}

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug-rclpy(debugpy)",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal"
    },
    {
      "name": "Debug-rclcpp(gbd)",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/install/${input:package}/lib/${input:package}/${input:node}",
      "args": [],
      "preLaunchTask": "colcon: build",
      "stopAtEntry": true,
      "cwd": "${workspaceFolder}",
      "externalConsole": false,
      "MIMode": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ],
  "inputs": [
    {
      "id": "package",
      "type": "promptString",
      "description": "package name",
      "default": "topic_service_action_rclpp_example"
    },
    {
      "id": "node",
      "type": "promptString",
      "description": "node name",
      "default": "argument"
    }
  ]
}
profile
Web-Front / SW-AI 개발자

0개의 댓글