Differential Drive robot having difficulty doing 180 turns during navigation.
When arriving on a goal the robot swerves left to right until it decides to make a turn, occurs mainly in 180 like turns, was trying to create a code to make it rotate in place to the next path position, however as it turns out, that isn't the easiest thing for me to code, as I'm relatively new to all the ROS stuff. So i wanted to know if it could be some parameter that i haven't thought about or there was some other way i could make the code to be simple to work with. I'm using the ROS Kinetic and writing codes in python. Any help is wanted, thanks.
Asked by Grunthorin on 2023-04-28 14:35:25 UTC
Answers
I think you should show us some code snippets. Your robot's controller seems to be sensitive to the robot orientation, that is constrained by your encoders and/or other orientation sensors. You should try to include some dead zone around your target both for x
and y
coordinates and your robot orientation alpha
during checks if the robot should move/rotate.
Your target is quite similar to the so-called Rotation Shim Controller from Nav2 (ROS 2). I think you can base your code on it, check these parts:
The code has a lot of other features used, but the general idea is the same.
Asked by ljaniec on 2023-04-28 16:52:31 UTC
Comments
It's basically my code.
def rotate(self):
if self.rotate_axis:
if self.pathYaw < 0 and not self.enter:
z = -0.3
elif self.pathYaw >= 0 and not self.enter:
z = 0.3
self.enter = True
print('z', z)
while abs(abs(self.odomYaw) - abs(self.pathYaw)) > 0.01:
self.velocity_pub.publish(Twist(linear=Vector3(0, 0, 0), angular=Vector3(0, 0, z)))
self.enter = False
self.rotate_axis = False
Other than that, I have a callback that gets the quaternions of the localplan and another callback that get the quaternions of the odometry, in both callbacks the quaternions are converted to yaw.
Asked by Grunthorin on 2023-05-02 06:20:17 UTC
How does robot behave with this code in place? Does it rotate erratically or ..?
Asked by ljaniec on 2023-05-03 12:03:22 UTC
Yes, it rotates erratically. Even with the same route, it never stops on the same orientation, although it never stops on the right direction.
Asked by Grunthorin on 2023-05-04 06:50:26 UTC
Comments
Are you using move_base? Or did you write custom code to write directly to the cmd_vel topic? Or something else?
Asked by Mike Scheutzow on 2023-04-30 08:18:57 UTC
Yes, I'am using move_base, I used remap so it publishes on another topic and a custom code that manipulates the values to publish to cmd_vel.
Asked by Grunthorin on 2023-05-02 05:59:03 UTC