Skip to content

Commit

Permalink
Merge pull request #2 from micro-ROS/main
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
DominikN authored Dec 31, 2023
2 parents 7eb4e2b + e87705f commit 420eae5
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 120 deletions.
5 changes: 3 additions & 2 deletions .github/actions/platformio-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ runs:
run: |
apt update
export DEBIAN_FRONTEND=noninteractive
apt install -y git curl python3 python3-pip git cmake
python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
apt install -y git curl python3 python3-pip python3-venv git cmake
curl -fsSL -o get-platformio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py
python3 get-platformio.py
echo 'export PATH=$PATH:~/.platformio/penv/bin' >> ~/.bashrc
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
jobs:

micro_ros_platformio:
runs-on: ubuntu-20.04
container: ubuntu:20.04
runs-on: ubuntu-22.04
container: ubuntu:22.04

strategy:
fail-fast: false
matrix:
platform: [teensy41, teensy40, teensy36, teensy35, teensy31, due, zero, olimex_e407, esp32dev, nanorp2040connect, portenta_h7_m7, teensy41_eth, nanorp2040connect_wifi, portenta_h7_m7_wifi, esp32dev_wifi, portenta_h7_m7_galactic, portenta_h7_m7_foxy, portenta_h7_m7_rolling, teensy41_custom, pico]
platform: [teensy41, teensy40, teensy36, teensy35, teensy31, due, zero, olimex_e407, esp32dev, nanorp2040connect, portenta_h7_m7, teensy41_eth, nanorp2040connect_wifi, portenta_h7_m7_wifi, esp32dev_wifi, portenta_h7_m7_humble, portenta_h7_m7_rolling, teensy41_custom, pico]

steps:
- uses: actions/checkout@v3
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
Changelog for package micro_ros_platformio
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2.0.0 (2023-06-12)
------------------
* Iron release (`#102 <https://github.com/micro-ROS/micro_ros_platformio/issues/102>`_)
* Update rolling sources (`#99 <https://github.com/micro-ROS/micro_ros_platformio/issues/99>`_)
* Set rmw default implementation (`#62 <https://github.com/micro-ROS/micro_ros_platformio/issues/62>`_)
* Add rosidl_core (`#54 <https://github.com/micro-ROS/micro_ros_platformio/issues/54>`_)
* Fix Arduino with POSIX (`#48 <https://github.com/micro-ROS/micro_ros_platformio/issues/48>`_)
* Fix generation of idedata (`#44 <https://github.com/micro-ROS/micro_ros_platformio/issues/44>`_)
* micro_ros_platformio works on Raspberry Pi Pico (`#39 <https://github.com/micro-ROS/micro_ros_platformio/issues/39>`_)
* Fix native ethernet (`#37 <https://github.com/micro-ROS/micro_ros_platformio/issues/37>`_)
* Fix user meta path (`#34 <https://github.com/micro-ROS/micro_ros_platformio/issues/34>`_)
* Fix project environment modifications (`#36 <https://github.com/micro-ROS/micro_ros_platformio/issues/36>`_)
* Fix wifi transport setup (`#29 <https://github.com/micro-ROS/micro_ros_platformio/issues/29>`_)

1.0.0 (2022-05-25)
------------------
* Add humble as default ROS2 distro (`#27 <https://github.com/micro-ROS/micro_ros_platformio/issues/27>`_)
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ The community is encouraged to open pull request with custom use cases.
```bash
apt install -y git cmake python3-pip
```

### Platform specific requirements

#### MacOS

XCode command line tools are distributed with toolchain that is not fully compatible with micro-ROS build process.
To fix this, install GNU [binutils](https://www.gnu.org/software/binutils/) using [Homebrew](https://brew.sh/):

```bash
brew install binutils
```

## How to add to your project

Expand Down Expand Up @@ -84,10 +95,9 @@ A explanation for adding custom targets is also present

### ROS 2 distribution
The target ROS 2 distribution can be configured with the `board_microros_distro = <distribution>`, supported values are:
- `humble` *(default value)*
- `galactic`
- `humble`
- `iron` *(default value)*
- `rolling`
- `foxy`

### Transport configuration
The transport can be configured with the `board_microros_transport = <transport>`, supported values and configurations are:
Expand Down Expand Up @@ -207,7 +217,7 @@ It is also possible to use custom transports on a `micro-XRCE Agent` instance. M
## Examples
A simple publisher project using serial transport is available on the [examples](./examples) directory, this examples is meant to be modified with the user board.
- More micro-ROS usage examples are available on [micro-ROS-demos/rclc](https://github.com/micro-ROS/micro-ROS-demos/tree/galactic/rclc).
- More micro-ROS usage examples are available on [micro-ROS-demos/rclc](https://github.com/micro-ROS/micro-ROS-demos/tree/iron/rclc).
- For a complete micro-ROS tutorial, check [Programming with rcl and rclc](https://micro.ros.org/docs/tutorials/programming_rcl_rclc/overview/) documentation.
## Purpose of the Project
Expand Down
2 changes: 1 addition & 1 deletion ci/extra_packages/extra_packages.repos
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ repositories:
control_msgs:
type: git
url: https://github.com/ros-controls/control_msgs
version: galactic-devel
version: humble
16 changes: 3 additions & 13 deletions ci/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
; Galactic test
[env:portenta_h7_m7_galactic]
; Humble test
[env:portenta_h7_m7_humble]
platform = ststm32
board = portenta_h7_m7
framework = arduino
board_microros_transport = serial
board_microros_distro = galactic
lib_deps =
../

; Foxy test
[env:portenta_h7_m7_foxy]
platform = ststm32
board = portenta_h7_m7
framework = arduino
board_microros_transport = serial
board_microros_distro = foxy
board_microros_distro = humble
lib_deps =
../

Expand Down
10 changes: 7 additions & 3 deletions extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

selected_board_meta = boards_metas[board] if board in boards_metas else "colcon.meta"

# Retrieve the required transport. Default humble
microros_distro = global_env.BoardConfig().get("microros_distro", "humble")
# Retrieve the required transport. Default iron
microros_distro = global_env.BoardConfig().get("microros_distro", "iron")

# Retrieve the required transport. Default serial
microros_transport = global_env.BoardConfig().get("microros_transport", "serial")
Expand Down Expand Up @@ -97,7 +97,8 @@ def build_microros(*args, **kwargs):
"{} {} -fno-rtti -DCLOCK_MONOTONIC=0 -D'__attribute__(x)='".format(' '.join(env['CXXFLAGS']), ' '.join(env['CCFLAGS']))
)

builder = library_builder.Build(library_folder=main_path, packages_folder=extra_packages_path, distro=microros_distro)
python_env_path = env['PROJECT_CORE_DIR'] + "/penv/bin/activate"
builder = library_builder.Build(library_folder=main_path, packages_folder=extra_packages_path, distro=microros_distro, python_env=python_env_path)
builder.run('{}/metas/{}'.format(main_path, selected_board_meta), cmake_toolchain.path, microros_user_meta)

#######################################################
Expand Down Expand Up @@ -135,6 +136,9 @@ def update_env():
main_path + "/platform_code",
main_path + "/platform_code/{}/{}".format(framework, microros_transport)])

if (board == "teensy31" or board == "teensy35" or board == "teensy36"):
projenv.Append(LINKFLAGS=["--specs=nosys.specs"])

# Add micro-ROS defines to user application
projenv.Append(CPPDEFINES=[('MICRO_ROS_TRANSPORT_{}_{}'.format(framework.upper(), microros_transport.upper()), 1)])
projenv.Append(CPPDEFINES=[('MICRO_ROS_DISTRO_{} '.format(microros_distro.upper()), 1)])
Expand Down
3 changes: 1 addition & 2 deletions metas/common.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"rcl": {
"cmake-args": [
"-DBUILD_TESTING=OFF",
"-DRCL_COMMAND_LINE_ENABLED=OFF",
"-DRCL_LOGGING_ENABLED=OFF"
"-DRCL_MICROROS=ON"
]
},
"rcutils": {
Expand Down
41 changes: 27 additions & 14 deletions microros_utils/library_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, path, cc, cxx, ar, cflags, cxxflags):
self.path = os.path.realpath(file.name)

class Build:
def __init__(self, library_folder, packages_folder, distro):
def __init__(self, library_folder, packages_folder, distro, python_env):
self.library_folder = library_folder
self.packages_folder = packages_folder
self.build_folder = library_folder + "/build"
Expand All @@ -51,10 +51,11 @@ def __init__(self, library_folder, packages_folder, distro):
self.library = self.library_path + "/libmicroros.a"
self.includes = self.library_path+ '/include'
self.library_name = "microros"
self.python_env = python_env
self.env = {}

def run(self, meta, toolchain, user_meta = ""):
if os.path.exists(self.library_path):
if os.path.exists(self.library):
print("micro-ROS already built")
return

Expand Down Expand Up @@ -99,7 +100,7 @@ def download_dev_environment(self):

def build_dev_environment(self):
print("Building micro-ROS dev dependencies")
command = "cd {} && colcon build --cmake-args -DBUILD_TESTING=OFF".format(self.dev_folder)
command = "cd {} && . {} && colcon build --cmake-args -DBUILD_TESTING=OFF -DPython3_EXECUTABLE=`which python`".format(self.dev_folder, self.python_env)
result = run_cmd(command, env=self.env)

if 0 != result.returncode:
Expand Down Expand Up @@ -173,7 +174,7 @@ def build_mcu_environment(self, meta_file, toolchain_file, user_meta = ""):
print("Building micro-ROS library")

common_meta_path = self.library_folder + '/metas/common.meta'
colcon_command = 'colcon build --merge-install --packages-ignore-regex=.*_cpp --metas {} {} {} --cmake-args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF -DTHIRDPARTY=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE={}'.format(common_meta_path, meta_file, user_meta, toolchain_file)
colcon_command = '. {} && colcon build --merge-install --packages-ignore-regex=.*_cpp --metas {} {} {} --cmake-args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF -DTHIRDPARTY=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE={} -DPython3_EXECUTABLE=`which python`'.format(self.python_env, common_meta_path, meta_file, user_meta, toolchain_file)
command = "cd {} && . {}/install/setup.sh && {}".format(self.mcu_folder, self.dev_folder, colcon_command)
result = run_cmd(command, env=self.env)

Expand All @@ -182,6 +183,7 @@ def build_mcu_environment(self, meta_file, toolchain_file, user_meta = ""):
sys.exit(1)

def package_mcu_library(self):
binutils_path = self.resolve_binutils_path()
aux_folder = self.build_folder + "/aux"

shutil.rmtree(aux_folder, ignore_errors=True)
Expand All @@ -193,12 +195,12 @@ def package_mcu_library(self):
if f.endswith('.a'):
os.makedirs(aux_folder + "/naming", exist_ok=True)
os.chdir(aux_folder + "/naming")
os.system("ar x {}".format(root + "/" + f))
os.system("{}ar x {}".format(binutils_path, root + "/" + f))
for obj in [x for x in os.listdir() if x.endswith('obj')]:
os.rename(obj, '../' + f.split('.')[0] + "__" + obj)

os.chdir(aux_folder)
command = "ar rc libmicroros.a $(ls *.o *.obj 2> /dev/null); rm *.o *.obj 2> /dev/null; ranlib libmicroros.a"
command = "{binutils}ar rc libmicroros.a $(ls *.o *.obj 2> /dev/null); rm *.o *.obj 2> /dev/null; {binutils}ranlib libmicroros.a".format(binutils=binutils_path)
result = run_cmd(command)

if 0 != result.returncode:
Expand All @@ -211,13 +213,24 @@ def package_mcu_library(self):
shutil.copytree(self.build_folder + "/mcu/install/include", self.includes)

# Fix include paths
if self.distro not in ["galactic", "foxy"]:
include_folders = os.listdir(self.includes)
include_folders = os.listdir(self.includes)

for folder in include_folders:
folder_path = self.includes + "/{}".format(folder)
repeated_path = folder_path + "/{}".format(folder)
for folder in include_folders:
folder_path = self.includes + "/{}".format(folder)
repeated_path = folder_path + "/{}".format(folder)

if os.path.exists(repeated_path):
shutil.copytree(repeated_path, folder_path, copy_function=shutil.move, dirs_exist_ok=True)
shutil.rmtree(repeated_path)
if os.path.exists(repeated_path):
shutil.copytree(repeated_path, folder_path, copy_function=shutil.move, dirs_exist_ok=True)
shutil.rmtree(repeated_path)

def resolve_binutils_path(self):
if sys.platform == "darwin":
homebrew_binutils_path = "/opt/homebrew/opt/binutils/bin/"
if os.path.exists(homebrew_binutils_path):
return homebrew_binutils_path

print("ERROR: GNU binutils not found. ({}) Please install binutils with homebrew: brew install binutils"
.format(homebrew_binutils_path))
sys.exit(1)

return ""
Loading

0 comments on commit 420eae5

Please sign in to comment.