Ask Your Question
0

Node containing bluetooth communication does not work at first.

asked 2016-10-08 23:24:55 -0600

Giovani Debiagi gravatar image

updated 2016-10-08 23:31:49 -0600

Hello, guys.

I've been working on a project that needs data sent from an Arduino Nano, via bluetooth module (HC-05), to be received and used by a node on ROS. In order to do that, I've already developed the code for getting the message data from the bluetooth port and sending them to another node. I've been using the following steps to accomplish my goal.

Detect bluetooth devic $ rosrun imu imues.

$ hcitool scan

Pair device.

$ bluez-simple-agent hci0 20:15:07:27:76:81

Edit rfcomm.conf file with "bind no" configuration.

$ sudo vim /etc/bluetooth/rfcomm.conf

Initialize ROS.

$ roscore

Establish connection between bluetooth module and computer.

$ sudo rfcomm connect 0

Create linking between the bluetooth port (rfcomm0) and a random serial port to be created. This is done because if I set rfcomm0 port as a parameter of one of my nodes, apparently, the node doesn't recognize it and doesn't work.

$ sudo ln -s /dev/rfcomm0 /dev/ttyBluetooth

Set the recently created port (ttyBluetooth) as a parameter for one of my nodes.

$ rosparam set /imu_node/serial_port "/dev/ttyBluetooth"

Run node.

$ rosrun imu imu

The problem is that, when I do this, at first, it doesn't work and the node seems to crash (I can't stop it with Ctrl+C neither Ctrl+X). But, if I follow the steps below, it works normally.

  • Close the terminal session where the node was called.

  • Terminate bluetooth connection.

  • Terminate ros session.

  • Restart bluetooth connection.

    $ sudo rfcomm connect 0

  • Restart ROS.

    $ roscore

  • Reset the parameter.

    $ rosparam set /imu_node/serial_port "/dev/ttyBluetooth"

  • Run the node again.

    $ rosrun imu imu

Does anyone know what might be happening?

Thank you all.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-14 10:29:16 -0600

Giovani Debiagi gravatar image

SOLVED

Well, it seems like my bluetooth module (HC-05) gets "busy" when I try to connect it to the computer for the first time, since it's on. I've seen some tutorials where one of the last steps was "If you get a message telling you that your device is busy, try restarting the connection". This has made me assume that people often have this problem and it's hardware or even a bluetooth-ubuntu connection issue.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-08 23:24:55 -0600

Seen: 414 times

Last updated: Oct 14 '16