Closed mburaozkan closed 5 months ago
I have wrote the publisher inside to see whether the size exceeds the limit like this
void my_subscriber_callback(const void * msgin)
{
msg = (const std_msgs__msg__Int16MultiArray *)msgin;
if (msg != NULL)
{
motor_driver_drive(msg->data.data);
int size = msg->data.size; // Get the size of the received data array
snprintf(pub_msg.data.data, pub_msg.data.capacity, "Received size: %d", size);
pub_msg.data.size = strlen(pub_msg.data.data);
rcl_publish(&my_pub, &pub_msg, NULL);
}
}
The output is:
->ros2 topic echo /iturov/topic_0
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
data: 'Received size: 6'
---
But as I said after some point subscriber callback is not called so the text 'data: 'Received size: 6'' stops publishing
using std_msgs__msg__Int16MultiArray__init
is not recommended. Probably this is a bad memory initialization of the subscription message, you can read further about this topic here: https://docs.vulcanexus.org/en/latest/rst/tutorials/micro/memory_management/memory_management.html#message-memory
I solved it, the problem was that I did not do the following in IOC file:
-> Set the DMA mode to Circular for Rx
I am using microros on my board STM32H7xx that connected to my pc, and my aim is to write a publisher from my pc to control the thrusters connected to my PCA9685 via microcontroller.
The microros is working fine I have tried several publishers and subscribers, but when I try to do the task that I explained above the published messages come to my code and run the thrusters but after a few seconds the thrusters get stuck at a point where I no longer can change the pwm of the thrusters.
I thought that this might be about my subscriber buffer size etc.
This is my code:
Initialize here
My Subs Callback:
Timer for publisher:
Main:
Also my publisher is still working even after the subscriber stops recieving messages, so I don't think the proccesor goes into hard fault etc.
Also I checked this issue: https://github.com/micro-ROS/micro_ros_arduino/issues/413