Skip to content

Commit

Permalink
Merge remote-tracking branch 'micro-ROS/main' into fictionlab
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Nov 18, 2024
2 parents df188a0 + ed22dfe commit d7fee7f
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .github/actions/platformio-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ runs:
apt update
export DEBIAN_FRONTEND=noninteractive
apt install -y git curl python3 python3-pip python3-venv git cmake
python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
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
43 changes: 7 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,14 @@ jobs:
runs-on: ubuntu-20.04
container: ubuntu:20.04

strategy:
fail-fast: false
matrix:
pio-environment:
- 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
micro_ros_platformio:
runs-on: ubuntu-22.04
container: ubuntu:22.04

steps:
- uses: actions/checkout@v3
with:
path: repo
- name: Install environment
uses: ./repo/.github/actions/platformio-env
- name: Build
shell: bash
run: |
export PATH=$PATH:~/.platformio/penv/bin
cd repo/ci/arduino
pio run -e ${{ matrix.pio-environment }}
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_humble, portenta_h7_m7_jazzy, portenta_h7_m7_rolling, teensy41_custom, pico]

micro_ros_platformio_stm32cube:
runs-on: ubuntu-20.04
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 @@ -87,7 +98,8 @@ 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`
- `iron` *(default value)*
- `iron`
- `jazzy` *(default value)*
- `rolling`

### Transport configuration
Expand Down Expand Up @@ -208,7 +220,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/iron/rclc).
- More micro-ROS usage examples are available on [micro-ROS-demos/rclc](https://github.com/micro-ROS/micro-ROS-demos/tree/jazzy/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
10 changes: 10 additions & 0 deletions ci/arduino/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ board_microros_distro = humble
lib_deps =
../../

; Jazzy test
[env:portenta_h7_m7_jazzy]
platform = ststm32
board = portenta_h7_m7
framework = arduino
board_microros_transport = serial
board_microros_distro = jazzy
lib_deps =
../

; Rolling test
[env:portenta_h7_m7_rolling]
platform = ststm32
Expand Down
20 changes: 17 additions & 3 deletions extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,29 @@ def clean_microros_callback(*args, **kwargs):
print("micro-ROS library cleaned!")
os._exit(0)

global_env.AddCustomTarget("clean_microros", None, clean_microros_callback, title="Clean Micro-ROS", description="Clean Micro-ROS build environment")
if "clean_microros" not in global_env.get("__PIO_TARGETS", {}):
global_env.AddCustomTarget("clean_microros", None, clean_microros_callback, title="Clean Micro-ROS", description="Clean Micro-ROS build environment")

def clean_libmicroros_callback(*args, **kwargs):
library_path = main_path + '/libmicroros'

# Delete libmicroros folder
shutil.rmtree(library_path, ignore_errors=True)

print("libmicroros cleaned")
os._exit(0)

if "clean_libmicroros" not in global_env.get("__PIO_TARGETS", {}):
global_env.AddCustomTarget("clean_libmicroros", None, clean_libmicroros_callback, title="Clean libmicroros", description="Clean libmicroros")


def build_microros(*args, **kwargs):
##############################
#### Install dependencies ####
##############################

pip_packages = [x.split("==")[0] for x in os.popen('{} -m pip freeze'.format(env['PYTHONEXE'])).read().split('\n')]
required_packages = ["catkin-pkg", "lark-parser", "empy", "colcon-common-extensions", "importlib-resources", "pyyaml", "pytz", "markupsafe==2.0.1"]
required_packages = ["catkin-pkg", "lark-parser", "colcon-common-extensions", "importlib-resources", "pyyaml", "pytz", "markupsafe==2.0.1", "empy==3.3.4"]
if all([x in pip_packages for x in required_packages]):
print("All required Python pip packages are installed")

Expand Down Expand Up @@ -157,7 +171,7 @@ def update_env():
from SCons.Script import COMMAND_LINE_TARGETS

# Do not build library on clean_microros target or when IDE fetches C/C++ project metadata
if set(["clean_microros", "__idedata", "_idedata", "idedata"]).isdisjoint(set(COMMAND_LINE_TARGETS)):
if set(["clean_microros", "clean_libmicroros", "_idedata", "idedata"]).isdisjoint(set(COMMAND_LINE_TARGETS)):
build_microros()

update_env()
28 changes: 18 additions & 10 deletions microros_utils/library_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, library_folder, packages_folder, distro, 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 All @@ -66,9 +66,6 @@ def run(self, meta, toolchain, user_meta = ""):
self.build_mcu_environment(meta, toolchain, user_meta)
self.package_mcu_library()

# Delete build folders
shutil.rmtree(self.build_folder, ignore_errors=True)

def ignore_package(self, name):
for p in self.mcu_packages:
if p.name == name:
Expand All @@ -90,8 +87,7 @@ def check_env(self):
self.env = os.environ.copy()

def download_dev_environment(self):
shutil.rmtree(self.dev_src_folder, ignore_errors=True)
os.makedirs(self.dev_src_folder)
os.makedirs(self.dev_src_folder, exist_ok=True)
print("Downloading micro-ROS dev dependencies")
for repo in Sources.dev_environments[self.distro]:
repo.clone(self.dev_src_folder)
Expand All @@ -108,8 +104,7 @@ def build_dev_environment(self):
sys.exit(1)

def download_mcu_environment(self):
shutil.rmtree(self.mcu_src_folder, ignore_errors=True)
os.makedirs(self.mcu_src_folder)
os.makedirs(self.mcu_src_folder, exist_ok=True)
print("Downloading micro-ROS library")
for repo in Sources.mcu_environments[self.distro]:
repo.clone(self.mcu_src_folder)
Expand Down Expand Up @@ -183,6 +178,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 @@ -194,12 +190,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 @@ -221,3 +217,15 @@ def package_mcu_library(self):
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 ""
45 changes: 43 additions & 2 deletions microros_utils/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def __init__(self, name, url, distribution, branch=None):
def clone(self, folder):
self.path = folder + "/" + self.name
# TODO(pablogs) ensure that git is installed
if os.path.exists(self.path):
command = f"cd {self.path} && git pull {self.url} {self.branch}"
result = run_cmd(command)
if 0 != result.returncode:
print(f"{self.name} pull failed: \n{result.stderr.decode('utf-8')}")
sys.exit(1)
return

command = "git clone -b {} {} {}".format(self.branch, self.url, self.path)
result = run_cmd(command)

Expand Down Expand Up @@ -88,6 +96,14 @@ class Sources:
Repository("ament_cmake_ros", "https://github.com/ros2/ament_cmake_ros", "iron"),
Repository("ament_index", "https://github.com/ament/ament_index", "iron")
],
'jazzy': [
Repository("ament_cmake", "https://github.com/ament/ament_cmake", "jazzy"),
Repository("ament_lint", "https://github.com/ament/ament_lint", "jazzy"),
Repository("ament_package", "https://github.com/ament/ament_package", "jazzy"),
Repository("googletest", "https://github.com/ament/googletest", "jazzy"),
Repository("ament_cmake_ros", "https://github.com/ros2/ament_cmake_ros", "jazzy"),
Repository("ament_index", "https://github.com/ament/ament_index", "jazzy")
],
'rolling': [
Repository("ament_cmake", "https://github.com/ament/ament_cmake", "rolling"),
Repository("ament_lint", "https://github.com/ament/ament_lint", "rolling"),
Expand Down Expand Up @@ -164,6 +180,30 @@ class Sources:
Repository("rcl_logging", "https://github.com/ros2/rcl_logging", "iron"),
Repository("ros2_tracing", "https://github.com/ros2/ros2_tracing", "iron"),
],
'jazzy': [
Repository("micro-CDR", "https://github.com/eProsima/micro-CDR", "jazzy", "ros2"),
Repository("Micro-XRCE-DDS-Client", "https://github.com/eProsima/Micro-XRCE-DDS-Client", "jazzy", "ros2"),
Repository("rcl", "https://github.com/micro-ROS/rcl", "jazzy"),
Repository("rclc", "https://github.com/ros2/rclc", "jazzy"),
Repository("micro_ros_utilities", "https://github.com/micro-ROS/micro_ros_utilities", "jazzy"),
Repository("rcutils", "https://github.com/micro-ROS/rcutils", "jazzy"),
Repository("micro_ros_msgs", "https://github.com/micro-ROS/micro_ros_msgs", "jazzy"),
Repository("rmw-microxrcedds", "https://github.com/micro-ROS/rmw-microxrcedds", "jazzy"),
Repository("rosidl_typesupport", "https://github.com/micro-ROS/rosidl_typesupport", "jazzy"),
Repository("rosidl_typesupport_microxrcedds", "https://github.com/micro-ROS/rosidl_typesupport_microxrcedds", "jazzy"),
Repository("rosidl", "https://github.com/ros2/rosidl", "jazzy"),
Repository("rosidl_dynamic_typesupport", "https://github.com/ros2/rosidl_dynamic_typesupport", "jazzy"),
Repository("rosidl_core", "https://github.com/ros2/rosidl_core", "jazzy"),
Repository("rmw", "https://github.com/ros2/rmw", "jazzy"),
Repository("rcl_interfaces", "https://github.com/ros2/rcl_interfaces", "jazzy"),
Repository("rosidl_defaults", "https://github.com/ros2/rosidl_defaults", "jazzy"),
Repository("unique_identifier_msgs", "https://github.com/ros2/unique_identifier_msgs", "jazzy"),
Repository("common_interfaces", "https://github.com/ros2/common_interfaces", "jazzy"),
Repository("test_interface_files", "https://github.com/ros2/test_interface_files", "jazzy"),
Repository("rmw_implementation", "https://github.com/ros2/rmw_implementation", "jazzy"),
Repository("rcl_logging", "https://github.com/ros2/rcl_logging", "jazzy"),
Repository("ros2_tracing", "https://github.com/ros2/ros2_tracing", "jazzy"),
],
'rolling': [
Repository("micro-CDR", "https://github.com/eProsima/micro-CDR", "rolling", "ros2"),
Repository("Micro-XRCE-DDS-Client", "https://github.com/eProsima/Micro-XRCE-DDS-Client", "rolling", "ros2"),
Expand Down Expand Up @@ -215,5 +255,6 @@ class Sources:
],
'humble': ['rcl_logging_log4cxx', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples'],
'iron': ['test_tracetools', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples'],
'rolling': ['test_tracetools', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples']
}
'jazzy': ['test_tracetools', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples','lttngpy'],
'rolling': ['test_tracetools', 'rcl_logging_spdlog', 'rcl_yaml_param_parser', 'rclc_examples','lttngpy']
}
4 changes: 2 additions & 2 deletions platform_code/arduino/clock_gettime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <sys/time.h>
#define micro_rollover_useconds 4294967295

#ifndef WITH_POSIX
#if !defined(_POSIX_TIMERS) || !_POSIX_TIMERS

extern "C" int clock_gettime(clockid_t unused, struct timespec *tp)
{
Expand All @@ -22,4 +22,4 @@ extern "C" int clock_gettime(clockid_t unused, struct timespec *tp)
return 0;
}

#endif // ifndef WITH_POSIX
#endif // ifndef _POSIX_TIMERS

0 comments on commit d7fee7f

Please sign in to comment.