Created
February 1, 2015 12:20
-
-
Save detik19/89a62994bbb7ed1e2797 to your computer and use it in GitHub Desktop.
Hello World using ROS Serial (Publisher) for Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* rosserial Publisher Example | |
* Prints "hello world!" | |
*/ | |
#include <ros.h> | |
#include <std_msgs/String.h> | |
ros::NodeHandle nh; | |
std_msgs::String str_msg; | |
ros::Publisher chatter("chatter", &str_msg); | |
char hello[13] = "hello world!"; | |
void setup() | |
{ | |
nh.initNode(); | |
nh.advertise(chatter); | |
} | |
void loop() | |
{ | |
str_msg.data = hello; | |
chatter.publish( &str_msg ); | |
nh.spinOnce(); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment