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
- Committer:
- FernandoLG
- Date:
- 2018-08-24
- Revision:
- 4:26006d815db0
- Parent:
- 3:6690a73cf982
File content as of revision 4:26006d815db0:
/*
* rosserial Subscriber Example
* Blinks an LED on callback
*/
#include "mbed.h"
#include <ros.h>
#include <std_msgs/String.h>
ros::NodeHandle nh;
DigitalOut myled(LED1);
std_msgs::String commandRead;
ros::Publisher chatter("chatter", &commandRead);
// /*
void handlerFunction(const std_msgs::String& commandSend){
commandRead = commandSend;
}
// */
ros::Subscriber<std_msgs::String> sub("cmd_vel", &handlerFunction);
int main() {
nh.initNode();
nh.subscribe(sub);
nh.advertise(chatter);
char initialValue[2] = "X";
commandRead.data= initialValue;
while (1) {
chatter.publish( &commandRead);
nh.spinOnce();
wait_ms(10);
}
}