Ros-RTOS helloworld example project

Dependencies:   mbed-rtos mbed ros_lib_indigo

main.cpp

Committer:
randalthor
Date:
2017-01-04
Revision:
0:4934245d6d7a

File content as of revision 0:4934245d6d7a:

#include "mbed.h"
#include "rtos.h"
#include "cmsis_os.h"
#include <ros.h>
#include <std_msgs/String.h>



ros::NodeHandle  nh;
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);


DigitalOut led1(LED1);

void print_thread(void const *argument)
{
    char hello[13] = "hello world!"; 
    while (true) {
        Thread::wait(1000);
        str_msg.data = hello;
        chatter.publish( &str_msg );
        nh.spinOnce();
       
    }
}

int main()
{
    nh.initNode();
    nh.advertise(chatter);
    
  
    Thread thread(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);
    
    while (true) {
        led1 = !led1;
        Thread::wait(500);
    }
    
}