How to keep turtlebot 3 straight at high speeds?
My turtlebots dont move straight at high speed (ex. 5.0). In my python codes ı want only move linear.x = 5.0 axis.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
My turtlebots dont move straight at high speed (ex. 5.0). In my python codes ı want only move linear.x = 5.0 axis.
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:
If the robot (odometry) orientation is not towards the target, then rotate only the robot until its orientation is towards the target. (...)
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.
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()
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.
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.
Asked: 2022-05-27 08:08:35 -0500
Seen: 320 times
Last updated: May 27 '22
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?
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.