Redundant code in subscriber example?

Why are these different? In the first, ones seems redundant, how does creating self.node_name help later in the script?


class ObstacleDetectorNode (Node):
def init(self,node_name=“obstacle_detector_node”):
self.node_name = node_name
super().init(self.node_name)

class MoveRoverNode(Node):
def init(self):
# Here you have the class constructor
# call super() in the constructor to initialize the Node object
# the parameter you pass is the node name
super().init(‘move_rover_node’)


If self.node_name is not used later in the script, it is redundant indeed. We’ll review that and make the necessary corrections.

Thanks for calling it out.

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