ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to keep turtlebot 3 straight at high speeds?

asked 2022-05-27 08:08:35 -0500

berk ince gravatar image

My turtlebots dont move straight at high speed (ex. 5.0). In my python codes ı want only move linear.x = 5.0 axis.

edit retag flag offensive close merge delete

Comments

What software are you using to send move commands to the robot? What software and sensors are you using to determine the current x,y position of the robot?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-05-27 14:46:44 -0500 )edit

I don't know exactly how to use the site, but I have uploaded the codes as an answer. For some reason I don't know, it loads without carriage returns.

berk ince gravatar image berk ince  ( 2022-05-27 15:32:37 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2022-05-27 14:50:53 -0500

ljaniec gravatar image

updated 2022-05-27 15:58:44 -0500

Please provide more details - what movement errors are evident? What does "don't move straight" mean? How do you control the robots in your simulation?

The speed you chose velocity is out of range for the TB3, real robots have a maximum translational velocity of 0.22-0.26 m/s... Your 5 m/s is ~twenty times higher. It looks like control with a kinematic model isn't sufficient here. Of course, I could be wrong about this.

-- EDIT:

You can use a code mentioned in this post and in the video for a simple controller:

A simple controller to do that would be the following:

  1. If the robot (odometry) orientation is not towards the target, then rotate only the robot until its orientation is towards the target. (...)

  2. Once the robot is headed towards the target, just move straight towards the goal until reached (...)

https://www.theconstructsim.com/ros-q...

Other fine material is here:

https://www.youtube.com/watch?v=D7ISr...

and here (the part with proportional controller is something which you particularly care about)

https://www.youtube.com/watch?v=Qh15N...

In general, lower speeds should certainly be used for the robots as well.

edit flag offensive delete link more

Comments

I don't know exactly how to use the site, but I have uploaded the codes as an answer. For some reason I don't know, it loads without carriage returns.

berk ince gravatar image berk ince  ( 2022-05-27 15:32:32 -0500 )edit

I re-formatted this code, but you should put it in the edit of the question, not as an answer.

ljaniec gravatar image ljaniec  ( 2022-05-27 15:42:30 -0500 )edit

Thank you for helping so much.

berk ince gravatar image berk ince  ( 2022-05-27 17:43:33 -0500 )edit

You can upvote/accept this answer, so it will be marked in the queue as solved - if you have some new questions, write them in next posts right away :)

ljaniec gravatar image ljaniec  ( 2022-05-27 18:11:17 -0500 )edit
0

answered 2022-05-27 15:20:54 -0500

berk ince gravatar image

updated 2022-05-27 15:37:04 -0500

ljaniec gravatar image

I'm using Gazebo for simulation my robot is default Turtlebot3_waffle. It spawn 0.0.0 location. I enter only linear.x value for movement but it the direction of the robot turns a little. Even if I run it at low speeds, I saw that it changes direction a little bit. It rotates outside the axis line even if it is on the axis initially.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Uygulama 1: Tek Eksen Boyunca Hareket I                           
"""
import rospy                                
from geometry_msgs.msg import Twist                                       
def hareket():                                 
     rospy.init_node("duz_git")                                         
    pub = rospy.Publisher("cmd_vel",Twist,queue_size=10)              
    hiz_mesaji = Twist()                                       
    hiz_mesaji.linear.x = 0.50      
    hiz_mesaji.linear.y = 0.0       
    hiz_mesaji.linear.z = 0.0     
    hiz_mesaji.angular.x = 0.0                
    hiz_mesaji.angular.y = 0.0                 
    hiz_mesaji.angular.z = 0.0                 
    mesafe = 50                   
    yer_degistirme = 0                   
    t0 = rospy.Time.now().to_sec()              
    while (yer_degistirme < mesafe):                       
        pub.publish(hiz_mesaji)                   
        t1 = rospy.Time.now().to_sec()                                 
        yer_degistirme = hiz_mesaji.linear.x * (t1-t0)                  
    hiz_mesaji.linear.x = 0.0                          
    hiz_mesaji.linear.y = 0.0               
    pub.publish(hiz_mesaji)                     
    rospy.loginfo("Hedefe varildi !")                                 

hareket()
edit flag offensive delete link more

Comments

How do you spawn the robot in Gazebo? Is the robot facing exactly in the direction of the OX axis, starting from the point (0,0,0)? At this high speed, any initial error can build up very quickly. If you want to move the robot in one direction, you could use a standard PID for correction while moving. I will update my answer with links to examples in a moment.

ljaniec gravatar image ljaniec  ( 2022-05-27 15:41:47 -0500 )edit

Your method is too simple for the real world, or for a somewhat accurate simulation. You are getting exactly the result I would expect. My advice is for you to learn about odometry and about algorithms used by local planner software.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-05-27 15:57:11 -0500 )edit

Thank you I will consider this. This code's aim is just for testing basic turtlebot movement.

berk ince gravatar image berk ince  ( 2022-05-27 17:45:17 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-05-27 08:08:35 -0500

Seen: 320 times

Last updated: May 27 '22