[Solved] publisher problem in hydro
Hi everyone
I have a really strange behaviour I can not explain. I have a really simple program where I publish a message and then quit. When im not sleeping after creating the publisher, but i start immediately to publish the messages gets lost. Any ideas what the case may be? I am using hydro, and the roscore runs locally.
thanks flavio
#include "ros/ros.h"
#include "std_msgs/Float32.h"
int main(int argc, char **argv)
{
ros::init(argc, argv, "publish_test");
ros::NodeHandle nh;
ros::Publisher set_control_active_pub = nh.advertise< std_msgs::Float32>("/pixhawk_bridge/control_active2",10 );
ros::Duration(2).sleep();
std_msgs::Float32 activate_msg;
activate_msg.data = 0;
set_control_active_pub.publish( activate_msg );
ros::spinOnce();
ros::Duration(2).sleep();
return 0;
}