"move_generic_model.py" from Unit 3 is wrong?

There’s a class called Coordinates in this script that uses the get_logger() method. Since Coordinates doesn’t inherit from Node, it has no access to this method.

class Coordinates:
    def __init__(self, x, y, z, roll, pitch, yaw):
        self.x = x
        self.y = y
        self.z = z
        self.roll = roll
        self.pitch = pitch
        self.yaw = yaw

    def print_coordinates(self):
        self.get_logger().info("[ x, y, z] = [" + str(self.x) + ", " +
                      str(self.y) + ", " + str(self.z) + "]")
        self.get_logger().info("[ roll, pitch, yaw] = [" + str(self.roll) +
                      ", " + str(self.pitch) + ", " + str(self.yaw) + "]")

Hello @systems4you,

welcome to the community and thanks for reporting this issue.

I made a note so that we can fix asap. In the meantime, try replacing the print_coordinates function with this one:


def print_coordinates(self):
       rclpy.logging.get_logger("Coord").info("[ x, y, z] = [" + str(self.x) + ", " + str(self.y) + ", " + str(self.z) + "]")
       rclpy.logging.get_logger("Coord").info("[ roll, pitch, yaw] = [" + str(self.roll) + ", " + str(self.pitch) + ", " + str(self.yaw) + "]")

And see how it goes.

We are looking forward to hearing from you.

Roberto

1 Like

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