Skip to content

Commit 2b326a3

Browse files
mergify[bot]kneep
andauthored
Add android support config (#396) (#405)
Signed-off-by: Joel Cao <[email protected]> Co-authored-by: Joel Cao <[email protected]> (cherry picked from commit 967e7ad) Co-authored-by: kneep <[email protected]>
1 parent a9ff37d commit 2b326a3

File tree

9 files changed

+206
-0
lines changed

9 files changed

+206
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ This package is the **official build system for micro-ROS**. It provides tools a
3737
| [Mbed](https://os.mbed.com/) | [ST B-L475E-IOT01A](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/) | v6.6 | `mbed disco_l475vg_iot01a` |
3838
| - | Static library (.a) and headers (.h) <sup>3</sup> | - | `generate_lib` |
3939
| Linux | *Host <sup>2</sup>* | Ubuntu 18.04/20.04 | `host` |
40+
| Android | [AOSP](https://source.android.com) <sup>4</sup> | Latest | `android generic` |
4041

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

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

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

48+
*<sup>4</sup> Community supported, may have lack of official support*
49+
4750
## Standalone build system tools
4851

4952
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:
@@ -75,6 +78,12 @@ Some other prerequisites needed for building a firmware using this package are:
7578
```
7679
sudo apt install python3-rosdep
7780
```
81+
82+
Building for Android needs [Latest Android NDK](https://developer.android.com/ndk/downloads) to be installed and the following environment variables to be set:
83+
- ```ANDROID_ABI```: CPU variant, refer [here](https://developer.android.com/ndk/guides/abis) for details.
84+
- ```ANDROID_NATIVE_API_LEVEL```: Android platform version, refer [here](https://developer.android.com/ndk/guides/cmake#android_native_api_level) for details.
85+
- ```ANDROID_NDK```: root path of the installed NDK.
86+
7887
# Quick start
7988

8089
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.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
keep:
2+
ament/ament_cmake
3+
ament/ament_index
4+
ament/ament_lint
5+
ament/ament_package
6+
ament/googletest
7+
ament/osrf_pycommon
8+
ament/uncrustify_vendor
9+
ros2/ament_cmake_ros
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repositories:

config/android/generic/build.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
. $PREFIX/config/utils.sh
2+
3+
if [ $# -ge 1 ]; then
4+
TOOLCHAIN=$1
5+
else
6+
echo "Syntax: ros2 run micro_ros_setup build_firmware.sh <CMake toolchain file> [Colcon meta file]"
7+
exit 1
8+
fi
9+
10+
if [ $# -ge 2 ]; then
11+
COLCON_META=$2
12+
echo "Using provided meta: $COLCON_META"
13+
14+
else
15+
COLCON_META=$FW_TARGETDIR/mcu_ws/colcon.meta
16+
echo "Using default meta: $COLCON_META"
17+
fi
18+
19+
20+
BUILD_DIR=$FW_TARGETDIR/build
21+
22+
pushd $FW_TARGETDIR/mcu_ws >/dev/null
23+
24+
# Set these variables according to your own environment.
25+
if [ -z ${ANDROID_ABI+x} ]; then
26+
ANDROID_ABI=arm64-v8a
27+
fi
28+
if [ -z ${ANDROID_NATIVE_API_LEVEL+x} ]; then
29+
ANDROID_NATIVE_API_LEVEL=android-30
30+
fi
31+
if [ -z ${ANDROID_NDK+x} ]; then
32+
ANDROID_NDK=~/android-ndk-r23
33+
fi
34+
35+
# rm -rf build install log
36+
37+
colcon build --packages-up-to micro_ros_demos_rclc \
38+
--merge-install \
39+
--packages-ignore-regex=.*_cpp \
40+
--metas $COLCON_META \
41+
--cmake-args \
42+
"--no-warn-unused-cli" \
43+
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF \
44+
-DBUILD_SHARED_LIBS=ON \
45+
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
46+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
47+
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
48+
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
49+
-DANDROID_STL=c++_shared \
50+
-DANDROID_ABI=${ANDROID_ABI} \
51+
-DANDROID_NDK=${ANDROID_NDK} \
52+
-DANDROID=ON \
53+
-DTHIRDPARTY=ON \
54+
-DBUILD_TESTING=OFF \
55+
-DBUILD_MEMORY_TOOLS=OFF \
56+
-DBUILD_MEMORY_TESTS=OFF \
57+
-DCMAKE_BUILD_TYPE=Release \
58+
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
59+
60+
popd >/dev/null
61+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"names":{
3+
"microxrcedds_client":{
4+
"cmake-args":[
5+
"-DBUILD_SHARED_LIBS=ON",
6+
"-DUCLIENT_PROFILE_MULTITHREAD=ON"
7+
]
8+
},
9+
"microcdr":{
10+
"cmake-args":[
11+
"-DBUILD_SHARED_LIBS=ON"
12+
]
13+
},
14+
"rosidl_typesupport_microxrcedds_c":{
15+
"cmake-args":[
16+
"-DBUILD_SHARED_LIBS=ON"
17+
]
18+
},
19+
"rosidl_typesupport_microxrcedds_cpp":{
20+
"cmake-args":[
21+
"-DBUILD_SHARED_LIBS=ON"
22+
]
23+
},
24+
"rclc_parameter":{
25+
"cmake-args":[
26+
"-DBUILD_SHARED_LIBS=ON"
27+
]
28+
},
29+
"rcutils":{
30+
"cmake-args":[
31+
"-DENABLE_TESTING=OFF"
32+
]
33+
},
34+
"rmw_microxrcedds":{
35+
"cmake-args":[
36+
"-DRMW_UXRCE_TRANSPORT=udp",
37+
"-DRMW_UXRCE_DEFAULT_UDP_IP=127.0.0.1",
38+
"-DRMW_UXRCE_DEFAULT_UDP_PORT=8888",
39+
"-DRMW_UXRCE_MAX_NODES=15",
40+
"-DRMW_UXRCE_MAX_PUBLISHERS=15",
41+
"-DRMW_UXRCE_MAX_SUBSCRIPTIONS=15",
42+
"-DRMW_UXRCE_MAX_SERVICES=15",
43+
"-DRMW_UXRCE_MAX_CLIENTS=15",
44+
"-DRMW_UXRCE_STREAM_HISTORY=32",
45+
"-DRMW_UXRCE_MAX_HISTORY=10"
46+
]
47+
}
48+
}
49+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
repositories:
2+
eProsima/Micro-CDR:
3+
type: git
4+
url: https://github.com/eProsima/Micro-CDR.git
5+
version: foxy
6+
eProsima/Micro-XRCE-DDS-Client:
7+
type: git
8+
url: https://github.com/eProsima/Micro-XRCE-DDS-Client.git
9+
version: foxy
10+
11+
# MicroROS
12+
uros/rcl:
13+
type: git
14+
url: https://github.com/micro-ROS/rcl
15+
version: galactic
16+
uros/rclc:
17+
type: git
18+
url: https://github.com/ros2/rclc
19+
version: galactic
20+
uros/micro_ros_utilities:
21+
type: git
22+
url: https://github.com/micro-ROS/micro_ros_utilities
23+
version: main
24+
version: galactic
25+
uros/rcutils:
26+
type: git
27+
url: https://github.com/micro-ROS/rcutils
28+
version: galactic
29+
uros/micro_ros_msgs:
30+
type: git
31+
url: https://github.com/micro-ROS/micro_ros_msgs.git
32+
version: galactic
33+
uros/rmw_microxrcedds:
34+
type: git
35+
url: https://github.com/micro-ROS/rmw-microxrcedds.git
36+
version: galactic
37+
uros/rosidl_typesupport:
38+
type: git
39+
url: https://github.com/micro-ROS/rosidl_typesupport.git
40+
version: galactic
41+
uros/rosidl_typesupport_microxrcedds:
42+
type: git
43+
url: https://github.com/micro-ROS/rosidl_typesupport_microxrcedds.git
44+
version: galactic
45+
uros/tracetools:
46+
type: git
47+
url: https://gitlab.com/micro-ROS/ros_tracing/ros2_tracing.git/
48+
version: galactic
49+
uros/micro-ROS-demos:
50+
type: git
51+
url: https://github.com/micro-ROS/micro-ROS-demos.git
52+
version: galactic

config/android/generic/create.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pushd $FW_TARGETDIR >/dev/null
2+
3+
# ignore broken packages
4+
touch mcu_ws/ros2/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE
5+
touch mcu_ws/ros2/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE
6+
touch mcu_ws/ros2/rcl/COLCON_IGNORE
7+
touch mcu_ws/ros2/rosidl/rosidl_typesupport_introspection_cpp/COLCON_IGNORE
8+
touch mcu_ws/uros/rcl/rcl_yaml_param_parser/COLCON_IGNORE
9+
touch mcu_ws/uros/rclc/rclc_examples/COLCON_IGNORE
10+
11+
popd >/dev/null

config/android/generic/flash.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo "No flash step"
2+
echo "Please find library and includes inside firmware/build folder"

config/android/generic/package.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="2">
4+
<name>firmware</name>
5+
<version>0.0.0</version>
6+
<description>Micro-ROS dependecies for Android</description>
7+
<maintainer email="[email protected]">Joel Cao</maintainer>
8+
<license>APL2</license>
9+
10+
<build_depend>gperf</build_depend>
11+
<build_depend>wget</build_depend>
12+
</package>

0 commit comments

Comments
 (0)