![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
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
examples/ServoControl.cpp
- Committer:
- nucho
- Date:
- 2011-08-19
- Revision:
- 0:06fc856e99ca
File content as of revision 0:06fc856e99ca:
//#define COMPILE_SERVOCONTROL_CODE_ROSSERIAL #ifdef COMPILE_SERVOCONTROL_CODE_ROSSERIAL /* * rosserial Servo Control Example * * This sketch demonstrates the control of hobby R/C servos * using ROS and the arduiono * * For the full tutorial write up, visit * www.ros.org/wiki/rosserial_arduino_demos * * For more information on the Arduino Servo Library * Checkout : * http://www.arduino.cc/en/Reference/Servo */ #include "mbed.h" #include "Servo.h" #include <ros.h> #include <std_msgs/UInt16.h> ros::NodeHandle nh; Servo servo(p21); DigitalOut myled(LED1); void servo_cb( const std_msgs::UInt16& cmd_msg) { servo.position(cmd_msg.data); //set servo angle, should be from 0-180 myled = !myled; //toggle led } ros::Subscriber<std_msgs::UInt16> sub("servo", servo_cb); int main() { nh.initNode(); nh.subscribe(sub); while (1) { nh.spinOnce(); wait_ms(1); } } #endif