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

error connection rosserial via bluetooth arduino notebook

asked 2014-05-25 08:32:15 -0500

amburkoff gravatar image

updated 2014-05-25 08:33:22 -0500

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.

edit retag flag offensive close merge delete

Comments

Does serial over bluetooth work when you're not using a rosserial sketch? Is the baud rate on your bluetooth module set correctly?

ahendrix gravatar image ahendrix  ( 2014-05-25 09:26:34 -0500 )edit

Yes I used to work with this Bluetooth module via serial data is transferred. Baud rate correct.

amburkoff gravatar image amburkoff  ( 2014-05-26 06:01:23 -0500 )edit

Have you solve this? I'm having the same problem now. its annoying!

EwingKang gravatar image EwingKang  ( 2014-09-06 22:51:47 -0500 )edit

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).

EwingKang gravatar image EwingKang  ( 2015-03-22 21:00:39 -0500 )edit

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).

David FLD gravatar image David FLD  ( 2022-06-05 05:25:54 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2015-03-22 17:25:29 -0500

fmgb gravatar image

updated 2018-06-26 14:55:45 -0500

jayess gravatar image

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 :)

edit flag offensive delete link more

Question Tools

4 followers

Stats

Asked: 2014-05-25 08:32:15 -0500

Seen: 1,701 times

Last updated: Jun 26 '18