Robotics StackExchange | Archived questions

Troubles to move turtlebot_gazebo

I started a small project where I wanted to move the turtlebot in gazebo. I launched: roslaunch turtlebotgazebo turtlebotworld.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 turtlebotteleopkeyboard 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

Asked by S.Yildiz on 2018-08-16 08:08:16 UTC

Comments

I also tried it with x = 20.0 or y

Asked by S.Yildiz on 2018-08-16 08:08:53 UTC

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

Asked by Delb on 2018-08-16 09:31:59 UTC

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

Asked by Delb on 2018-08-16 09:33:14 UTC

Answers