비주얼 스튜디오 코드 IDE(VSCode)
Visual Studio Code is a powerful cross-platform source code editor/IDE that can be used for PX4 development on Ubuntu, Windows, and macOS.
PX4 개발에 VSCode를 사용하는 데에는 많은 이유가 있습니다.
- Getting setup really only takes a few minutes.
- A rich extension ecosystem that enables a huge range of tools needed for PX4 development: C/C++ (with solid cmake integration), Python, Jinja2, ROS messages, and even DroneCAN dsdl.
- 뛰어난 Github 통합 기능
IDE를 설정과 개발 방법에 대하여 설명합니다.
INFO
There are other powerful IDEs, but they typically take more effort to integrate with PX4. With VScode, configuration is stored in the PX4/PX4-Autopilot tree (PX4-Autopilot/.vscode) so the setup process is as simple as adding the project folder.
전제 조건
You must already have installed the command line PX4 developer environment for your platform and downloaded the Firmware source code repo.
Installation & Setup
Download and install VSCode (you will be offered the correct version for your OS).
Open VSCode and add the PX4 source code:
- Select Open folder ... option on the welcome page (or using the menu: File > Open Folder):
- A file selection dialog will appear. Select the PX4-Autopilot directory and then press OK.
The project files and configuration will then load into VSCode.
Press Install All on the This workspace has extension recommendations prompt (this will appear on the bottom right of the IDE).
VSCode will open the Extensions panel on the left hand side so you can watch the progress of installation.
오른쪽 하단에 여러 알림/프롬프트가 나타날 수 있습니다.
TIP
If the prompts disappear, click the little "alarm" icon on the right of the bottom blue bar.
:::
- If prompted to install a new version of cmake:
- Say No (the right version is installed with the PX4 developer environment).
- If prompted to sign into github.com and add your credentials:
- 이것은 당신에게 달려 있습니다! Github와 IDE 간의 긴밀한 통합을 제공하여 워크플로를 단순화할 수 있습니다.
- Other prompts are optional, and may be installed if they seem useful.
PX4 빌드
빌드를 진행하려면:
Select your build target ("cmake build config"):
The current cmake build target is shown on the blue config bar at the bottom (if this is already your desired target, skip to next step).
INFO
The cmake target you select affects the targets offered for when building/debugging (i.e. for hardware debugging you must select a hardware target like
px4_fmu-v6
).
:::
Click the target on the config bar to display other options, and select the one you want (this will replace any selected target).
Cmake will then configure your project (see notification in bottom right).
Wait until configuration completes. When this is done the notification will disappear and you'll be shown the build location: .
- You can then kick off a build from the config bar (select either Build or Debug).
After building at least once you can now use [code completion](#code completion) and other VSCode features.
디버깅
SITL 디버깅
SITL에서 PX4를 디버깅하려면:
Select the debug icon on the sidebar (marked in red) to display the debug panel.
Then choose your debug target (e.g. Debug SITL (Gazebo Iris)) from the top bar debug dropdown (purple box).
INFO
The debug targets that are offered (purple box) match your build target (yellow box on the bottom bar). 예를 들어, SITL 대상을 디버그하려면 빌드 대상에 SITL이 포함되어야 합니다.
:::
- 디버그 "재생" 화살표(상단 막대의 디버그 대상 옆 - 분홍색 상자)를 클릭하여 디버깅을 시작합니다.
디버깅하는 동안 중단점을 설정하고, 코드를 건너뛰고, 그렇지 않으면 정상적으로 개발할 수 있습니다.
하드웨어 디버깅
The instructions in SWD Debug Port explain how to connect to the SWD interface on common flight controllers (for example, using the Dronecode or Blackmagic probes).
After connecting to the SWD interface, hardware debugging in VSCode is then the same as for SITL Debugging except that you select a debug target appropriate for your debugger type (and firmware) - e.g. jlink (px4_fmu-v5)
.
TIP
To see the jlink
option you must have selected a cmake target for building firmware.
코드 완성
In order for the code completion to work (and other IntelliSense magic) you need an active configuration and to have built the code.
이 작업이 완료되면 다른 작업을 수행할 필요가 없습니다. 툴체인은 입력시 자동으로 기호를 제공합니다.
문제 해결
이 섹션에는 설정 및 빌드 오류에 대한 지침이 포함되어 있습니다.
Ubuntu 18.04: "Visual Studio Code는 이 큰 작업 영역에서 파일 변경 사항을 감시할 수 없습니다."
이 오류는 시작시에 나타납니다. On some systems, there is an upper-limit of 8192 file handles imposed on applications, which means that VSCode might not be able to detect file modifications in /PX4-Autopilot
.
메모리 소비를 희생시키면서 오류를 방지하기 위해 이 제한을 늘릴 수 있습니다. Follow the instructions here. 값 65536이면 충분합니다.