Muhammed Zain
Published © MIT

Rosserial Arduino : Part 2

ROSSerial communication using Arduino NANO.

IntermediateWork in progress2 hours529
Rosserial Arduino : Part 2

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1

Software apps and online services

Robot Operating System
ROS Robot Operating System
Arduino IDE
Arduino IDE

Story

Read more

Code

Hello World Code

C/C++
/*
 * 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);
}

Credits

Muhammed Zain
12 projects • 36 followers
Maker | IoT DEV | Designer | Electronics researcher | Robotics
Contact

Comments

Please log in or sign up to comment.