rosbot 2.0 PWM publish error
Hello. I am a student studying with Rosbot 2.0.
I modified the code to get the rosbot's PWM value.
I added the code below to the main.cpp file of the firmware.
#include <std_msgs/Float32MultiArray.h>
std_msgs::Float32MultiArray pwm_msg;
ros::Publisher *pwm_pub;
volatile bool pwm_publish_flag = true;
// PWM
float pwm[] = {0, 0, 0, 0};
static void initPwmPublisher()
{
pwm_pub = new ros::Publisher("pwm", &pwm_msg);
nh.advertise(*pwm_pub);
}
int main()
.
.
.
initPwmPublisher();
if (pwm_publish_flag)
{
// Get duty cycle
// '(RosbotMotNum)1' corresponds to Motor1
pwm[0] = RosbotDrive::getInstance().getSpeed((RosbotMotNum)1, SpeedMode::DUTY_CYCLE);
pwm[1] = RosbotDrive::getInstance().getSpeed((RosbotMotNum)2, SpeedMode::DUTY_CYCLE);
pwm[2] = RosbotDrive::getInstance().getSpeed((RosbotMotNum)3, SpeedMode::DUTY_CYCLE);
pwm[3] = RosbotDrive::getInstance().getSpeed((RosbotMotNum)4, SpeedMode::DUTY_CYCLE);
pwm_msg.data = pwm;
if (nh.connected())
pwm_pub->publish(&pwm_msg);
}
After building the above code and updating the firmware, I entered the below command into the terminal.
roslaunch rosbot_ekf all.launch
As a result, an error occurred when requesting the topic.
The error message is shown in the figure below.
The error message is "[ERROR] [1648106980.691931]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino".
There was no problem when receiving 1 PWM signal, but an error occurs when receiving 4 PWM signals using Float32MultiArray.
How can I solve it?
Please help me.
Thank you.