You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am receiving multiple CAN bus message every 20ms which is decoded and arranged as a JSON message and sent to the publishing task using FreeRTOS queue. the message is 500 bytes long. I am confused how should I set the setspinTimeout (can't understand what it even does by looking at the code comments in the header files) and how often should i call spinOnce.
#include <ros.h>
#include <std_msgs/String.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("CAN_Data", &str_msg);
void messageSenderTask(void *pvParameters)
{
// ... [initialization and other code]
while (true)
{
char message[JSON_BUFFER_SIZE];
if (xQueueReceive(messageQueue, message, (TickType_t)0))
{
if (nh.connected())
{
str_msg.data = message;
chatter.publish(&str_msg);
}
}
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(10));
}
}
void setup()
{
// ... [initialization and other setup code]
nh.getHardware()->setConnection(server, serverPort);
nh.initNode();
nh.advertise(chatter);
nh.setSpinTimeout(50);
// ... [creation of other tasks]
}
void loop()
{
nh.spinOnce();
taskYIELD();
}
some questions:
does calling publish return immediately and does it write all the 500 bytes to the rosserial server node in one publish call ? Can i call publish multiple times in a subroutine without calling spinOnce or does each publish call needs spinOnce call ?
looking for advice on any modifications to this code for this purpose.
EDIT:
board is OLIMEX ESP32 EVB working with Ethernet connection
The text was updated successfully, but these errors were encountered:
I am receiving multiple CAN bus message every 20ms which is decoded and arranged as a JSON message and sent to the publishing task using FreeRTOS queue. the message is 500 bytes long. I am confused how should I set the setspinTimeout (can't understand what it even does by looking at the code comments in the header files) and how often should i call spinOnce.
some questions:
does calling publish return immediately and does it write all the 500 bytes to the rosserial server node in one publish call ? Can i call publish multiple times in a subroutine without calling spinOnce or does each publish call needs spinOnce call ?
looking for advice on any modifications to this code for this purpose.
EDIT:
board is OLIMEX ESP32 EVB working with Ethernet connection
The text was updated successfully, but these errors were encountered: