ただのシリアルです

Dependencies:   mbed ros_lib_kinetic

Committer:
yuto17320508
Date:
Tue Mar 06 16:49:27 2018 +0000
Revision:
0:728f686a985b
a;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yuto17320508 0:728f686a985b 1 /*
yuto17320508 0:728f686a985b 2 2 * rosserial Publisher Example
yuto17320508 0:728f686a985b 3 3 * Prints "hello world!"
yuto17320508 0:728f686a985b 4 4 */
yuto17320508 0:728f686a985b 5 #include"mbed.h"
yuto17320508 0:728f686a985b 6 #include <ros.h>
yuto17320508 0:728f686a985b 7 #include <std_msgs/String.h>
yuto17320508 0:728f686a985b 8
yuto17320508 0:728f686a985b 9 ros::NodeHandle nh;
yuto17320508 0:728f686a985b 10
yuto17320508 0:728f686a985b 11 std_msgs::String str_msg;
yuto17320508 0:728f686a985b 12 ros::Publisher chatter("chatter", &str_msg);
yuto17320508 0:728f686a985b 13
yuto17320508 0:728f686a985b 14 char hello[13] = "hello world!";
yuto17320508 0:728f686a985b 15
yuto17320508 0:728f686a985b 16 DigitalOut led = LED1;
yuto17320508 0:728f686a985b 17
yuto17320508 0:728f686a985b 18 int main() {
yuto17320508 0:728f686a985b 19 nh.initNode();
yuto17320508 0:728f686a985b 20 nh.advertise(chatter);
yuto17320508 0:728f686a985b 21
yuto17320508 0:728f686a985b 22 while (1) {
yuto17320508 0:728f686a985b 23 led = !led;
yuto17320508 0:728f686a985b 24 str_msg.data = hello;
yuto17320508 0:728f686a985b 25 chatter.publish( &str_msg );
yuto17320508 0:728f686a985b 26 nh.spinOnce();
yuto17320508 0:728f686a985b 27 wait_ms(1000);
yuto17320508 0:728f686a985b 28 }
yuto17320508 0:728f686a985b 29 }