micro-ROS / micro-ROS/micro_ros_stm32cubemx_utils
rcl_publish() doesn't publish with success
- Dominant language
- C
- Stars
- 275
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I try to start example program in stm32 cube ide that publish data.
Hardware description: custom board witm stm32h743VIT6

RTOS: FreeRTOS
Installation type: micro_ros_stm32cubemx_utils
Version or commit hash: Foxy
I did everything like in the start up guide.
Default task:
```c
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
// micro-ROS configuration
rmw_uros_set_custom_transport(
true,
(void *) &huart2,
cubemx_transport_open,
cubemx_transport_close,
cubemx_transport_write,
cubemx_transport_read);
rcl_allocator_t freeRTOS_allocator = rcutils_get_zero_initialized_allocator();
freeRTOS_allocator.allocate = microros_allocate;
freeRTOS_allocator.deallocate = microros_deallocate;
freeRTOS_allocator.reallocate = microros_reallocate;
freeRTOS_allocator.zero_allocate = microros_zero_allocate;
if (!rcutils_set_default_allocator(&freeRTOS_allocator)) {
printf("Error on default allocators (line %d)\n", __LINE__);
}
// micro-ROS app
rcl_publisher_t publisher;
std_msgs__msg__Int32 msg;
rclc_support_t support;
rcl_allocator_t allocator;
rcl_node_t node;
allocator = rcl_get_default_allocator();
//create init_options
rclc_support_init(&support, 0, NULL, &allocator);
// create node
rclc_node_init_default(&node, "cubemx_node", "", &support);
// create publisher
rclc_publisher_init_default(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
"cubemx_publisher");
msg.data = 0;
for(;;)
{
rcl_ret_t ret = rcl_publish(&publisher, &msg, NULL);
if (ret != RCL_RET_OK)
{
printf("Error publishing (line %d)\n", __LINE__);
}
msg.data++;
osDelay(10);
}
```
I checked with debugger that task is executed, but there is error code no. 300 - RCL_RET_PUBLISHER_INVALID.
I'm using DMA transport. Communication in the hardware layer works.
When:
` rclc_support_init(&support, 0, NULL, &allocator);
`
is called I see 10 messages with the logic analyzer(every one is the same):

I have another task related to communication with motors and other peripherals with the lowest possible priority and that one works fine.
What can be reason of that issue? I can't debug what happens inside rcl_publish() from my program.

There is a few problems with the DMA on the STM32H743 - to use it it is necessary to use cache invalidation function. Is that possible that can cause the problem?
Best regards
Contributor guide
Assessment
This issue has not been assessed yet.