![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Example of a Publisher and Subscriber ROS nodes for Mbed enable board using Twist messages.
Dependencies: mbed ros_lib_kinetic
main.cpp
- Committer:
- FernandoLG
- Date:
- 2018-08-13
- Revision:
- 1:fb8f963047b0
- Parent:
- 0:2595562b0c61
File content as of revision 1:fb8f963047b0:
/* * rosserial Subscriber Example * Blinks an LED on callback */ #include "mbed.h" #include <ros.h> #include <geometry_msgs/Twist.h> ros::NodeHandle nh; DigitalOut myled(LED1); geometry_msgs::Twist commandRead; ros::Publisher chatter("chatter", &commandRead); // /* void handlerFunction(const geometry_msgs::Twist& command){ commandRead = command; } // */ ros::Subscriber<geometry_msgs::Twist> sub("cmd_vel", &handlerFunction); int main() { nh.initNode(); nh.subscribe(sub); nh.advertise(chatter); commandRead.linear.x = 6.9; while (1) { //commandRead = command; chatter.publish( &commandRead); nh.spinOnce(); wait_ms(10); } }