# Turtlebot not moving

Hey guys, I'm still a beginner in ROS and I wrote a simple program in C++ that makes the turtlebot move in a square trajectory. I have the electric version of ROS installed. I used rosmake to compile the package and rosrun to run the executable file. The problem is, the turtlebot is not moving or anything. I tried to use a printf to see if the code was working and it did. I also tried to use the teleop package and it worked too. So I don't know what else I can do to make it work. Some help with that would be much appreciated :] Here is the code I used:

int main(int argc, char** argv) { // ROS initialisation

ros::init(argc, argv, "turtle_motion");

ros::NodeHandle n;

ros::Publisher vel_pub = n.advertise<geometry_msgs::twist>("/turtlebot_node/cmd_vel", 1);

ros::Rate loop_rate(5);

unsigned int cpt=0;

while(ros::ok()) {

```
geometry_msgs::Twist cmd_vel;
//Trajectoire: Carré
//Premiere Phase
if (cpt>=0 && cpt<10){
cmd_vel.angular.z = 0; // rad/s
cmd_vel.linear.x = 0.03; // m/s
}
//Deuxieme Phase
if (cpt>=10 && cpt<20){
cmd_vel.angular.z = 0.786; // rad/s
cmd_vel.linear.x = 0; // m/s
}
//Troisieme Phase
if (cpt>=20 && cpt<30){
cmd_vel.angular.z = 0; // rad/s
cmd_vel.linear.x = 0.03; // m/s
}
//Quatrieme Phase
if (cpt>=30 && cpt<40){
cmd_vel.angular.z = 0.786; // rad/s
cmd_vel.linear.x = 0; // m/s
}
//Cinquieme Phase
if (cpt>=40 && cpt<50){
cmd_vel.angular.z = 0; // rad/s
cmd_vel.linear.x = 0.03; // m/s
}
//Sixieme Phase
if (cpt>=50 && cpt<60){
cmd_vel.angular.z = 0.786; // rad/s
cmd_vel.linear.x = 0; // m/s
}
//Septieme Phase
if (cpt>=60 && cpt<70){
cmd_vel.angular.z = 0; // rad/s
cmd_vel.linear.x = 0.03; // m/s
}
//Huitieme Phase
if (cpt>=70 && cpt<80){
cmd_vel.angular.z = 0.786; // rad/s
cmd_vel.linear.x = 0; // m/s
}
if (cpt>=80) cpt=0;
cpt++;
vel_pub.publish(cmd_vel);
ros::spinOnce();
loop_rate.sleep();
```

}

return(0); }

Is this really your code? I doubt that it compiles. The type you specify in the advertise call (geometry_msgs::twist) does not exist. It must be geometry_msgs::Twist. Please make sure you read the support guidelines before posting. Always copy-paste code and format it.

The first step for debugging your issue is to call

`rostopic echo /turtlebot_node/cmd_vel`

and check if your node publishes correct data. If the data looks good, check if the topic is connected:`rostopic info /turtlebot_node/cmd_vel`

. Please edit your question and provide the output.