ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Arduino + Bluetooth + ROS : Error

asked 2017-06-17 10:09:28 -0600

Ayush Sharma gravatar image

updated 2017-06-17 10:15:29 -0600

Respected all, My task is to get the orientation sensor data from the phone and send it to the ROS for further processing.

I have decided to implement this via the following procedure: 1: Android App | 2: Bluetooth Shield | 3: Arduino (retrieving real time orientation data from android app) | 4: ROS (Rosserial)

I have implemented the first three steps and have retrieved the orientation data on arduino serial monitor on real time.

Now, when I am trying to use the (from the ros wiki), using the command:

rosrun rosserial_python _port:=/dev/ttyACM0 _baud:=9600

I am getting the following error! image description

This works well when I tried the conventional "Hello World" example of the rosserial. This means that the node files are working well. Also, i have use the command "nh.getHardware()-> setBaud(9600);" to set the baud rate.

Following is the code i am trying. (Please note that there can be manyy error in the code). I have edited the conventional "hello world" program and the arduino bluetooth code to get the orientation string


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

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

SoftwareSerial myBT (11, 10);
const int ledPin = 13;
String inCode = "";
boolean endCode = false;

void setup () {
  nh.getHardware()-> setBaud(9600);
  pinMode (ledPin, OUTPUT);
  inCode.reserve (30);

void loop () {
  if (myBT.available ()) {
    char incomingChar = ();
    if (incomingChar == ')') {
      endCode = true;
      inCode  = (inCode + incomingChar);

  if (endCode) {
    int comma1 = inCode.indexOf (',');
    int comma2 = inCode.indexOf (',', comma1 + 1);
    String As = inCode.substring (0, comma1);
    String Ps = inCode.substring (comma1 + 1, comma2);
    String Rs = inCode.substring (comma2 + 1);

    Serial.print ("inCode =");
    Serial.print (inCode);
    Serial.print ("Azimuth =");
    Serial.print (As);
    Serial.print ("Pitch =");
    Serial.print (Ps);
    Serial.print ("Roll =");
    Serial.println (Rs); = 'As';
    chatter.publish( &str_msg );

    int A = As.toInt ();
    int P = Ps.toInt ();
    int R = Rs.toInt ();

    inCode = "";
    endCode = false;

Why am i getting such errors? Kindly help. Regards

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-06-25 13:18:00 -0600

thepirate16 gravatar image

updated 2017-06-25 13:18:17 -0600

Have you tried using rosserial_server instead of rosserial_python? For me this solved a big part of the problem. Seems like rosserial_python cannot handle the connections most of the times so it's safer to use the server mode.

You can check

edit flag offensive delete link more


Respected, I have tried the same earlier. But, no positive results!!!!

Ayush Sharma gravatar image Ayush Sharma  ( 2017-06-26 11:13:12 -0600 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2017-06-17 10:09:28 -0600

Seen: 752 times

Last updated: Jun 25 '17