carbase

Dependencies:   mbed mbed-rtos ros_lib_melodic

main.cpp

Committer:
Gary Servin
Date:
2019-11-08
Revision:
0:f48f597ef690
Child:
3:a1a69ae50c18

File content as of revision 0:f48f597ef690:

/*
 * rosserial Subscriber Example
 * Blinks an LED on callback
 */
#include "mbed.h"
#include <ros.h>
#include <std_msgs/Empty.h>

ros::NodeHandle nh;
DigitalOut myled(LED1);

void messageCb(const std_msgs::Empty& toggle_msg){
    myled = !myled;   // blink the led
}

ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb);

int main() {
    nh.initNode();
    nh.subscribe(sub);

    while (1) {
        nh.spinOnce();
        wait_ms(1);
    }
}