The robot is not behaving properly with negative linear velocity values

hi,

in the course project for python basics for robotics, when i want to move backwards, i use negative values for linear velocity, the robot just ignores all parameters and functions just goes full speed backward collide with the wall and fly off the map.

time.sleep(2) → is ignored, sample move value of linear as 0.5 moves it just a little bit forward, perfect no issues but if u give -0.5 it just flies off the turtlebot.

i havent tried other courses projects yet but if all are like this then i wont be able to complete them to get the certificates.

please help if i am doing something wrong

can you post some code?

hi,

sure, below is the function that was already there in the file.

#~#~#~#~#~# start your function definitions after this line #~#~#~#~#~#

def sample_move(linear, angular):
    # sample function to move the robot
    # this function can be deleted later!
    global robot_interface
    robot_interface.linear_velocity = linear
    robot_interface.angular_velocity = angular
    return None

#~#~#~#~#~# finish your function definitions before this line #~#~#~#~#~#

and here is the 2 versions of usage:

try:
        #~#~#~#~#~# start your program after this line #~#~#~#~#~#

        #~#~#~#~#~# write code here to run only once #~#~#~#~#~#
        sample_move(0.5, 0.000)
        time.sleep(5.0)
        sample_move(0.000, 0.000)
        time.sleep(1.0)

        #~#~#~#~#~# write code here to run continuously #~#~#~#~#~#
        
        
        #~#~#~#~#~# finish your program before this line #~#~#~#~#~#

the above works fine the robot just moves slightly forward, next is the following:

try:
        #~#~#~#~#~# start your program after this line #~#~#~#~#~#

        #~#~#~#~#~# write code here to run only once #~#~#~#~#~#
        sample_move(-0.5, 0.000)
        time.sleep(5.0)
        sample_move(0.000, 0.000)
        time.sleep(1.0)

        #~#~#~#~#~# write code here to run continuously #~#~#~#~#~#
        
        
        #~#~#~#~#~# finish your program before this line #~#~#~#~#~#

this time the robot just full steam ahead goes and bashes into the back wall and flies off the map then to be restored in the middle of the map again.

i appreciate your time and help, thank you.

I do not get from what course did you get the info.

My assumption is that you have to put something like linear.x and angular.z . The TWIST messages have for a differential robot linear speed around X and angular one around z

thanks for your response, the course is python basics for robotics, and its the course project.

these functions were already implemented in the workspace that was given. i just added the negative sign to the linear speed to go backwards but it dosent seem to work too well.

What page? Is te \python 3 one?

Quite strange. Can you try smaller values like -0.1 or even less?

All course projects aren’t like this. This is likely just a problem with this particular simulation.

hello,

yeah +0.5 moves it a little bit whereas -0.5 moves it quite a bit more and crashes it from where then it flies off the map.

your idea of 0.1 value worked in terms of it dint keep on moving until it crashes. i think with 0.1 its doable. i have attached some videos for reference of the behavior.

check out the 0.5 video and the 0.1 video for reference.

thank you

yes python 3 course, at the end there is a final project where you have to first simulate and then perform on the real robot right so that one is a little glitchy.

Thanks for sharing the information. We’ll use it to improve the simulation.

Unfortunately, I couldn’t view your cool videos. I got this instead (not so cool :wink:):

ahh sorry for that, i have updated the access, you can view them now, thank you.

I think it makes sense to reduce the speed for reverse as we have in real life :slight_smile:. If you use lower sleep values it also works, as demonstrated in the video below

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.