0
$\begingroup$

I have implemented microros on an stm32 nucleo f446re and wrote a publisher in it, while using default qos the messages published can't exceed the frequency more than one hertz even after removing the delay function.....Is there any way to increase the speed of the message publishing

here is the code for the FreeRTOS thread

    `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_best_effort( &publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), "cubemx_publisher");

msg.data = 0;

rcl_subscription_t subscription; std_msgs__msg__Int32 sub_msg;

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);

} /* USER CODE END 5 */ } `

$\endgroup$
1
  • $\begingroup$ Hi, I'm not expert on stm32, neither on micro-ros, but your problem might be linked to material constraints. Can you check the processor load ? There may be other threads running, consuming your processor resources. $\endgroup$ Commented Jul 10 at 10:14

1 Answer 1

-1
$\begingroup$

Im retty sure this has to do with the QoS settings. Try initiating the node with Best Effort instead of reliable. See this post: https://github.com/micro-ROS/micro_ros_arduino/issues/20

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.