# Turtlebot just stops moving even with the code executing

Hi! I am an Electrical Engineering student that really likes robotics. So I took up a class that tackled turtlebots. So below is a of my first code that in a given square space the bot would find the center. And I am using python as the programming language

Let me give a short explanation so basically I defined a function that would estimate values given a certain tolerance level. I know that python 3 already has a pre defined function that does exactly that but the OS(ubuntu) I was using somehow does not have that function, being a newbie I opt not meddle with the libraries and just decided to define a function. Any how the code estimates the distance in front of it and behind of it to tell whether to move forward. Also the code estimates the bots yaw to tell what direction to turn (towards the center).

if isclose(self.yaw,-1.56,0.0,0.3) or isclose(self.yaw,1.56,0.0,0.3) and not (isclose(self.yaw,0.0,0.0,0.3) or isclose(self.yaw,3.12,0.0,0.3)):
if not isclose(msg.ranges[0], msg.ranges[180],0.0, 0.2) and (isclose(self.yaw,0.0,0.0,0.15) or isclose(self.yaw,3.12,0.0,0.15) or isclose(self.yaw,-1.56,0.0,0.15) or isclose(self.yaw,1.56,0.0,0.15)):
print('WAT')
move.linear.x=0.1
move.angular.z=0.0
elif not isclose(msg.ranges[90], msg.ranges[270],0.0, 0.2) and isclose(self.yaw,-1.56,0.0,0.9) and msg.ranges[90] > msg.ranges[270]:
print('WAT1')
move.linear.x=0.0
elif not isclose(msg.ranges[90], msg.ranges[270],0.0, 0.2) and isclose(self.yaw,-1.56,0.0,0.9) and msg.ranges[90] < msg.ranges[270]:
print('WAT2')
move.linear.x=0.0
elif not isclose(msg.ranges[90], msg.ranges[270],0.0, 0.2) and isclose(self.yaw,1.56,0.0,0.9) and msg.ranges[90] > msg.ranges[270]:
print('WAT3')
move.linear.x=0.0
elif not isclose(msg.ranges[90], msg.ranges[270],0.0, 0.2) and isclose(self.yaw,1.56,0.0,0.9) and msg.ranges[90] < msg.ranges[270]:
print('WAT4')
move.linear.x=0.0
else:
move.linear.x=0.0
move.angular.z=0.0


This part seems to be problematic since during simulations I could see from the terminal that 'WAT3' prints but the bot does not move. A similar part of my code works just fine the difference with this is just ...

edit retag close merge delete