Void callback subscriber does not work [closed]
Hi Ros users
i would like to send odometry (just linear and angular velocity) to another IP via socket udp.
But I have a problem. The problem is that void velsubcallback is not executed and I do not why.. (The catkin_make is ok)
This is my .cpp and my int main (but i think we have to focus on while):
void velsubcallback(const nav_msgs::Odometry& msg)
{
variable1=msg.twist.twist.linear.x;
variable2=msg.twist.twist.angular.z;
lectura_ros.linear=variable1;
lectura_ros.angular=variable2;
ROS_INFO("variable %f",lectura_ros.linear);
}
int main(int argc, char **argv)
{
int va_send_to;
int long_dir_cli;
int socket_ros;
struct sockaddr_in dir_serv_socket,dir_cli_socket;
ros::init(argc, argv, "lanzando_vel");
ros::NodeHandle n;
while (ros::ok())
{
ros::Subscriber odom_sub = n.subscribe("p3dx/odom", 1000, velsubcallback);
va_send_to = sendto(socket_ros,(char *)&lectura_ros,sizeof(dato_ros),0,(struct sockaddr *)&dir_cli_socket,sizeof(dir_cli_socket));
Any idea??
Thank you so much!
Have you checked, that data gets published on this topic?
First of all, thanks!
Yes, I have. Data is publishing on this topic but the problem is that void velsub callback is not executed