ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

The class must inherits from (or is a subclass of) Node. You are missing it! Please see a complete working example below:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import rclpy
from rclpy.node import Node


class TestMoveitNode(Node):
    def __init__(self):
        super().__init__("first_moveit_node")
        self.get_logger().info("Hello moveit")


def main(args=None):
    rclpy.init(args=args)
    node = TestMoveitNode()
    rclpy.spin(node)
    rclpy.shutdown()


if __name__ == "__main__":
    main()

This is how I run it:

$ ros2 run  examples_rclpy_minimal_publisher first_moveit_node 
[INFO] [1665138307.033597919] [first_moveit_node]: Hello moveit

Please feel free to look at the documentation.