Skip to content

Commit

Permalink
Small documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
light-tech committed Sep 19, 2022
1 parent fb32627 commit 6c073b6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
paths:
- 'build_deps.sh'
- '.github/workflows/build_dependencies.yml'
jobs:
build-ros2:
runs-on: macos-latest
Expand All @@ -16,7 +17,7 @@ jobs:
with:
cmake-version: '3.23.x'
- run: ./build_deps.sh ${{ matrix.platformArch }}
- run: tar czf deps_${{ matrix.platformArch }}.tar.xz deps_${{ matrix.platformArch }}/
- run: tar cJf deps_${{ matrix.platformArch }}.tar.xz deps_${{ matrix.platformArch }}/
- uses: actions/upload-artifact@v3
with:
name: deps_${{ matrix.platformArch }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/main_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
paths:
- 'build_ros2_macos.sh'
- '.github/workflows/main_macos.yml'
jobs:
build-ros2:
runs-on: macos-latest
Expand All @@ -19,8 +20,8 @@ jobs:
cache: 'pip'
- run: pip3 install -r requirements.txt
- run: ./build_ros2_macos.sh
- run: tar cJf ros2.tar.xz ros2/
- run: tar cJf ros2_macOS.tar.xz ros2_macOS/
- uses: actions/upload-artifact@v3
with:
name: ros2
path: ros2.tar.xz
name: ros2_macOS
path: ros2_macOS.tar.xz
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ros2
ros2_ws/
deps*/
host_deps/
*.tar.xz

# Finder
.DS_Store
Expand Down
34 changes: 15 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

Build ROS2 stack for iOS software development.

**For the impatient**: Instead of building ROS2 from source (see below), you can download [our prebuilt libs](https://github.com/light-tech/ROS2-On-iOS/releases) and extract it to the root of the repo with `tar xzf`.
Then make a symlink `ros2` pointing to the extracted `ros2_iOS_Simulator` where we can find the ROS2 `lib` and `include` headers
**For the impatient**: Instead of building ROS2 from source (see below), you can download [our prebuilt libs](https://github.com/light-tech/ROS2-On-iOS/releases) and extract it.
Then make a symlink `ros2` pointing to the extracted `ros2_$PLATFORM` where we can find the ROS2 `lib` and `include` headers
```shell
ln -s ros2_iOS_Simulator ros2
ln -s PATH_TO_EXTRACTED_ros2_$PLATFORM ros2
```
You should of course change the symlink target when switching between building for real iPhone, for simulator and for Mac Catalyst.
You should of course change the symlink target when switching between building for real iPhone, simulator and Mac Catalyst.
Now we can run the demo application which ports [the official example](https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html): Run the app on **two** simulator instances, click on *Start publishing* on one and *Start listening* on the other.

![Minimal Publisher/Subscriber Demo](https://user-images.githubusercontent.com/25411167/184833976-2287a315-0dd8-4d0c-82e6-c42bd7a53d66.mov)

_Note_: To run Mac Catalyst app on your macOS machine, you need to sign the app with your development signing certificate.

**Main guides**:

* [Build ROS2 from source on macOS](https://docs.ros.org/en/humble/Installation/Alternatives/macOS-Development-Setup.html)
Expand All @@ -22,38 +24,30 @@ Now we can run the demo application which ports [the official example](https://d

We are going to need

* CMake **3.23** until [this](https://github.com/ament/ament_cmake/pull/395) is sorted out
* CMake **3.23** until [this issue](https://github.com/ament/ament_cmake/pull/395) is sorted out
* Python **3.10**
* Xcode + Command Line tools

installed. All subsequent shell commands are to be done at `$REPO_ROOT`.

Also, create a Python virtual environment for ease of working
Also, create a Python virtual environment for ease of package installation

1. Create a new Python virtual environment
```shell
export MY_PYTHON_ENV=usr_local
python3 -m venv $MY_PYTHON_ENV
python3 -m venv my_ros2_python_env
```
Here I use `usr_local` as it is intended to act like `/usr/local/`.

2. Activate the environment
```shell
source $MY_PYTHON_ENV/bin/activate
source my_ros2_python_env/bin/activate
```

3. Install the packages
```shell
python3 -m pip install -r requirements.txt
```

4. Compile `googletest`:
```shell
cd usr_local/lib/python3.10/site-packages/mypyc/external/googletest/make
make
```

If you have other environment management such as Anaconda, remember to deactivate them.
If you have other environment management such as Anaconda, remember to **DEACTIVATE** them.

## Source and workspace preparation

Expand Down Expand Up @@ -97,17 +91,19 @@ If you have other environment management such as Anaconda, remember to deactivat
ln -s $REPO_ROOT/src src
```

5. It is good to have multiple workspaces such as
5. During development, it is good to have multiple workspaces such as

- `ament_ws`: move `ament` here, build and `source` it before moving on to
- `base_ws`: add `rcl` and its dependencies and once successful
- `rclcpp_ws`: add other desired packages such as `rclcpp`.

This way, one can minimize the amount of packages to rebuild.

## Build ROS2 core packages for iOS

Before building, we need to change the line `#include <net/if_arp.h>` in `src/eProsima/Fast-DDS/src/cpp/utils/IPFinder.cpp` into `#include <net/ethernet.h>` according to [this](https://stackoverflow.com/questions/10395041/getting-arp-table-on-iphone-ipad) as the original header is only available in the macOS SDK.

We also disable `rcl_logging_spdlog` by
We also disable the package `rcl_logging_spdlog` by
```shell
touch src/ros2/rcl_logging/rcl_logging_spdlog/AMENT_IGNORE
```
Expand Down
8 changes: 4 additions & 4 deletions build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function setupPlatform() {

function setCompilerFlags() {
export CFLAGS="-isysroot $SYSROOT -arch $ARCH -I$DEPS_SYSROOT/include/"
export CPPFLAGS="-isysroot $SYSROOT -arch $ARCH -I$DEPS_SYSROOT/include/"
export CXXFLAGS="-isysroot $SYSROOT -arch $ARCH -I$DEPS_SYSROOT/include/"
}

function buildCMake() {
Expand All @@ -106,7 +106,7 @@ function configureThenMakeArm() {
make && make install # >/dev/null 2>&1

export -n CFLAGS
export -n CPPFLAGS
export -n CXXFLAGS
}

function configureThenMake() {
Expand All @@ -122,7 +122,7 @@ function configureThenMake() {
make && make install #>/dev/null 2>&1

export -n CFLAGS
export -n CPPFLAGS
export -n CXXFLAGS
}

function configureThenMakeNoHost() {
Expand All @@ -132,7 +132,7 @@ function configureThenMakeNoHost() {
make && make install #>/dev/null 2>&1

export -n CFLAGS
export -n CPPFLAGS
export -n CXXFLAGS
}

function buildHostTools() {
Expand Down
8 changes: 4 additions & 4 deletions build_ros2_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ REPO_ROOT=`pwd`

cd $REPO_ROOT
mkdir -p base_ws/src
vcs import base_ws/src < $REPO_ROOT/ros2_min.repos
vcs import base_ws/src < $REPO_ROOT/rviz2.repos
vcs import ros2_ws/src < $REPO_ROOT/ros2_min.repos
vcs import ros2_ws/src < $REPO_ROOT/rviz2.repos

# Ignore rcl_logging_spdlog package
touch base_ws/src/ros2/rcl_logging/rcl_logging_spdlog/AMENT_IGNORE
touch base_ws/src/ros2/orocos_kdl_vendor/python_orocos_kdl_vendor/AMENT_IGNORE

cd base_ws
colcon build --install-base $REPO_ROOT/ros2 --merge-install --cmake-force-configure --cmake-args -DBUILD_TESTING=NO -DTHIRDPARTY=FORCE -DCOMPILE_TOOLS=NO -DFORCE_BUILD_VENDOR_PKG=ON -DBUILD_MEMORY_TOOLS=OFF -DRCL_LOGGING_IMPLEMENTATION=rcl_logging_noop -DCMAKE_PREFIX_PATH=$REPO_ROOT/deps
cd ros2_ws
colcon build --install-base $REPO_ROOT/ros2_macOS --merge-install --cmake-force-configure --cmake-args -DBUILD_TESTING=NO -DTHIRDPARTY=FORCE -DCOMPILE_TOOLS=NO -DFORCE_BUILD_VENDOR_PKG=ON -DBUILD_MEMORY_TOOLS=OFF -DRCL_LOGGING_IMPLEMENTATION=rcl_logging_noop -DCMAKE_PREFIX_PATH=$REPO_ROOT/deps

0 comments on commit 6c073b6

Please sign in to comment.