Skip to content

Instantly share code, notes, and snippets.

@detik19
Created February 1, 2015 12:20
Show Gist options
  • Save detik19/89a62994bbb7ed1e2797 to your computer and use it in GitHub Desktop.
Save detik19/89a62994bbb7ed1e2797 to your computer and use it in GitHub Desktop.
Hello World using ROS Serial (Publisher) for Arduino
/*
* 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