Skip to content

Commit

Permalink
Add android support config (#396)
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Cao <joel.cao@oppo.com>

Co-authored-by: Joel Cao <joel.cao@oppo.com>
  • Loading branch information
kneep and Joel Cao authored Oct 11, 2021
1 parent ac8eac4 commit 967e7ad
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ This package is the **official build system for micro-ROS**. It provides tools a
| [Mbed](https://os.mbed.com/) | [ST B-L475E-IOT01A](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/) | v6.6 | `mbed disco_l475vg_iot01a` |
| - | Static library (.a) and headers (.h) <sup>3</sup> | - | `generate_lib` |
| Linux | *Host <sup>2</sup>* | Ubuntu 18.04/20.04 | `host` |
| Android | [AOSP](https://source.android.com) <sup>4</sup> | Latest | `android generic` |

*<sup>1</sup> Community supported, may have lack of official support*

*<sup>2</sup> Support for compiling apps in a native Linux host for testing and debugging*

*<sup>3</sup> a valid CMake toolchain with custom crosscompilation definition is required*

*<sup>4</sup> Community supported, may have lack of official support*

## Standalone build system tools

micro-ROS also offers some other ways to crosscompile it for different platforms. These other options are secondary tools and may not have full support for all features. Currently micro-ROS is also available as:
Expand Down Expand Up @@ -75,6 +78,12 @@ Some other prerequisites needed for building a firmware using this package are:
```
sudo apt install python3-rosdep
```

Building for Android needs [Latest Android NDK](https://developer.android.com/ndk/downloads) to be installed and the following environment variables to be set:
- ```ANDROID_ABI```: CPU variant, refer [here](https://developer.android.com/ndk/guides/abis) for details.
- ```ANDROID_NATIVE_API_LEVEL```: Android platform version, refer [here](https://developer.android.com/ndk/guides/cmake#android_native_api_level) for details.
- ```ANDROID_NDK```: root path of the installed NDK.

# Quick start

Download [here](https://www.eprosima.com/index.php/downloads-all) the micro-ROS docker image that contains a pre-installed client and agent as well as some compiled examples.
Expand Down
9 changes: 9 additions & 0 deletions config/android/dev_ros2_packages.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
keep:
ament/ament_cmake
ament/ament_index
ament/ament_lint
ament/ament_package
ament/googletest
ament/osrf_pycommon
ament/uncrustify_vendor
ros2/ament_cmake_ros
1 change: 1 addition & 0 deletions config/android/dev_uros_packages.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repositories:
61 changes: 61 additions & 0 deletions config/android/generic/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
. $PREFIX/config/utils.sh

if [ $# -ge 1 ]; then
TOOLCHAIN=$1
else
echo "Syntax: ros2 run micro_ros_setup build_firmware.sh <CMake toolchain file> [Colcon meta file]"
exit 1
fi

if [ $# -ge 2 ]; then
COLCON_META=$2
echo "Using provided meta: $COLCON_META"

else
COLCON_META=$FW_TARGETDIR/mcu_ws/colcon.meta
echo "Using default meta: $COLCON_META"
fi


BUILD_DIR=$FW_TARGETDIR/build

pushd $FW_TARGETDIR/mcu_ws >/dev/null

# Set these variables according to your own environment.
if [ -z ${ANDROID_ABI+x} ]; then
ANDROID_ABI=arm64-v8a
fi
if [ -z ${ANDROID_NATIVE_API_LEVEL+x} ]; then
ANDROID_NATIVE_API_LEVEL=android-30
fi
if [ -z ${ANDROID_NDK+x} ]; then
ANDROID_NDK=~/android-ndk-r23
fi

# rm -rf build install log

colcon build --packages-up-to micro_ros_demos_rclc \
--merge-install \
--packages-ignore-regex=.*_cpp \
--metas $COLCON_META \
--cmake-args \
"--no-warn-unused-cli" \
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DANDROID_STL=c++_shared \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${ANDROID_NDK} \
-DANDROID=ON \
-DTHIRDPARTY=ON \
-DBUILD_TESTING=OFF \
-DBUILD_MEMORY_TOOLS=OFF \
-DBUILD_MEMORY_TESTS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON

popd >/dev/null

49 changes: 49 additions & 0 deletions config/android/generic/client-colcon.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"names":{
"microxrcedds_client":{
"cmake-args":[
"-DBUILD_SHARED_LIBS=ON",
"-DUCLIENT_PROFILE_MULTITHREAD=ON"
]
},
"microcdr":{
"cmake-args":[
"-DBUILD_SHARED_LIBS=ON"
]
},
"rosidl_typesupport_microxrcedds_c":{
"cmake-args":[
"-DBUILD_SHARED_LIBS=ON"
]
},
"rosidl_typesupport_microxrcedds_cpp":{
"cmake-args":[
"-DBUILD_SHARED_LIBS=ON"
]
},
"rclc_parameter":{
"cmake-args":[
"-DBUILD_SHARED_LIBS=ON"
]
},
"rcutils":{
"cmake-args":[
"-DENABLE_TESTING=OFF"
]
},
"rmw_microxrcedds":{
"cmake-args":[
"-DRMW_UXRCE_TRANSPORT=udp",
"-DRMW_UXRCE_DEFAULT_UDP_IP=127.0.0.1",
"-DRMW_UXRCE_DEFAULT_UDP_PORT=8888",
"-DRMW_UXRCE_MAX_NODES=15",
"-DRMW_UXRCE_MAX_PUBLISHERS=15",
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=15",
"-DRMW_UXRCE_MAX_SERVICES=15",
"-DRMW_UXRCE_MAX_CLIENTS=15",
"-DRMW_UXRCE_STREAM_HISTORY=32",
"-DRMW_UXRCE_MAX_HISTORY=10"
]
}
}
}
52 changes: 52 additions & 0 deletions config/android/generic/client_uros_packages.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
repositories:
eProsima/Micro-CDR:
type: git
url: https://github.com/eProsima/Micro-CDR.git
version: foxy
eProsima/Micro-XRCE-DDS-Client:
type: git
url: https://github.com/eProsima/Micro-XRCE-DDS-Client.git
version: foxy

# MicroROS
uros/rcl:
type: git
url: https://github.com/micro-ROS/rcl
version: galactic
uros/rclc:
type: git
url: https://github.com/ros2/rclc
version: galactic
uros/micro_ros_utilities:
type: git
url: https://github.com/micro-ROS/micro_ros_utilities
version: main
version: galactic
uros/rcutils:
type: git
url: https://github.com/micro-ROS/rcutils
version: galactic
uros/micro_ros_msgs:
type: git
url: https://github.com/micro-ROS/micro_ros_msgs.git
version: galactic
uros/rmw_microxrcedds:
type: git
url: https://github.com/micro-ROS/rmw-microxrcedds.git
version: galactic
uros/rosidl_typesupport:
type: git
url: https://github.com/micro-ROS/rosidl_typesupport.git
version: galactic
uros/rosidl_typesupport_microxrcedds:
type: git
url: https://github.com/micro-ROS/rosidl_typesupport_microxrcedds.git
version: galactic
uros/tracetools:
type: git
url: https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing.git/
version: galactic
uros/micro-ROS-demos:
type: git
url: https://github.com/micro-ROS/micro-ROS-demos.git
version: galactic
11 changes: 11 additions & 0 deletions config/android/generic/create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pushd $FW_TARGETDIR >/dev/null

# ignore broken packages
touch mcu_ws/ros2/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE
touch mcu_ws/ros2/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE
touch mcu_ws/ros2/rcl/COLCON_IGNORE
touch mcu_ws/ros2/rosidl/rosidl_typesupport_introspection_cpp/COLCON_IGNORE
touch mcu_ws/uros/rcl/rcl_yaml_param_parser/COLCON_IGNORE
touch mcu_ws/uros/rclc/rclc_examples/COLCON_IGNORE

popd >/dev/null
2 changes: 2 additions & 0 deletions config/android/generic/flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "No flash step"
echo "Please find library and includes inside firmware/build folder"
12 changes: 12 additions & 0 deletions config/android/generic/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>firmware</name>
<version>0.0.0</version>
<description>Micro-ROS dependecies for Android</description>
<maintainer email="joel.cao@oppo.com">Joel Cao</maintainer>
<license>APL2</license>

<build_depend>gperf</build_depend>
<build_depend>wget</build_depend>
</package>

0 comments on commit 967e7ad

Please sign in to comment.