Rosanswers logo

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 serial_node.py (from the ros wiki), using the command:

rosrun rosserial_python serial_node.py _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 = myBT.read ();
    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);
    str_msg.data = '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

Originally posted by Ayush Sharma on ROS Answers with karma: 41 on 2017-06-17

Post score: 0


1 Answer 1


Rosanswers logo

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 http://wiki.ros.org/rosserial_server.

Originally posted by thepirate16 with karma: 101 on 2017-06-25

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by Ayush Sharma on 2017-06-26:
Respected, I have tried the same earlier. But, no positive results!!!!


Your Answer

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