Commit graph

17 commits

Author SHA1 Message Date
Arjav Patel
5e91459b1a system/microros: Add UDP and serial custom transport backends.
Micro XRCE-DDS expects the application to supply open/close/write/read
callbacks for the wire transport. Add a single dispatcher that
registers the selected backend via rmw_uros_set_custom_transport(),
plus two backends:

transport/microros_transport_udp.c
  BSD-socket UDP backend. Opens an AF_INET/SOCK_DGRAM socket,
  resolves CONFIG_MICROROS_AGENT_IP/PORT, connect()s it, and uses
  send/recv. The socket fd is stashed in uxrCustomTransport->args
  so no module-level state is needed.

transport/microros_transport_serial.c
  termios serial backend. Opens CONFIG_MICROROS_SERIAL_DEVICE with
  O_RDWR|O_NOCTTY|O_CLOEXEC, switches to raw 8N1 at
  CONFIG_MICROROS_SERIAL_BAUD, and uses poll/read/write. Fd is
  again stashed in uxrCustomTransport->args.

Both backends are mutually exclusive at compile time via Kconfig;
the dispatcher selects which set of callbacks to register. Wired
into both the legacy Make build (CSRCS in system/microros/Makefile)
and the CMake build (separate microros_transport static library
with the transport directory only exposed to its INTERFACE).

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Arjav Patel
0a0118b93c system/microros: Wire libmicroros include layout and sim final link.
libmicroros is installed by colcon under include/<pkg>/<pkg>/file.h
for ament-packaged headers (e.g. rcl, rmw, rosidl) and the flat
include/<pkg>/file.h for a few others (e.g. rclc). A single
-I include/ therefore resolves <rclc/rclc.h> but not <rcl/rcl.h>.

Enumerate every immediate subdirectory of include/ in addition to
include/ itself so both layouts resolve.

Switch the library hand-off from LDLIBS to EXTRA_LIBS. The sim
target's final link pulls EXTRA_LIBS, not LDLIBS, so the previous
form left rcl/rclc/rcutils symbols unresolved.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Arjav Patel
3d6ea0ccec system/microros: Fix toolchain attribute strip breaking libc inlines.
micro_ros_lib/toolchain.cmake.in initialised C and CXX flags with
-D'__attribute__(x)=' to silence GCC attributes the upstream ament
build is not aware of. The strip also removed __gnu_inline__ and
__always_inline__ from NuttX's libc string.h inlines, so each
micro-ROS translation unit emitted external definitions of strcmp,
strcpy, strlen and friends. Sim final link then failed with ~50
multiple-definition errors.

Drop the define from both flag init lines so the attributes survive
and the inlines collapse as intended.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-06-02 00:15:25 +08:00
Arjav Patel
939ed0ca2a apps/system/microros: add rcutils strcasecmp strings.h include patch.
POSIX specifies strcasecmp/strncasecmp in <strings.h>, not <string.h>.
On NuttX (and other strict POSIX environments) rcutils/src/strcasecmp.c
only includes <string.h>, causing an implicit-declaration error for
strcasecmp when cross-compiling.

Patch 0003 adds #include <strings.h> guarded by !_WIN32, matching the
existing Windows/POSIX split in the file.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
55a7d4d2df apps/system/microros: define __NuttX__ in cross-compile toolchain flags.
Add -D__NuttX__ to CMAKE_C_FLAGS_INIT and CMAKE_CXX_FLAGS_INIT in
toolchain.cmake.in so that all cross-compiled micro-ROS packages see the
NuttX target macro.  Without this, rcutils/src/process.c follows the
__linux__ branch and references program_invocation_name, a glibc-only
extension absent from the NuttX C library.

Pair with 0002-rcutils-process-nuttx-compat.patch which additionally
guards the linux branch with !defined(__NuttX__), ensuring the embedded
fallback path is taken on NuttX even if the host compiler defines any
linux-flavoured macros.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
9a0c249c79 apps/system/microros: add CMake ExternalProject build support.
Mirror the Makefile build pipeline into CMakeLists.txt using
ExternalProject_Add so that CMake-based NuttX builds (cmake --build)
can also produce libmicroros.a.  The external project delegates to the
existing Makefile targets, then exposes the result via an IMPORTED
STATIC library target with correct INTERFACE_INCLUDE_DIRECTORIES.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
7dbebe1673 apps/system/microros: add DIR-typedef NuttX guard patch.
NuttX defines DIR as a struct type in dirent.h.  The rcutils filesystem
source has a bare typedef int DIR that triggers a redefinition error when
NuttX system headers are on the include path.  Guard it with #ifndef DIR
so the typedef is skipped when the type is already defined.

Applied automatically during the micro_ros_src/src fetch step with
  patch -p1 --forward --ignore-whitespace ... || true
so the build is idempotent if the upstream ever merges a fix.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
cb316ec165 apps/system/microros: wire libmicroros.a into LDLIBS and CFLAGS.
When CONFIG_SYSTEM_MICROROS=y, add the prebuilt libmicroros.a to LDLIBS
and the colcon-installed include/ tree to CFLAGS/CXXFLAGS so that any
application in nuttx-apps can include micro-ROS headers and link against
the library without extra flags.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
b1a4d3fcd5 apps/system/microros: add libmicroros.a colcon build pipeline.
Replace the Directory.mk stub with a full Application.mk-based Makefile
that builds libmicroros.a from upstream micro-ROS sources via colcon.
Build pipeline (six steps, each a Make target):

  1. micro_ros_dev/install  -- clone + build ament/colcon host tools
  2. micro_ros_src/src      -- git clone all Jazzy micro-ROS packages
                               with --depth 1; apply DIR-typedef guard
                               patch; mark unused packages COLCON_IGNORE
  3. toolchain.cmake        -- sed-substitute CC/CXX/CFLAGS into template
  4. colcon.meta            -- sed-substitute Kconfig resource limits
  5. micro_ros_src/install  -- colcon cross-build (merge-install,
                               packages-ignore-regex=.*_cpp)
  6. libmicroros.a          -- ar-merge all install/lib/*.a into one
                               archive; copy include/ tree

clean:: removes generated files; distclean:: removes all fetched dirs.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
e764594d26 apps/system/microros: add CMake cross-compile toolchain template.
Add toolchain.cmake.in and include_override/assert.h for the colcon
cross-build.  Key differences from the old robertobucher port:
  - Drop -DCLOCK_MONOTONIC=0: NuttX defines CLOCK_MONOTONIC=1 and
    the override broke nanosleep() on newer kernels.
  - CMAKE_SYSTEM_PROCESSOR is a placeholder substituted per-arch.
  - include_override/assert.h works around the rosidl NDEBUG issue
    (https://github.com/ros2/rosidl/pull/739).

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
98d3a0bcb0 apps/system/microros: add colcon.meta.in resource-limit template.
Add a colcon.meta.in template that is substituted at build time with
Kconfig values.  Key settings:
  - Custom transport only (UCLIENT_PROFILE_CUSTOM_TRANSPORT=ON,
    UCLIENT_PROFILE_STREAM_FRAMING=ON) -- actual UDP/serial callbacks
    are wired in Phase 4.
  - RCL_MICROROS=ON (Jazzy/Kilted renamed flag replacing the old
    RCL_COMMAND_LINE_ENABLED/RCL_LOGGING_ENABLED pair).
  - RCUTILS_NO_FILESYSTEM=OFF -- NuttX provides POSIX filesystem.
  - Resource limits use @MAX_NODES@/@MAX_PUBLISHERS@ etc. placeholders
    substituted from CONFIG_MICROROS_MAX_* Kconfig values.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
0f8f9125f0 apps/system/microros: add micro_ros_lib directory skeleton.
Add micro_ros_lib/ subdirectory with a .keep sentinel so the directory
is tracked by git before any generated build artifacts appear.  All
colcon/fetch outputs land here and are gitignored by the parent .gitignore.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-26 06:57:55 +08:00
Arjav Patel
e9d1141f7c apps/system/microros: Add CMakeLists.txt for CMake support.
Add CMakeLists.txt file for CMake build system integration.
Enables the micro-ROS library module to be built using NuttX CMake
build system alongside traditional Make-based builds.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
faf07ed3b0 apps/system/microros: Add .gitignore for library build artifacts.
Ignore build outputs and generated files:
- Directories: micro_ros_src/, micro_ros_dev/, build/, install/
- Build outputs: libmicroros.a, toolchain.cmake, colcon.meta
- Archives: *.tar.gz

Prevents build artifacts and downloaded sources from being committed.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
0be4928893 apps/system/microros: Add Makefile skeleton.
Add Makefile with standard NuttX build system integration. Follows
the MENUDESC + Directory.mk pattern used throughout nuttx-apps.
Enables the system/microros module to be built as part of the apps
directory build process.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
2a3a41d53a apps/system/microros: Add Kconfig with configuration options.
Add Kconfig file defining CONFIG_SYSTEM_MICROROS and related options:
- MICROROS_DISTRO: ROS 2 distribution selection (default jazzy)
- MICROROS_TRANSPORT_UDP/SERIAL: Transport method selection
- MICROROS_AGENT_IP/PORT: UDP agent address configuration
- MICROROS_SERIAL_DEVICE/BAUD: Serial transport configuration
- Resource limits: MAX_NODES, MAX_PUBLISHERS, MAX_SUBSCRIPTIONS,
  MAX_SERVICES, MAX_CLIENTS

Allows menuconfig integration for micro-ROS library configuration.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
bda3448106 apps/system/microros: Create empty library skeleton.
Add Make.defs with copyright header for the micro-ROS library
build system. This establishes the directory structure for Phase 2,
with actual build logic to follow in subsequent steps.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00