This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.
Dependencies: rosserial_mbed_lib mbed Servo
Diff: tests/float64_test.cpp
- Revision:
- 4:2cbca0ac2569
- Parent:
- 3:dff241b66f84
--- a/tests/float64_test.cpp Sat Nov 12 23:53:04 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -//#define COMPLIE_FLOAT64_CODE_ROSSERIAL -#ifdef COMPILE_FLOAT64_CODE_ROSSERIAL - -/* - * rosserial::std_msgs::Float64 Test - * Receives a Float64 input, subtracts 1.0, and publishes it - */ - -#include "mbed.h" -#include <ros.h> -#include <std_msgs/Float64.h> - - -ros::NodeHandle nh; - -float x; -DigitalOut myled(LED1); - -void messageCb( const std_msgs::Float64& msg) { - x = msg.data - 1.0; - myled = !myled; // blink the led -} - -std_msgs::Float64 test; -ros::Subscriber<std_msgs::Float64> s("your_topic", &messageCb); -ros::Publisher p("my_topic", &test); - -int main() { - nh.initNode(); - nh.advertise(p); - nh.subscribe(s); - while (1) { - test.data = x; - p.publish( &test ); - nh.spinOnce(); - wait_ms(10); - } -} -#endif \ No newline at end of file