Demo for rosserial working with ROS2
Dependencies: mbed ros_lib_melodic
Diff: main.cpp
- Revision:
- 0:91fdcf1ce3aa
diff -r 000000000000 -r 91fdcf1ce3aa main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 29 12:36:50 2021 +0000 @@ -0,0 +1,36 @@ +/* + * rosserial Publisher Example + * Prints "hello world!" + */ + +#include "mbed.h" +#include "string.h" +#include <ros.h> +#include <std_msgs/String.h> + +ros::NodeHandle nh; + +std_msgs::String str_msg; +ros::Publisher chatter("chatter", &str_msg); + +char hello[] = "Hello from Nucleo"; +DigitalOut led = LED1; +DigitalIn but(USER_BUTTON); + +int main() { + nh.initNode(); + nh.advertise(chatter); + + while (1) { + //if(but == 0) { + // while(but == 0); + led = !led; + str_msg.data = hello; + chatter.publish( &str_msg ); + nh.spinOnce(); + + //} + + wait_ms(100); + } +} \ No newline at end of file