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 Servo roscar_ver_20190501_anglechange_copy ros_lib_kinetic roscar_ver_20190501_copy
main.cpp
- Committer:
- FernandoLG
- Date:
- 2018-08-13
- Revision:
- 1:fb8f963047b0
- Parent:
- 0:2595562b0c61
- Child:
- 2:8b3e4bfa29e5
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);
    }
}