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

Revision history [back]

click to hide/show revision 1
initial version

I would like to summarize all the issues I faced and how I solved it:

First issue: The following error in uploading the program:

avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding

There were some solution using reset bottom but it didn't work for me. I finally found out I should use "sudo arduino" to lunch the arduino and after that I can easily upload.

Second issue: using "sudo arduino" gave me this error:

fatal error: ros.h: No such file or directory compilation terminated.

Unfortunately methods in internet didn't help me. I just tried to copy ros-lib form sketchbook to "/usr/share/arduino/libraries" and Hallelujah the error was gone! :)

Finally the main part of my code is as follows:

#include <ros.h>
#include <sensor_msgs/LaserScan.h>

void Callback_laser(const sensor_msgs::LaserScan& scan)
{
double minval = scan.ranges[0];

    for(int i=0;i<500;i++)
    {
       if(scan.ranges[i]<minval or minval!=minval)
           minval=scan.ranges[i];
    } 
   Serial.println(minval);
}

ros::NodeHandle nh;
ros::Subscriber<sensor_msgs::LaserScan> laser_subscriber("scan", &Callback_laser);

void setup() {

  nh.initNode();
  nh.subscribe(laser_subscriber);

}

void loop() {

 nh.spinOnce();
 delay(100); 

}

Apparently, it works fine but some strange characters are written in Serial monitor!

Even when I run "Hello World" program in ros-arduino tutorial, hello world with those strange characters are printed!

In the following attached picture you can see the results. right terminal I run "rostopic echo /scan"; left terminal I run "rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0", and top is Serial monitor.

image description

I would like to summarize all the issues I faced and how I solved it:

First issue: The following error in uploading the program:

avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding

There were some solution using reset bottom but it didn't work for me. I finally found out I should use "sudo arduino" to lunch the arduino and after that I can easily upload.

Second issue: using "sudo arduino" gave me this error:

fatal error: ros.h: No such file or directory compilation terminated.

Unfortunately methods in internet didn't help me. I just tried to copy ros-lib form sketchbook to "/usr/share/arduino/libraries" and Hallelujah the error was gone! :)

Finally the main part of my code is as follows:

#include <ros.h>
#include <sensor_msgs/LaserScan.h>

void Callback_laser(const sensor_msgs::LaserScan& scan)
{
double minval = scan.ranges[0];

    for(int i=0;i<500;i++)
    {
       if(scan.ranges[i]<minval or minval!=minval)
           minval=scan.ranges[i];
    } 
   Serial.println(minval);
}

ros::NodeHandle nh;
ros::Subscriber<sensor_msgs::LaserScan> laser_subscriber("scan", &Callback_laser);

void setup() {

  nh.initNode();
  nh.subscribe(laser_subscriber);

}

void loop() {

 nh.spinOnce();
 delay(100); 

}

Apparently, I thought, it works fine but some strange characters are written apparently it's not! When I put a command in Serial monitor! callback function to on the LED it doesn't on the LED. I think the reason is the laserscan data is too large! (Not Sure Though)

Even when I run "Hello World" program in ros-arduino tutorial, hello world with those strange characters are printed!

In the following attached picture you can see the results. right terminal I run "rostopic echo /scan"; left terminal I run "rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0", and top is Serial monitor.

image description

I would like to summarize all the issues I faced and how I solved it:

First issue: The following error in uploading the program:

avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding

There were some solution using reset bottom but it didn't work for me. I finally found out I should use "sudo arduino" to lunch the arduino and after that I can easily upload.

Second issue: using "sudo arduino" gave me this error:

fatal error: ros.h: No such file or directory compilation terminated.

Unfortunately methods in internet didn't help me. I just tried to copy ros-lib form sketchbook to "/usr/share/arduino/libraries" and Hallelujah the error was gone! :)

Finally the main part of my code is as follows:

#include <ros.h>
#include <sensor_msgs/LaserScan.h>

void Callback_laser(const sensor_msgs::LaserScan& scan)
{
double minval = scan.ranges[0];

    for(int i=0;i<500;i++)
    {
       if(scan.ranges[i]<minval or minval!=minval)
           minval=scan.ranges[i];
    } 
   Serial.println(minval);
}

ros::NodeHandle nh;
ros::Subscriber<sensor_msgs::LaserScan> laser_subscriber("scan", &Callback_laser);

void setup() {

  nh.initNode();
  nh.subscribe(laser_subscriber);

}

void loop() {

 nh.spinOnce();
 delay(100); 

}

I thought, it works fine but apparently it's not! it doesn't! When I put a command in callback function to on the LED it doesn't on the LED. I think the reason is the laserscan data is too large! (Not Sure Though)

Even when I run "Hello World" program in ros-arduino tutorial, hello world with those strange characters are printed!

In the following attached picture you can see the results. right terminal I run "rostopic echo /scan"; left terminal I run "rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0", and top is Serial monitor.

image description