Go to the documentation of this file.00001
00002 #ifdef COMPILE_FLOAT64_CODE_ROSSERIAL
00003
00004
00005
00006
00007
00008
00009 #include "mbed.h"
00010 #include <ros.h>
00011 #include <std_msgs/Float64.h>
00012
00013
00014 ros::NodeHandle nh;
00015
00016 float x;
00017 DigitalOut myled(LED1);
00018
00019 void messageCb( const std_msgs::Float64& msg) {
00020 x = msg.data - 1.0;
00021 myled = !myled;
00022 }
00023
00024 std_msgs::Float64 test;
00025 ros::Subscriber<std_msgs::Float64> s("your_topic", &messageCb);
00026 ros::Publisher p("my_topic", &test);
00027
00028 int main() {
00029 nh.initNode();
00030 nh.advertise(p);
00031 nh.subscribe(s);
00032 while (1) {
00033 test.data = x;
00034 p.publish( &test );
00035 nh.spinOnce();
00036 wait_ms(10);
00037 }
00038 }
00039 #endif