0
$\begingroup$

Rosanswers logo

Can not run rosserial via bluetooth.
Arduino Uno
Blutooth module HC-06
Notebook with bluetooth Ubuntu 12.04 Ros Hydro
Arduino sketch:

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

char hello[13] = "hello world!";

void setup()
{
  nh.getHardware()->setBaud(9600);
  nh.initNode();
  nh.advertise(chatter);
}

void loop()
{
  str_msg.data = hello;
  chatter.publish( &str_msg );
  nh.spinOnce();
  delay(1000);
}

In terminal:

sudo rfcomm connect 0 98:D3:31:20:03:19 1

Connection is established, the red LED on the Bluetooth lit.

In new terminal:

$ rosrun rosserial_python serial_node.py _port:=/dev/rfcomm0
[INFO] [WallTime: 1401040615.342558] ROS Serial Python Node
[INFO] [WallTime: 1401040615.353809] Connecting to /dev/rfcomm0 at 9600 baud
[ERROR] [WallTime: 1401040632.468633] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

How to fix this error? If connecting by the usb cable, everything works.


Originally posted by amburkoff on ROS Answers with karma: 26 on 2014-05-25

Post score: 0


Original comments

Comment by ahendrix on 2014-05-25:
Does serial over bluetooth work when you're not using a rosserial sketch? Is the baud rate on your bluetooth module set correctly?

Comment by amburkoff on 2014-05-26:
Yes I used to work with this Bluetooth module via serial data is transferred. Baud rate correct.

Comment by EwingKang on 2014-09-06:
Have you solve this? I'm having the same problem now. its annoying!

Comment by EwingKang on 2015-03-22:
Actually I've solve my problem. It truns out that my bluetooth chip is a china made cheap one and not a real HC-06. And there is something like only a single post in some unkown forum that provides the datasheet. Generally speaking, it's the fault of baud rate (not usable if exceed certain rate).

Comment by David FLD on 2022-06-05:
I uploaded the this code on my arduino nano to have a serial communication with the ros via Hc-05 bluetooth module. It worked only with the 9600 baudrate (not 57600).

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I have fixed this error. I explain this: My Arduino's program is equal than yours. But I have one line different:

nh.getHardware()->setBaud(57600);

This is because ROS works with 57600 bauds and if you use less bauds, you'll lose many packages. So in terminal, I eject for the conection:

sudo rfcomm connect rfcomm1 MAC_DEVICE NUMBER_CHANNEL In my case would be:

sudo rfcomm connect rfcomm1 98:D3:31:B2:D8:EB 1

Thus the bluetooth's led will remain fixed, no flash.

The last, I eject ros with:

rosrun rosserial_python serial_node.py _port:=/dev/rfcomm1 _baud:=57600

And in other terminal: rostopic echo chatter

And bualá! jajajajajaja :) Hope this helps someone :)


Originally posted by fmgb with karma: 26 on 2015-03-22

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.