(4) Compilation Command
The compilation command for ROS1 is "**catkin_make**," while for ROS2, the compilation command is "**colcon build.**"
If any further development learning is required, please refer to the official tutorial via the following link.
**
(5) Enter the command "**docker exec -it 55ce /bin/bash**" to enter the container (the container's ID can be abbreviated as long as it uniquely identifies the container).
```bash
docker exec -it 55ce /bin/bash
```
(6) Enter the command "**useradd -m -s /bin/bash ubuntu**" to create a new user.
```bash
useradd -m -s /bin/bash ubuntu
```
(7) In the terminal, enter "**passwd ubuntu**" to set the password for "ubuntu". Here, "ubuntu" is set as the password, you will prompted to re-enter the password.
```bash
passwd ubuntu
```
(8) Enter "**usermod -aG sudo ubuntu**" to add the new user "ubuntu" to the sudo group, granting it the superuser permission.
```bash
usermod -aG sudo ubuntu
```
(9) Enter "**sudo apt-get update -y && sudo apt-get upgrade -y**" to update the list of available software packages and upgrade the installed software packages on the system.
```bash
sudo apt-get update -y && sudo apt-get upgrade -y
```
(10) Enter "**sudo apt-get install vim -y**" to install Vim text editor.
```bash
sudo apt-get install vim -y
```
(11) Enter "**sudo apt-get install ros-humble-desktop-full -y**"to install the complete desktop environment of ROS Humble version.
```bash
sudo apt-get install ros-humble-desktop-full -y
```
### 8.2.1 Test ROS2 Environment
(1) Enter "**docker exec -it -u ubuntu -w /home/ubuntu 55ce /bin/bash**" to enter the container.
>[!Note]
>
>**55ce is the container ID with the ROS2 environment installed.**
```bash
docker exec -it -u ubuntu -w /home/ubuntu 55ce /bin/bash
```
(2) Enter "**source /opt/ros/humble/setup.bash**" to manually set up ROS2 environment.
```bash
source /opt/ros/humble/setup.bash
```
(3) The step 2 needs to be executed every time to load the workspace when you open the terminal, you can enter "**echo "source /opt/ros/humble/setup.bash" \>\> ~/.bashrc**" to write this command into the .bashrc file.
```bash
echo "source /opt/ros/humble/setup.bash" \>\> ~/.bashrc
```
(4) Enter "**source ~/.bashrc**" to make the **.bashrc** file take effect. In this way, there is no need to load the workspace environment for each operation.
```bash
source ~/.bashrc
```
(5) Enter "**ros2 run turtlesim turtlesim_node**" to start the TurtleSim GUI interface. If it launches successfully, it indicates that ROS2 has been installed successfully.
```bash
ros2 run turtlesim turtlesim_node
```
## 8.3 ROS2 Command-Line Operation
### 8.3.1 Component of ROS2 File System
The ROS2 file consists of Packages and Manifests.
Packages are the basic organizational unit in ROS2 software, consisting of a collection of related files and directories used to organize and manage ROS2 nodes, libraries, and resources. These packages contain source code for nodes, configuration files, message and service definition.
Manifests (package.xml) is a description file for the packages used to define the relevant metadata and dependencies of the package. In ROS2, packages typically contain a file named package.xml, which contains metadata information information about the package, such as name, version, maintainer, license agreement, and dependencies.
Manifest file (package.xml) plays a crucial role in ROS2, providing descriptions and management for packages. This enables the ROS2 to properly handle dependencies between packages and perform appropriate building and performance.
### 8.3.2 Get to Know ROS2 Basic Terms
The following table will introduce you some basic terms in ROS2:
| Term | Instruction |
| Underlying communication layer (DDS) | It provides high-performance, reliable, real-time data communication and integration capabilities, thereby establishing fundamental support for messaging and service invocation between nodes in ROS2. |
| Node | Node is the smallest unit of processing running in ROS. It is typically an executable file. Each node can use topics or services to communicate with other nodes. |
| Message | The variables of data types such as int, float and boolean. |
| Topic | A one-way asynchronous communication mechanism. By publishing messages to topics or subscribing to topics, the data transmission between nodes can be realized. The topic type is determined by the type of corresponding message. |
| Publishing | Send data with a message type corresponding to the topic content. |
| Publishers | For publishing to take place,the publisher node registers various information such as its topics on the master node, and transmits messages to subscribing nodes that wish to subscribe. |
| Subscribing | Receive data with a message type corresponding topic content. |
| Subscribers | For subscription to take place, the subscribing node registers various information such as its topics on the master node. Subsequently, it receives all messages from publisher nodes that have published topics of interest to this node, via the master node. |
| Services | A bidirectional synchronous communication mechanism where the service is provided to the client request corresponding to a specific task and service servers gives the service response. |
| Service Servers | A node taking requests as input, and providing responses as output. |
| Service Clients | A node taking responding as input, and providing requests as output. |
* **Command-line Tool**
The ro2 node command is used to view node messages.
| **Command** | **Instruction** |
| :------------: | :----------------------------------------------------------: |
| ros2 node list | View the list of active nodes within the current domain ( nodes grouped by the same ROS_DOMAIN_ID ) |
| ros2 node info | View the detailed information about a specific node in ROS2, including its subscriptions, publications, publishing, services and actions, etc. |
* **Topic Operation Tool**
The ros2 topic command in ROS2 is used to perform operations related to topics.
| **Command** | **Instruction** |
| ---------------- | :----------------------------------------------------------: |
| ros2 topic list | List all active topics within the domain. |
| ros2 topic info | Provide information about a specific topic, including its type, and publishers/subscribers. |
| ros2 topic type | View the type of topic messages. |
| ros2 topic find | Find the topics related to a specific message type in ROS2. |
| ros2 topic hz | Display the average publishing frequency of a topic in ROS2. |
| ros2 topic bw | Calculate the bandwidth usage of a specific topic. |
| ros2 topic delay | Calculate the message delay using the timestamp in the message header in ROS2. |
| ros2 topic echo | Display the topic message in console. |
| ros2 topic pub | Publish a message to a specific topic through command-line. |
* **Interface Operation Tool**
The ros2 interface command is used to perform operations related to the interfaces in ROS2.
| **Command** | **Instruction** |
| :---------------------: | :----------------------------------------------------------: |
| ros2 interface list | List all available interfaces in the system, including Messages, Services, and Actions. |
| ros2 interface package | List the child interfaces within the specific package. |
| ros2 interface packages | List packages containing interfaces. |
| ros2 interface show | Display the detailed contents of the specified interface. |
| ros2 interface proto | Display message module. |
## 8.4 ROS2 Development Environment Configuration
>[!Note]
>
>**The provided Raspberry Pi image comes pre-installed and pre-configured with the development environment. This lesson is only provided for learning and reference purpose only.**
>
During the subsequent learning and development processes, users can improve their efficiency by optimizing development environment and installing plugins.
### 8.4.1 Adjust Resolution
(1) Press "**Ctrl+Alt+T**" to open a command-line terminal and input the command "**sudo raspi-config**", then press Enter.
```bash
sudo raspi-config
```
(2) Select "2. Display Options" using "↑↓" keys and press "Enter" to confirm. "**Esc**" key can be used to go back to the previous level.
(3) Select "**D3 VNC Resolution**", and then press "**Enter**" to confirm.
(4) Select "**1920\*1080**" and "**\