micro-ROS / micro_ros_stm32cubemx_utils

A set of utilities for integrating micro-ROS in a STM32CubeMX project
Apache License 2.0
169 stars 64 forks source link

STM32H753 microros (humble) publisher does not publish anything #152

Open ugurxun opened 2 months ago

ugurxun commented 2 months ago

Hello, I am trying to work with microros on STM32H753ZIT6U .

System: WSL Ubuntu22.04 Ros Distro: Humble Microcontroller: STM32H753ZIT6U Transport: USART with DMA USART baudrate: 115200

What I have done

I followed the instrunctions on microros tutorials and I created microros workspace, cloned micro_ros_setup, updated dependencies, installed python3-pip, builded, sourced. Then, I created firmware, builded it and crated microros agent.

I created a stm32cubeide project and arranged peripherals as HSE to crystal/seramic, SYS to TIM1. I enabled the USART3 (PD8, PD9) which is directly connected STLINKs microusb. I adjusted usart3_rx and usart3_tx for DMA with very high priority. I selected circular buffer for RX, I enabled the global interrupt for that. Finally, I enabled the FreeRTOS and I gave 12kb storage for stack of default task.

I cloned the micro_ros_stm32cubemx_utils and moved the files in extra_sources to /Core/Src . I deleted the files except dma_transport.c in microros_transports. Then, I added prebuid steps, micro-ROS include directory and Add the micro-ROS precompiled library as described. I sourced ros2 humble, micro ros workspace and gave the permissions via "sudo chmod 666 /var/run/docker.sock ". I found a basic projects ,compiled it and flashed succesfully. I runned the microros agent with "ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0". I also tried the run it with "ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888". However the publisher does not publish anything. Ekran görüntüsü 2024-08-16 152739

I tried to see the publisher with "ros2 topic list" but it is not seen.

Code

/ USER CODE BEGIN Header / /**


/ Private includes ----------------------------------------------------------/ / USER CODE BEGIN Includes /

include <rcl/rcl.h>

include <rcl/error_handling.h>

include <rclc/rclc.h>

include <rclc/executor.h>

include <uxr/client/transport.h>

include <rmw_microxrcedds_c/config.h>

include <rmw_microros/rmw_microros.h>

include <std_msgs/msg/int32.h>

/ USER CODE END Includes /

/ Private typedef -----------------------------------------------------------/ / USER CODE BEGIN PTD /

/ USER CODE END PTD /

/ Private define ------------------------------------------------------------/ / USER CODE BEGIN PD /

/ USER CODE END PD /

/ Private macro -------------------------------------------------------------/ / USER CODE BEGIN PM /

/ USER CODE END PM /

/ Private variables ---------------------------------------------------------/

UART_HandleTypeDef huart3; DMA_HandleTypeDef hdma_usart3_rx; DMA_HandleTypeDef hdma_usart3_tx;

/ Definitions for defaultTask / osThreadId_t defaultTaskHandle; const osThreadAttr_t defaultTask_attributes = { .name = "defaultTask", .stack_size = 3000 4, .priority = (osPriority_t) osPriorityNormal, }; / USER CODE BEGIN PV */

/ USER CODE END PV /

/ Private function prototypes -----------------------------------------------/ void SystemClock_Config(void); static void MPU_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_USART3_UART_Init(void); void StartDefaultTask(void *argument);

/ USER CODE BEGIN PFP /

/ USER CODE END PFP /

/ Private user code ---------------------------------------------------------/ / USER CODE BEGIN 0 /

/ USER CODE END 0 /

/**

/**

/**

}

/**

}

/**

/ USER CODE BEGIN MX_GPIO_Init_2 / / USER CODE END MX_GPIO_Init_2 / }

/ USER CODE BEGIN 4 / bool cubemx_transport_open(struct uxrCustomTransport transport); bool cubemx_transport_close(struct uxrCustomTransport transport); size_t cubemx_transport_write(struct uxrCustomTransport transport, const uint8_t buf, size_t len, uint8_t err); size_t cubemx_transport_read(struct uxrCustomTransport transport, uint8_t buf, size_t len, int timeout, uint8_t err);

void microros_allocate(size_t size, void state); void microros_deallocate(void pointer, void state); void microros_reallocate(void pointer, size_t size, void state); void microros_zero_allocate(size_t number_of_elements, size_t size_of_element, void * state);

/ USER CODE END 4 /

/ USER CODE BEGIN Header_StartDefaultTask / /**

void MPU_Config(void) { MPU_Region_InitTypeDef MPU_InitStruct = {0};

/ Disables the MPU / HAL_MPU_Disable();

/* Initializes and configures the Region and the memory to be protected / MPU_InitStruct.Enable = MPU_REGION_ENABLE; MPU_InitStruct.Number = MPU_REGION_NUMBER0; MPU_InitStruct.BaseAddress = 0x0; MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; MPU_InitStruct.SubRegionDisable = 0x87; MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct); / Enables the MPU / HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

/**

/**

ifdef USE_FULL_ASSERT

/**


What I expect to see

image Then, I need to see my topic in ros2 topic list. The publisher must publish increasing counter data.

Do you have any idea to solve my problem? Thank you all.

handsome7729 commented 1 week ago

have you solved the problem?

ugurxun commented 1 week ago

No, unfortunately i couldn't.