zmk5 / jupyter-ros2

Jupyter widget helpers for ros2, the Next-Generation of the Robot Operating System
28 stars 8 forks source link

NameError: name 'Node' is not defined #12

Open DONJAGA opened 2 years ago

DONJAGA commented 2 years ago

Ubuntu: 22.04 ROS2 Humble Hawksbill Python 3.10

jupyros and dependencies installed correctly and I have provided sys path as my local ROS2 site-packages for humble as :

import sys
sys.path.append('/opt/ros/humble/lib/python3.10/site-packages/')

Then import jupyros

import jupyros

But this error kicks in as

`The rclpy package is not found in your $PYTHONPATH. Subscribe and publish are not going to work.
Do you need to activate your ros2 environment?
CvBridge not installed or sourced! Image messages will not work until then!
The rclpy package is not found in your $PYTHONPATH. Subscribe and publish are not going to work.
Do you need to activate your ros2 environment?
The rclpy package is not found in your $PYTHONPATH. Subscribe and publish are not going to work.
Do you need to activate your ros2 environment?
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In [4], line 5
      2 sys.path.append('/opt/ros/humble/lib/python3.10/site-packages/')
      4 # The next line should now work!
----> 5 import jupyros

File ~/jupyter-ros2/jupyros/__init__.py:7
      5 from .ipy import *
      6 from .server_extension import *
----> 7 from .publisher import Publisher
      8 from .subscription import Subscription
      9 from .plot import LivePlot

File ~/jupyter-ros2/jupyros/publisher.py:25
     21 # Used for documentation purposes only
     22 MsgType = TypeVar('MsgType')
---> 25 class Publisher():
     26     """
     27     Creates a class containing the form widget for message type `msg_type`.
     28     This class analyzes the fields of msg_type and creates
   (...)
     38 
     39     """
     40     def __init__(self, node: Node, msg_type: MsgType, topic: str) -> None:
     41         # Check if a ros2 node is provided.

File ~/jupyter-ros2/jupyros/publisher.py:40, in Publisher()
     25 class Publisher():
     26     """
     27     Creates a class containing the form widget for message type `msg_type`.
     28     This class analyzes the fields of msg_type and creates
   (...)
     38 
     39     """
---> 40     def __init__(self, node: Node, msg_type: MsgType, topic: str) -> None:
     41         # Check if a ros2 node is provided.
     42         if (not isinstance(node, Node) or not issubclass(type(node), Node)):
     43             raise TypeError(
     44                 "Input argument 'node' is not of type rclpy.node.Node!")

NameError: name 'Node' is not defined
`

As my local ROS2 environment is clearly running. To make sure I even ran a ROS2 simple pub/subscript.