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: examples/ServiceClient.cpp
- Revision:
- 3:dff241b66f84
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/ServiceClient.cpp Sat Nov 12 23:53:04 2011 +0000 @@ -0,0 +1,40 @@ +//#define COMPILE_SERVICECLIENT_CODE_ROSSERIAL +#ifdef COMPILE_SERVICECLIENT_CODE_ROSSERIAL + +/* + * rosserial Service Client + */ + +#include <ros.h> +#include <std_msgs/String.h> + +#include <rosserial_arduino/Test.h> + +ros::NodeHandle nh; +using rosserial_arduino::Test; + +ros::ServiceClient<Test::Request, Test::Response> client("test_srv"); + +std_msgs::String str_msg; +ros::Publisher chatter("chatter", &str_msg); + +char hello[13] = "hello world!"; + +int main() { + nh.initNode(); + nh.serviceClient(client); + nh.advertise(chatter); + while (!nh.connected()) nh.spinOnce(); + nh.loginfo("Startup complete"); + while (1) { + Test::Request req; + Test::Response res; + req.input = hello; + client.call(req, res); + str_msg.data = res.output; + chatter.publish( &str_msg ); + nh.spinOnce(); + wait_ms(100); + } +} +#endif \ No newline at end of file