[Bug] different content of the __init__(self)

Screenshot of the error

Error details

The original rotate_robot.py content is the blued area. However, scroll down, the below explanation of this part of the code is different. You could compare them.

Hi @katrinac ,

I just checked the contents of the code and noted the following:

Code in python file (the part you have highlighted):

def __init__(self):
    rospy.init_node('robot_control_node', anonymous=True)
    self.vel_publisher = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
    self.cmd = Twist()
    self.ctrl_c = False
    self.rate = rospy.Rate(10)
    rospy.on_shutdown(self.shutdownhook)

Code in explanation:

def __init__(self):
    self.vel_publisher = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
    self.cmd = Twist()
    self.angular_speed_d = 0     # <--- extra line not used
    self.angle_d = 0             # <--- extra line not used
    self.angular_speed_r = 0     # <--- extra line not used
    self.angle_r = 0             # <--- extra line not used
    self.clockwise = False       # <--- extra line not used
    self.ctrl_c = False
    self.rate = rospy.Rate(10)
    rospy.on_shutdown(self.shutdownhook)

So the lines marked “extra line not used” are actually not needed in the explanation.
This is because these become the parameter arguments to the functions in the python file rotate_robot.py.
The above 5 values are taken from the user using an input() function inside the get_inputs_rotate(self) function. Therefore the 5 lines have no use in the code. It was probably forgotten to be removed during the course creation time.

So, you do not have to worry about the lines not matching, at least for now.
You can proceed with your learning.

Let me know if you face any problems later.

Regards,
Girish

2 Likes

Thank you very much! @girishkumar.kannan