ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

rosbot 2.0 PWM publish error

asked 2022-03-24 03:09:03 -0600

choking gravatar image

updated 2022-03-29 20:44:49 -0600

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.

image description

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-31 04:56:15 -0600

Armin Wolf gravatar image

Which firmware version did you install? Because you might also need to update rosbot_ekf and the Baudrate inside the launch file. I had the same problem after doing a firmware upgrade, i solved it by setting "serial_baudrate" of rosserial_bridge to 525000.

edit flag offensive delete link more

Comments

I have already modified the launch file "serial_baudrate" to 52500. Any other suggestions to solve this problem?

choking gravatar image choking  ( 2022-04-04 23:47:52 -0600 )edit

Its 525000 baud, not 52500 baud. Also please note that different ros version (melodic, ...) need different firmware versions. Since i assume you are using ROS 1 melodic, you should look here and pick "firmware_diff_melodic.bin" in case you rosbot does not use mecanum wheels, otherwise pick "firmware_mec_melodic.bin". Also make sure you have the latest version of "rosbot_ekf" installed.

Armin Wolf gravatar image Armin Wolf  ( 2022-04-05 07:25:52 -0600 )edit

Thanks for your reply. "serial_baudrate" to 52500 is typo. I modified it to 525000. and also, After building the firmware I flashed it to firmware_diff_melodic.bin. The "rosbot_ekf" version is also the latest version...

choking gravatar image choking  ( 2022-04-06 01:11:15 -0600 )edit

Ok, then maybe you should check if rosserial needs an update too. Also you could check if your baud rate is overriden somewhere.

Armin Wolf gravatar image Armin Wolf  ( 2022-04-06 07:45:26 -0600 )edit

If I publish each pwm without using an array, I can publish up to three motor pwm signals without error. However, if I publish 4 motor pwm signals, an error occurs. error message : "Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino"

I think it's a buffer size issue. How can I solve it?

Also, How can I check that the baud rate is overridden somewhere?

choking gravatar image choking  ( 2022-04-14 06:32:43 -0600 )edit

Looking at the output of ROS, the Baudrate can be seen just above the error message (i overlooked that you are already using the correct baudrate :/). You are using this code inside the core2 firmware, right? If so, then the firmware crashes once you try to access the 4th pwm signal. Maybe you can ask the people at Husarion about this issue.

Armin Wolf gravatar image Armin Wolf  ( 2022-04-14 10:14:28 -0600 )edit

Okay, Thank you, sir!

choking gravatar image choking  ( 2022-04-15 01:34:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-03-24 03:09:03 -0600

Seen: 174 times

Last updated: Mar 29 '22