Ros-Arduino subscriber
Hi
I would like to send a message to arduino serial monitor, here is my code
#include <ros.h>
#include <sensor_msgs/LaserScan.h>
void Callback_laser(const sensor_msgs::LaserScan& scan)
{
Serial.print("Hello = :");
Serial.println(scan.ranges[0]);
}
ros::NodeHandle nh;
ros::Subscriber<sensor_msgs::LaserScan> laser_subscriber("scan", &Callback_laser);
void setup() {
nh.initNode();
nh.subscribe(laser_subscriber);
Serial.begin(9600);
}
void loop() {
nh.spinOnce();
delay(10);
}
but nothing will appear in serial monitor!
Could you please tell me what is the problem with my code?
Thanks in advance for your help.
When I put Serial.print("Hello = :"); inside void loop() I can see the message, but I cannot see any message when it's inside callback