cancel
Showing results for 
Search instead for 
Did you mean: 

Messages being published at only one hertz(microros)

kapilan0902
Visitor

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

 this is the code of the 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 */
}

0 REPLIES 0