You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A detailed tutorial for setting up the Asctec Pelican UAV for autonomous waypoint navigation using ROS. Covers configuring network settings, flashing firmware, and running the ROS package on the onboard Atomboard.
16
16
17
+
-**[Building an iOS App for ROS 2 Integration](/wiki/common-platforms/ros2-ios-app-with-swift/)**
18
+
A step-by-step guide on building an iOS application integrated with ROS 2 using the SwiftROS2 framework, covering project setup, node configuration, and SwiftUI interface development.
19
+
17
20
-**[Building a Custom Drone for the DARPA Triage Challenge](/wiki/common-platforms/building-custom-drone-for-darpa-triage-challenge/)**
18
21
A comprehensive guide to designing and building UAVs for disaster scenarios. Covers both modified commercial platforms and fully custom designs, including hardware selection, electrical integration, and software configuration.
19
22
@@ -96,6 +99,11 @@ Here is a compiled list of external resources referenced in the subsections:
Copy file name to clipboardExpand all lines: wiki/common-platforms/ros2-ios-app-with-swift.md
+34-42Lines changed: 34 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,18 @@
1
-
## A New Post
2
-
3
1
---
4
2
date: 2025-04-29
5
-
title: Building an iOS App for ROS2 Integration – A Step-by-Step Guide
6
-
categories: [Tutorial, ROS2, iOS]
7
-
tags: [ROS2, iOS, Swift, Tutorial]
3
+
title: Building an iOS App for ROS 2 Integration
8
4
---
9
5
10
-
This document provides a detailed, step-by-step guide on building an iOS application integrated with ROS2 using the SwiftROS2 framework. In this guide, you will learn how to set up the project, configure ROS2 nodes, implement publishers and subscribers to exchange messages via DDS, and build a SwiftUI-based user interface for operating ROS2 functionality. In addition, this README offers an in-depth explanation of the dependency packages and how the DDS mechanism is implemented to support ROS2 communication. This guide assumes you have a basic understanding of Swift and iOS development. By the end, you will be able to create and run an iOS app that seamlessly interacts with ROS2 nodes.
6
+
This document provides a detailed, step-by-step guide on building an iOS application integrated with ROS 2 using the SwiftROS2 framework. In this guide, you will learn how to set up the project, configure ROS 2 nodes, implement publishers and subscribers to exchange messages via DDS, and build a SwiftUI-based user interface for operating ROS 2 functionality. In addition, this guide offers an in-depth explanation of the dependency packages and how the DDS mechanism is implemented to support ROS 2 communication. This guide assumes you have a basic understanding of Swift and iOS development. By the end, you will be able to create and run an iOS app that seamlessly interacts with ROS 2 nodes.
11
7
12
-
The complete code can be found at https://github.com/LiaoChiawen/ROS2iOSApp
8
+
The complete code can be found at <https://github.com/LiaoChiawen/ROS2iOSApp>.
13
9
14
10
## Table of Contents
15
11
-[Introduction](#introduction)
16
12
-[Background and Key Concepts](#background-and-key-concepts)
17
-
-[Step-by-Step Tutorial: Building an iOS App for ROS2](#step-by-step-tutorial-building-an-ios-app-for-ros2)
13
+
-[Step-by-Step Tutorial: Building an iOS App for ROS 2](#step-by-step-tutorial-building-an-ios-app-for-ros-2)
18
14
-[1. Project Setup and Dependencies](#1-project-setup-and-dependencies)
19
-
-[2. Creating the ROS2 Node](#2-creating-the-ros2-node)
15
+
-[2. Creating the ROS 2 Node](#2-creating-the-ros-2-node)
20
16
-[3. Implementing Publishers and Subscribers](#3-implementing-publishers-and-subscribers)
21
17
-[4. Building the User Interface](#4-building-the-user-interface)
22
18
-[5. Running and Testing the App](#5-running-and-testing-the-app)
@@ -32,18 +28,18 @@ The complete code can be found at https://github.com/LiaoChiawen/ROS2iOSApp
32
28
-[References](#references)
33
29
34
30
## Introduction
35
-
This tutorial explains how to build an iOS app that leverages ROS2 capabilities using the SwiftROS2 framework. In this guide you will learn to initialize a ROS2 node, set up publishers and subscribers via a DDS-based system, and construct a simple user interface with SwiftUI to operate core functionalities including initialization, message publishing, and node shutdown. The first 100 words of this introduction will be used as an excerpt on the Wiki index.
31
+
This tutorial explains how to build an iOS app that leverages ROS 2 capabilities using the SwiftROS2 framework. In this guide you will learn to initialize a ROS 2 node, set up publishers and subscribers via a DDS-based system, and construct a simple user interface with SwiftUI to operate core functionalities including initialization, message publishing, and node shutdown.
36
32
37
33
## Background and Key Concepts
38
34
Before diving into the code, it is useful to understand these key concepts:
39
-
-**ROS2 (Robot Operating System 2):** A set of libraries and tools for building robot applications, which employs nodes, topics, and messaging to facilitate robust communication.
40
-
-**DDS (Data Distribution Service):** A middleware protocol used in ROS2 for real-time, scalable, and high-performance data exchange. It allows configuration of Quality of Service (QoS) parameters such as reliability and latency.
41
-
-**Nodes:** The computational executables in ROS2 that handle processing and communication.
35
+
-**ROS 2 (Robot Operating System 2):** A set of libraries and tools for building robot applications, which employs nodes, topics, and messaging to facilitate robust communication.
36
+
-**DDS (Data Distribution Service):** A middleware protocol used in ROS 2 for real-time, scalable, and high-performance data exchange. It allows configuration of Quality of Service (QoS) parameters such as reliability and latency.
37
+
-**Nodes:** The computational executables in ROS 2 that handle processing and communication.
42
38
-**Publishers and Subscribers:** Mechanisms for sending (publishing) and receiving (subscribing) messages across nodes.
43
-
-**SwiftROS2:** A simulated Swift library that provides interfaces to create ROS2 nodes, publishers, and subscribers.
39
+
-**SwiftROS2:** A simulated Swift library that provides interfaces to create ROS 2 nodes, publishers, and subscribers.
44
40
-**iOS Development using SwiftUI:** SwiftUI is utilized for building modern, responsive user interfaces on iOS.
45
41
46
-
## Step-by-Step Tutorial: Building an iOS App for ROS2
42
+
## Step-by-Step Tutorial: Building an iOS App for ROS 2
47
43
48
44
### 1. Project Setup and Dependencies
49
45
1.**Clone the Repository:**
@@ -63,8 +59,8 @@ Before diving into the code, it is useful to understand these key concepts:
63
59
3.**Configure Xcode:**
64
60
In Xcode, set the deployment target to iOS 17.0 and ensure proper code signing configurations.
65
61
66
-
### 2. Creating the ROS2 Node
67
-
The heart of the app is the ROS2 node. The `CentralNode` class encapsulates ROS2 functionalities including initialization and resource management.
62
+
### 2. Creating the ROS 2 Node
63
+
The heart of the app is the ROS 2 node. The `CentralNode` class encapsulates ROS 2 functionalities including initialization and resource management.
68
64
69
65
-**Initialization:**
70
66
In `ContentView.swift`, the `initialize()` function performs the following:
@@ -121,7 +117,7 @@ public func sendString() {
121
117
122
118
### 4. Building the User Interface
123
119
The UI is built using SwiftUI and consists of three main buttons:
124
-
-**Initialize:** Sets up the ROS2 node and publishers.
120
+
-**Initialize:** Sets up the ROS 2 node and publishers.
125
121
-**Publish Message:** Sends a test message.
126
122
-**Destroy Node:** Tears down the node and cleans up.
127
123
@@ -167,45 +163,45 @@ var body: some View {
167
163
-**Build the Project:**
168
164
Use Xcode to build the project ensuring that all dependencies are properly integrated.
169
165
-**Run on Simulator or Device:**
170
-
Launch the app on an iOS device or Simulator. Use the buttons to initialize the ROS2 node, publish a message, and destroy the node.
166
+
Launch the app on an iOS device or Simulator. Use the buttons to initialize the ROS 2 node, publish a message, and destroy the node.
171
167
-**Testing:**
172
168
Verify the functionality by checking Xcode console logs and running unit tests located in `/ROS2iOSAppTests`.
173
169
174
170
## Detailed Explanation of Dependencies
175
171
176
172
### swift-ros2
177
173
-**Purpose:**
178
-
Provides a high-level Swift interface to interact with ROS2, allowing creation of nodes, publishers, and subscribers.
174
+
Provides a high-level Swift interface to interact with ROS 2, allowing creation of nodes, publishers, and subscribers.
179
175
-**Usage:**
180
-
Classes such as `CentralNode` use this package to encapsulate ROS2 operations and expose easy-to-use methods to initialize nodes and create communication channels.
176
+
Classes such as `CentralNode` use this package to encapsulate ROS 2 operations and expose easy-to-use methods to initialize nodes and create communication channels.
181
177
-**Implementation:**
182
-
Utilizes Swift’s async/await for asynchronous operations and error-handling mechanisms for reliable integration with ROS2 middleware.
178
+
Utilizes Swift’s async/await for asynchronous operations and error-handling mechanisms for reliable integration with ROS 2 middleware.
183
179
184
180
### FastRTPSSwift
185
181
-**Purpose:**
186
-
Bridges ROS2 DDS functionalities by leveraging the Fast RTPS (Real-Time Publish-Subscribe) protocol.
182
+
Bridges ROS 2 DDS functionalities by leveraging the Fast RTPS (Real-Time Publish-Subscribe) protocol.
187
183
-**Usage:**
188
184
Manages low-level DDS operations such as registering writers (publishers) and readers (subscribers) and handles QoS settings (e.g., reliability, durability).
189
185
-**Implementation:**
190
186
Wraps the native C/C++ Fast RTPS libraries into Swift-friendly APIs, abstracting the complexity involved in direct DDS communications.
191
187
192
188
### ros2msg
193
189
-**Purpose:**
194
-
Defines message types and data structures used in ROS2 communications.
190
+
Defines message types and data structures used in ROS 2 communications.
195
191
-**Usage:**
196
192
Provides message models like `ROS2String` to package data and ensure proper serialization and deserialization using Swift’s Codable protocol.
197
193
-**Implementation:**
198
-
Structures messages in a way that aligns with ROS2 standards, facilitating seamless interaction between different nodes and platforms.
194
+
Structures messages in a way that aligns with ROS 2 standards, facilitating seamless interaction between different nodes and platforms.
199
195
200
196
## Understanding the DDS Mechanism
201
-
DDS (Data Distribution Service) underpins the efficient and reliable exchange of data between ROS2 nodes. Key points include:
197
+
DDS (Data Distribution Service) underpins the efficient and reliable exchange of data between ROS 2 nodes. Key points include:
202
198
-**DDS Communication Model:**
203
199
Uses a publish/subscribe model where publishers send messages to topics and subscribers receive them based on topic subscriptions.
204
200
-**Quality of Service (QoS):**
205
201
DDS allows customization of parameters (e.g., reliability, durability, latency) ensuring high-performance communication even in real-time applications.
206
202
-**Fast RTPS Integration:**
207
203
The FastRTPSSwift package bridges the Fast RTPS library with SwiftROS2, managing:
208
-
-**Participant Creation:** The ROS2 node (CentralNode) acts as a participant joining a DDS domain.
204
+
-**Participant Creation:** The ROS 2 node (CentralNode) acts as a participant joining a DDS domain.
209
205
-**Writer and Reader Registration:** Publishers (writers) and subscribers (readers) are registered with the DDS participant.
210
206
-**Message Routing:** DDS middleware routes messages efficiently between registered writers and readers, applying QoS policies.
211
207
-**Abstraction in SwiftROS2:**
@@ -219,37 +215,33 @@ DDS (Data Distribution Service) underpins the efficient and reliable exchange of
219
215
3.**Build and Run:**
220
216
Build the project and run the app on the desired iOS simulator or device.
221
217
4.**Interact with the App:**
222
-
- Tap **Initialize** to set up the ROS2 node.
223
-
- Tap **Publish Message** to send a test ROS2 message.
224
-
- Tap **Destroy Node** to gracefully shut down the ROS2 node.
218
+
- Tap **Initialize** to set up the ROS 2 node.
219
+
- Tap **Publish Message** to send a test ROS 2 message.
220
+
- Tap **Destroy Node** to gracefully shut down the ROS 2 node.
225
221
5.**Review Logs:**
226
222
Monitor the Xcode console for log messages confirming successful node initialization, message publishing, and node destruction.
227
223
228
224
## Summary
229
-
This guide provided a comprehensive walkthrough for building an iOS app integrated with ROS2:
225
+
This guide provided a comprehensive walkthrough for building an iOS app integrated with ROS 2:
230
226
- Project setup, dependency resolution, and Xcode configuration.
231
-
- Initializing a ROS2 node with `CentralNode` and configuring communication via DDS.
227
+
- Initializing a ROS 2 node with `CentralNode` and configuring communication via DDS.
232
228
- Implementing publishers and subscribers to exchange messages.
233
229
- Designing a user interface with SwiftUI and testing the functionality.
234
230
- Detailed insights into the core dependency packages and DDS integration research.
235
231
236
232
## See Also
237
-
-[ROS2 Official Documentation](https://docs.ros.org/)
233
+
-[ROS 2 Official Documentation](https://docs.ros.org/)
- Advanced DDS configuration and Quality of Service (QoS) settings.
244
240
- Detailed tutorials on integrating C/C++ libraries with Swift.
245
-
- Comprehensive studies of ROS2 communication patterns and best practices.
241
+
- Comprehensive studies of ROS 2 communication patterns and best practices.
246
242
247
243
## References
248
-
1. Y. Hu, swift-ros2 – ROS2-like node that supports subscription and publication of DDS messages in ROS2 message format” GitHub Repository, https://github.com/strapsai/swift-ros2.
249
-
2. ROS Documentation, “Getting Started with ROS2,” available at https://docs.ros.org/.
250
-
3. Fast RTPS Documentation, available at https://fast-dds.docs.eprosima.com/en/latest/.
251
-
4. Apple Developer Documentation, “SwiftUI,” available at https://developer.apple.com/documentation/swiftui.
252
-
253
-
<!--
254
-
This README is based on the Robotics Knowledgebase Template. It provides a detailed guide on building an iOS ROS2 application, explains the core dependencies, and describes how the DDS mechanism underpins ROS2 communication. Modify sections as needed to match your project specifics.
255
-
-->
244
+
1. Y. Hu, "swift-ros2 – ROS2-like node that supports subscription and publication of DDS messages in ROS2 message format," GitHub Repository, <https://github.com/strapsai/swift-ros2>.
245
+
2. ROS Documentation, "Getting Started with ROS 2," available at <https://docs.ros.org/>.
246
+
3. Fast RTPS Documentation, available at <https://fast-dds.docs.eprosima.com/en/latest/>.
247
+
4. Apple Developer Documentation, "SwiftUI," available at <https://developer.apple.com/documentation/swiftui>.
0 commit comments