Publisher and subscriber using rosserial/arduino
hello, I am following the arduino susbcriber from the rosserial tutorials which blink a LED http://wiki.ros.org/rosserial_arduino... . In order to publish into the topic and run the program, I have to send the command "rostopic pub toggle_led std_msgs/Empty --once". I want to do this by running a c++ script that will publish into the topic as follows.
#include "ros/ros.h"
#include "std_msgs/Empty.h"
int main(int argc, char **argv){
ros::init(argc, argv, "toogle_msg");
ros::NodeHandle n;
std_msgs::Empty myMsg;
ros::Publisher toggle_msg= n.advertise<std_msgs::Empty>("toggle_msg",1);
toogle_msg.publish(myMsg);
ros::spinOnce();
return 0; }
When I run the program it doesn't publish into the topic so the LED doesn't start blinking. What am I missing?
I also have the rosrun rosserial_python serial_node.py /dev/ttyUSB0 running.
Thank you.