wip: testing

This commit is contained in:
2025-08-22 11:37:20 +02:00
parent 98ac20f729
commit ef5035b92b
2 changed files with 29 additions and 20 deletions

View File

@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.20.0)
project(sherpa_ros2_sensor_node)
SET(CMAKE_CXX_COMPILER /opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc)
list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/modules/micro_ros_zephyr_module/modules/libmicroros)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sherpa_ros2_sensor_node)
target_sources(app PRIVATE src/main.cpp)
if(${BOARD} STREQUAL "native_sim")
add_subdirectory(src/emulation)
endif()
endif()

View File

@@ -1,25 +1,32 @@
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/sys/printk.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <rcl/rcl.h>
#include <rclc/rclc.h>
#include <uxr/client/config.h>
#include <uxr/client/client.h>
#include <zephyr/kernel.h>
#if defined(CONFIG_BOARD_NATIVE_SIM)
#include "gpio_visualizer.hpp"
#endif
// IP and port of the PC running XRCE-DDS agent
#define AGENT_IP "192.168.1.100"
#define AGENT_PORT 8888
int main(void)
{
#if defined(CONFIG_BOARD_NATIVE_SIM)
spawn_gpio_visualizer_thread();
#endif
{
// Initialize micro-ROS support for Zephyr UDP transport
rmw_uros_set_custom_transport(
true, // enable
NULL, // user data (none)
zephyr_transport_open,
zephyr_transport_close,
zephyr_transport_write,
zephyr_transport_read);
while (1) {
printk("Hello World! %s\n", CONFIG_BOARD_TARGET);
k_sleep(K_SECONDS(2));
}
// Initialize rcl context, node, publisher, subscriber, etc...
return 0;
// Your app code here
while (1) {
// Spin or sleep
k_sleep(K_MSEC(100));
}
return 0;
}