Unit 6: Microproject problem with rotate function

Hello

Looks like I’m having some gremlins in my ROS.
While trying to build my escape for the robot out of the labyrinth I’m having problem with the rotate function in the RobotControl. I did copy/paste the updated robot_control_class from Unit 6. I even used @flarribagil code that he posted in his problem post just to see and it’s exactly the same reaction.

Here is what’s happening, I move forward to the first corner and try to rotate to the right 90’ but instead the robot rotates 180’ (facing back to where it came from) and just rotates back and forth about +/-10’ until I hit CTRL+C, at which point it just starts rotating 360’ counter-clockwise until I reset the simulation.

The following is the error message from terminal:

Traceback (most recent call last):
  File "Ex_6_microproject.py", line 29, in <module>
    firstturn.turns()
  File "Ex_6_microproject.py", line 24, in turns
    self.rc.rotate(self.rotate)
  File "/home/user/catkin_ws/src/robot_control/robot_control_class.py", line 175, in rotate
    self.rate.sleep()
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/timer.py", line 103, in sleep
    sleep(self._remaining(curr_time))
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/timer.py", line 165, in sleep
    raise rospy.exceptions.ROSInterruptException("ROS shutdown request")
rospy.exceptions.ROSInterruptException: ROS shutdown request

I did try to copy/paste again the robot_control_class just to make sure I eliminate any coping issues.
Any ideas on what I can check? Thanks

Hi @Cobra711 ,

could it be that you are sending commands too fast to the robot? Could you have a look at this answer to see whether your problem gets solved?

If the link above doesn’t solve the problem, could you try copying this robot_control_class.py to see whether the problem goes away?

Hello @ralves

Thank you once again for help, the first suggestion I’m not sure if it apply because I’m using the “rotate” function and not “turn”, so correct me if I’m wrong but we can’t assign angular speed to rotate, or can we?
Also like I mentioned I used code from this post (attached link) and had the same reaction, which would suggest that there is a problem with robot_control_class (maybe)

https://get-help.robotigniteacademy.com/t/unit-6-microproject-odometry-turtlebot/4385/2?u=cobra711

That brought me to your second suggestion and executed that, unfortunately same reaction with both codes.

Hello @Cobra711 ,

We’ve updated the rotate() function in the course project. Could you please update the robot_control_class.py and see if it solves your issue?

Best,

Hello @albertoezquerro

Yes, problem solved. :+1:t3: Thank you

2 Likes