Ask Your Question
0

turtlebot is not moving with published messages on cmd_vel

asked 2014-06-12 13:02:10 -0600

choog gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-06-12 13:12:58 -0600

tfoote gravatar image

Have you verified that topics are hooked up correctly rostopic info or rqt graph? And have you verified that they're being published correctly with rostopic echo?

You also appear not to be spinning anywhere. There's a tutorial for writing a publisher here: http://wiki.ros.org/ROS/Tutorials/Wri...

And debugging tools can be found here: http://wiki.ros.org/ROS/Tutorials/Und...

edit flag offensive delete link more

Comments

No the program I have created is not creating a topic that connects to the cmd_vel node on the turltebot. When I launch the rqt graph there is no connection established.

choog gravatar imagechoog ( 2014-06-13 10:35:00 -0600 )edit

Thank for the info, I was able to debug the problem looking up different peoples problems

choog gravatar imagechoog ( 2014-06-13 12:39:56 -0600 )edit
2

answered 2014-07-30 09:52:39 -0600

silvia gravatar image

Hello! Choog, how did you solve the problem? I have the same and I do not achieve to connect the cmd_vel node on the turtlebot. Thanks for your help,

Silvia

edit flag offensive delete link more

Comments

Hello, I am having the same issue. Any solutions?

beluga gravatar imagebeluga ( 2019-01-23 06:36:38 -0600 )edit

Ah ok, I solved my issue. I needed to publish to /cmd_vel_mux/input/navi topic instead of /cmd_vel.

beluga gravatar imagebeluga ( 2019-01-23 07:10:55 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-06-12 13:02:10 -0600

Seen: 2,123 times

Last updated: Jun 12 '14