Check My Ubuntu Version
Ubuntu 20.04 LTS [6]를 사용해도 ROS 2 사용에는 문제없다고 해서 진행함.
ROS 2 Foxy Fitzroy Installation: Use Debian Package
Make sure whether having a locale supporting UTF-8. Having a minimal environment(ex.POSIX) can cause problems.
Update Locale on the system setting them to use ‘US.UTF-8’ Locale for encoding => consistent language and encoding settings
Test with the following settings (Different UTF-8 supported locale is also fine)
Verify Settings
Ensure Ubuntu Universe repository is enabled
Install curl package with ‘-y’ flag, uses curl package to download the ROS key from specified url and save as ros-archive-keyring.gpg in directory /usr/share/keyrings
Key is used for verifying the authenticity of ROS packages during the installation
Add repository to sources list
Update apt repository caches in the setted repositories
Ensure my system is up to date
Desktop Install: ROS, RViz, demos, tutorials
ROS-Base Install (Bare Bones): Communication libraries, message packages, command line tools. No GUI tools.
Development tools: Compilers and other tools to build ROS packages
ROS2 Package installation in cafe
Set up your environment by sourcing the following file.
Verify both the C++ and Python APIs are working properly
Terminal1: Source the setup file and then run a C++ talker
Talker : Saying that it’s Publishing messages
Terminal2: Source the setup file and then run a Python listener
Listener : Saying I heard those messages.
ROS 2를 이용한 로봇 프로그래밍에 필수인 소프트웨어 모음 추가 다운로드
‘robot_ws’ 이라는 이름으로 워크스페이스 폴더를 생성한 후 빌드
환경 셋팅을 하고 ROS 2 설치가 잘 되어 빌드에 문제가 없는지 알아보는 과정
워크스페이스 폴더의 하위 폴더로 src 이외에도 build, install, log 폴더가 생성됨
2. Robot OS Installation
의 Environment Setup에서 ROS 2
설치 이후 source /opt/ros/foxy/setup.bash
를 설정 한 후, talker 노드 및 listener 노드를 실행하였음
그런데 source /opt/ros/foxy/setup.bash
와 같은 환경 설정을 매번 불러오기란 매우 귀찮을 수 있음
=> ROS 2 개발 및 사용의 편리성을 위해 Run commands(rc)를 모아두는 bashrc 파일에 많이 사용되는 alias, source, export 을 설정함
bashrc 파일의 기존 내용은 그대로 두고 맨 아래에 하기 설정들 추가
bashrc_첨부.txt
-nano ~/.bashrc:
Opening the .bashrc file in the nano text editor, allowing you to view and edit its contents
-Ctrl+x 누르면 저장하고 꺼지고 다시 cmd로 돌아옴. 저장 잘 됐는지 확인하고 싶으면 nano ~/.bashrc 다시 cmd에 치면 됨
Save & Exit using nano command
Ctrl+o: To save the file and continue editing it.
Ctrl+x: To save the changes and exit editing.
VSCode Recommended in a ROS2 Development Environment.
Another IDE recommended IDE that support ROS is QtCreator. QtCreator is best to use as a sub when writing UI for RQt’s Plugin Installation of ROS 2
ROS 2 개발 환경 구축을 위한 IDE 설정 및 사용법 (VSCode의 설치, 실행, 확장 기능 설치, 개발 환경 설정)
-IntelliSense 설정, 사용 방법
-디버깅 설정 및 사용법
VSCode 환경에서의 디버깅 툴은 C++은 GDB, Python은 debugpy 사용
-ROS 커뮤니티에서 VSCode 개발 환경을 위한 확장들과 VSCode를 이용한 다양한 사용 방법들을 공개한다고 한다 => 시간 날 때 찾아보기
1)Installation
Blog Guideline
Follow the link below and install ‘.deb’ debian installation file
https://code.visualstudio.com/Download
My Development Environment
Visual Studio Code already installed
Installation Process:
Open the Ubuntu Software app. => In the search bar of the Visual Studio Code section, type “visual studio code.” => Select the search result. => Click “Install.”
2)Implementation
Enter code in cmd => Visual Studio Code opens
3)Extensions Installation
-Extensions (Ctrl + Shift + x
)으로 이동
-아래의 C/C++/Python/ROS/File Format/유용한 Extensions 추가
C/C++/Python Extensions (VS Code Extensions for C++ and Python)
Name | Code Name | Description | |
---|---|---|---|
C/C++ | ms-vscode.cpptools | C/C ++ IntelliSense, Debugging support, and Code search | |
CMake | twxs.cmake | Support for the CMake language | |
CMake Tools | ms-vscode.cmake-tools | CMake language support & Additional tools and features to make working with CMake projects more convenient | |
Python | ms-python.python | Linging, Debugging, Intellisense, Code Formatting, Refactoring, Unit Testing |
IntelliSense : Term for various code editing features including: code completion, parameter info, quick info, and member lists
Debugging support : Visual Studio Code’s built-in debugger helps accelerate your Edit, Compile, and Debug loop.
CMake Language : Build system generator and configuration tool. CMake provides a platform-independent way to specify how a software project should be built and helps generate native build files (e.g., makefiles or project files for IDEs) for various operating systems and build environments.
File Format Extensions (VS Code Extensions for XML, YAML, Markdown)
Name | Code Name | Description | |
---|---|---|---|
XML Tools | dotjoshjohnson.xml | Support XML, XQuery, XPath | |
YAML | redhat.vscode-yaml | Support YAML | |
Markdown All in One | ms-vscode.cmake-tools | Support Markdown |
XML: Markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable
XQuery : Query language designed for querying and manipulating XML data
XPath : Language used for navigating XML documents and selecting nodes from the document’s structure
YAML: Human-readable data serialization format. Often used for configuration files and data exchange between languages with different data structures. YAML stands out for its simplicity and readability, making it easy for both humans and machines to understand.
Markdown: Lightweight markup language that allows you to write plain text using a format that is easy to read and write, while also providing a simple way to add formatting and structure
ROS Extensions (VS Code Extensions for ROS, URDF, Colcon)
Name | Code Name | Description | |
---|---|---|---|
ROS | ms-iot.vscode-ros | Support for ROS Development | |
URDF | smilerobotics.urdf | Support for URDF/xacro | |
Colcon Tasks | deitry.colcon-helper | VSCode Task for Colcon Query |
ROS: Open-source middleware framework designed to develop software for robots
URDF : XML-based file format used in ROS to describe the structure of a robot
Colcon : Command-line tool used in ROS for building and managing ROS packages
Useful Extensions (VS Code Extensions for Etc)
Name |Code Name|Description| |—|:—|:—:| |Highlight Trailing White Spaces|ybaumes.highlight-trailing-white-spaces|Emphasis on spaces used without meaning| |EOF Mark|msfukui.eof-mark|Add [EOF] character to files ending without [EOF]| |Better Comments|aaron-bond.better-comments|Strengthening comments for keywords such as alert, informational, TODO, etc.|
Etc. Recommended Extensions
-ms-azuretools.vscode-docker
-ms-vscode-remote.remote-ssh
-ms-vscode-remote.remote-ssh-edit
-ms-vscode-remote.remote-containers
-ms-python.vscode-pylance
-ms-toolsai.jupyter
-dbaeumer.vscode-eslint
-uctakeoff.vscode-counter
-vscode-icons-team.vscode-icons
4)Set Workspace
-“File” > “Add Folder to Workspace…” menu selection
-Select folder “robot_ws”
5)Set VS Code Development Environment
The following steps (6-9) guide you through setting up the VS Code development environment. While configuring, you may use the settings.json, c_cpp_properties.json, tasks.json, and launch.json files. If these files don’t exist, create them in the specified locations below.
Please note that in Linux, folders and files with a ‘.’ as a prefix are considered hidden.
~/.config/Code/User/settings.json
~/robot_ws/.vscode/c_cpp_properties.json
~/robot_ws/.vscode/tasks.json
~/robot_ws/.vscode/launch.json
6)Set User settings
‘settings.json’: VSCode의 사용자별 글로벌 환경 설정을 지정하는 파일
이 파일에 기술된 설정들은 모든 작업 공간(workspace)에서 적용
Ex.미니맵 사용, 세로 제한 줄 표시, 탭 사이즈 등
나는 settings.json file이 없음을 확인..
Make a new settings.json file using nano editor
settings.json_code.txt
Copy and paste the file above => Ctrl+x to save and edit
-Specialized User Settings
-In the settings.json
file located at ~/.config/Code/User/
, configure as above:
-ROS Related Settings
Specify the ROS version in ‘ms-iot.vscode-ros’ as ‘“ros.distro”: “foxy”’
Set ‘deitry.colcon-helper’ to use colcon-supported Tasks with ‘“colcon.provideTasks”: true’
Use “files.associations” to specify file types for ROS-specific filenames like *.repos, *.world, *.xacro, etc., whose extensions may not be known.
7)Set C/C++ Properties
-C/C++ Related Settings
-c_cpp_properties.json_code.txt
-Copy and paste the file above, then press Ctrl+x to save and exit.
-Configure settings related to C/C++
-Specify the os of the current designated workspace (~/robot_ws), define the path for the include folder, determine the standard C/C++ rules to be used, set the compilation path, and establish the IntelliSense mode.
8)Set Tasks
tasks.json_code.txt
-Copy and paste the file above, then press Ctrl+x to save and exit.
Make a new tasks.json file using nano editor
-Within VSCode, a pivotal feature known as Tasks seamlessly integrates external programs through the CLI(Command Line Interface). This functionality, aptly named the Task function, empowers VSCode beyond its fundamental role as a basic text editor.
-By harnessing the Task function, users can effortlessly execute diverse operations and seamlessly incorporate functional extensions.
-The following contents made the colcon related ‘build, test, clean’ tasks when built in ROS 2 to Task.
Ctrl + Shift + b
: Build in VScode
Ctrl + Shift + p > Tasks: Run Task > Choose the designated Task
: Perform Task besides the basic setting
9)Configure Launch Setting
launch.json_code.txt
Copy and paste the file above, then press Ctrl+x to save and exit.
Make a new launch.json file using nano editor
-In VSCode, the ‘Launch’ feature, accessible through ‘Run and Debug’ (Ctrl + Shift + d), serves as an execution command customizable based on language and debugger preferences.
-Additionally, you have the option to specify a Task or configure console functionalities before initiating the Launch, either for immediate debugging or subsequent execution.
-Here, I’ve configured VSCode’s debugging tools to align with the commonly used Python and C++ languages in ROS 2.
For C++, I’ve set it up to use GDB, and for Python, debugpy.
Specifically, debugging in Python is facilitated without the need for an additional build step, while for C++, it is advisable to execute colcon build before initiating GDB.
10)Build
-Ctrl + Shift + b
: Build in VScode
11)Debugging
-Ctrl + Shift + d
: Build in VScode. Debug respective of each language by referring to the GIF picture and implementation order
11-1.rclcpp
-Move using Run and Debug (Ctrl + Shift + d
)
-Select “Debug-rclcpp(gbd)”
-Input “Package name” (Ex. topic_service_action_rclcpp_example)
-Input “node name” (ex. argument)
-Click Start Debugging(F5
)
11-2.rclpy
-Move using Run and Debug (Ctrl + Shift + d
)
-Select “Debug-rclpy(debugpy)”
-Click Start Debugging (F5
)
1)Installation
QtCreator is already installed above.
2)Implementation
QtCreator is useful to use as a sub when writing a UI in RQt’s Plugin development
1)Installation
ROS Qt Creator Plug-in는 ROS-Industrial 컨소시엄에서 ROS의 통일된 개발 환경 구축을 위해 QtCreator의 플러그인 형태로 만든 것으로 ROS-Industrial 컨소시엄 멤버들간에 공통 개발 환경으로 사용함.
-일반적인 QtCreator에 ROS 개발 환경 설정을 더 편하게 해놓은 것으로 QtCreator를 기본 IDE로 사용하고자 한다면 사용해보기를 추천. QtCreator를 ROS 2의 IDE로 설정하려면 아래의 Installation Instructions (Users)
항목에서 신규 qtcreator-ros를 다운로드 받고 설정은 아래 링크의 도움말 참.
https://ros-qtc-plugin.readthedocs.io/en/latest/index.html
The choice of an integrated development environment depends on the developer’s personal preferences.
Delve into IDEs such as Vim, Eclipse, CLion, Emacs, and more by accessing information from the link provided below.
If you intend to delete ROS 2 for reinstallation, use the command below to delete ROS 2
Reference:
https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html
https://cafe.naver.com/openrt/25288
https://linuxhandbook.com/nano-save-exit/
https://medium.com/@yjo/cmake%EA%B0%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80-9a0091adafb
https://linuxhandbook.com/nano-save-exit/