Problem publishing at cmd_vel
Hello,
I have written the following code so I can send commands to my robots motors, which are listening to the /labrob/cmd_vel
topic:
#include "ros/ros.h"
#include "geometry_msgs/Twist.h"
int main(int argc, char **argv)
{
ros::init(argc, argv,"vel");
ros::NodeHandle vel;
ros::Publisher vel_pub = vel.advertise<geometry_msgs::Twist>("/labrob/cmd_vel", 100);
ros::Rate loop_rate(10);
geometry_msgs::Twist msg;
msg.linear.x = 0.1;
msg.linear.y = 0;
msg.linear.z = 0;
msg.angular.x = 0;
msg.angular.y = 0;
msg.angular.z = 0;
vel_pub.publish(msg);
ros::spin();
return 0;
}
With the rostopic pub command via the terminal, I can move the robot fine, but with the code I posted, the robot does not respond. What I am doing wrong ?