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/Tutorials/Blink. In order to publish into the topic and run the program, I have to send the command "rostopic pub toggleled stdmsgs/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 rosserialpython serialnode.py /dev/ttyUSB0 running.
Thank you.
Asked by richardsondynamics on 2016-04-23 21:09:23 UTC
Comments