Troubles to move turtlebot_gazebo

asked 2018-08-16 08:08:16 -0600

S.Yildiz gravatar image

updated 2018-08-16 15:50:10 -0600

gvdhoorn gravatar image

I started a small project where I wanted to move the turtlebot in gazebo. I launched: roslaunch turtlebot_gazebo turtlebot_world.launch

I wrote a code to move it:

#include "ros/ros.h"
#include "geometry_msgs/TwistWithCovariance.h"
#include "nav_msgs/Odometry.h"
#include "gazebo_msgs/LinkState.h"
#include "geometry_msgs/Twist.h"

int main(int argc, char **argv){

    ros::init(argc,argv,"move");
    ros::NodeHandle n;
    ros::Publisher move_pub = n.advertise<geometry_msgs::Twist>("moving",1000);
    ros::Rate loop_rate(10);

    geometry_msgs::Twist msg;
    while(ros::ok()){
        msg.linear.x = 0.0;
        msg.linear.y = 0.0;
        msg.linear.z = 20.0;
        move_pub.publish(msg);

        ros::spinOnce();

        loop_rate.sleep();

    }
}

This doesn't work. As you can see i included other msgs and tried it with them but I got the same result. I also tried to find the node turtlebot_teleop_keyboard to find out how it is done by inputs. But i couldn't find the path to it. So what do I have to do to move it? And how can I find the path to the node?

Thank you in advance

edit retag flag offensive close merge delete

Comments

I also tried it with x = 20.0 or y

S.Yildiz gravatar image S.Yildiz  ( 2018-08-16 08:08:53 -0600 )edit
2

First if you want to move the turtlebot since it's not a drone publishing a linear.z command won't do anything you have to use linear.x to move forward/backward and orientation.z to turn.

Secondly, why are you publishing on the topic /moving ? It's usually the topic cmd_vel that is used

Delb gravatar image Delb  ( 2018-08-16 09:31:59 -0600 )edit

If you want to teleop the turtlebot, since the mobile base of the turtlebot is a kobuki you just have to use :

roslaunch kobuki_keyop keyop.launch
Delb gravatar image Delb  ( 2018-08-16 09:33:14 -0600 )edit