turtlebot is not moving with published messages on cmd_vel
Hello, I have a simple turtle_move.cpp file that is suppose to make the turtlebot move in a square. The turtlesim program moves like its suppose to fine with my source code. I am using ROS groovy and a turtlebot 2.
#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
int main(int argc, char **argv) {
// Initialize the ROS system and become a node.
ros::init(argc, argv, "turtle_move");
ros::NodeHandle nh;
// Create a publisher object.
ros::Publisher pub = nh.advertise<geometry_msgs::Twist>(
"cmd_vel", 1);
// Seed the random number generator.
// Loop at 2Hz until the node is shut down.
ros::Rate rate(.5);
// Create and fill in the message.
geometry_msgs::Twist vel;
vel.angular.z = 0.0;
vel.linear.x = 0.0;
do{
// Publish the message.
pub.publish(vel);
rate.sleep();
vel.angular.z = 0.0;
vel.linear.x = 5.0;
ROS_INFO_STREAM("Sending random velocity command:"
<< " linear=" << vel.linear.x
<< " angular=" << vel.angular.z);
pub.publish(vel);
rate.sleep();
vel.angular.z = (float)1.5708;
vel.linear.x = 0.0;
// Send a message to rosout with the details.
ROS_INFO_STREAM("Sending random velocity command:"
<< " linear=" << vel.linear.x
<< " angular=" << vel.angular.z);
// Wait until it's time for another iteration.
rate.sleep();
}while(ros::ok());
}
The turtlebot is suppose to follow a square path. I have verified that my turtlebot is on and functional by running the turtlebot_teleop program first and everything was running fine. But when I try to run my program to make the turltebot follow a square it doesn't work. I have made sure that all my dependencies are accurate, my CMakeLists.txt includes an executable turtle_move.cpp file that runs just like I ran my code for the turtlesim which is working.
I noticed that a launch file exists does anyone know if this might be the reason my code is not controlling the turtlebot.
Thank you.