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

Differential Drive robot having difficulty doing 180 turns during navigation.

asked 2023-04-28 14:35:25 -0500

Grunthorin gravatar image

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.

edit retag flag offensive close merge delete

Comments

Are you using move_base? Or did you write custom code to write directly to the cmd_vel topic? Or something else?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-04-30 08:18:57 -0500 )edit

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.

Grunthorin gravatar image Grunthorin  ( 2023-05-02 05:59:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-28 16:52:31 -0500

ljaniec gravatar image

updated 2023-05-03 12:01:40 -0500

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.

edit flag offensive delete link more

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.

Grunthorin gravatar image Grunthorin  ( 2023-05-02 06:20:17 -0500 )edit

How does robot behave with this code in place? Does it rotate erratically or ..?

ljaniec gravatar image ljaniec  ( 2023-05-03 12:03:22 -0500 )edit

Yes, it rotates erratically. Even with the same route, it never stops on the same orientation, although it never stops on the right direction.

Grunthorin gravatar image Grunthorin  ( 2023-05-04 06:50:26 -0500 )edit

Question Tools

Stats

Asked: 2023-04-28 14:35:25 -0500

Seen: 100 times

Last updated: May 03 '23