Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
Dependents: roscar_ver_20190501_anglechange_copy
main.cpp
00001 /* 00002 * rosserial Subscriber Example 00003 * Blinks an LED on callback 00004 */ 00005 #include "mbed.h" 00006 #include <ros.h> 00007 #include <std_msgs/String.h> 00008 00009 ros::NodeHandle nh; 00010 DigitalOut myled(LED1); 00011 00012 std_msgs::String commandRead; 00013 ros::Publisher chatter("chatter", &commandRead); 00014 00015 // /* 00016 void handlerFunction(const std_msgs::String& commandSend){ 00017 commandRead = commandSend; 00018 } 00019 // */ 00020 00021 ros::Subscriber<std_msgs::String> sub("cmd_vel", &handlerFunction); 00022 00023 int main() { 00024 nh.initNode(); 00025 nh.subscribe(sub); 00026 nh.advertise(chatter); 00027 00028 char initialValue[2] = "X"; 00029 commandRead.data= initialValue; 00030 00031 while (1) { 00032 chatter.publish( &commandRead); 00033 nh.spinOnce(); 00034 wait_ms(10); 00035 } 00036 }
Generated on Mon Jul 18 2022 17:37:45 by
1.7.2