ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
508 stars 527 forks source link

rosserial_arduino with Nvidia jetson nano #505

Open asifbhatti11 opened 3 years ago

asifbhatti11 commented 3 years ago

Hello, I am using the Nvidia Jetson Nano board. which has Jetson Nano Developer Kit SD Card Image on it, which is based on Ubuntu 18.04. I am using ROS melodic on it. I have followed http://wiki.ros.org/rosserial_arduino... for rosserial installation. that was done successfully without any error. After launching the roscore I run this code: rosrun rosserial_python serial_node.py /dev/ttyACM0, as my Arduino is connected to ACM0 port. However, I get this error

Traceback (most recent call last): File "/home/asif/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 39, in <module> from rosserial_python import SerialClient, RosSerialServer File "/home/asif/catkin_ws/devel/lib/python2.7/dist-packages/rosserial_python/__init__.py", line 34, in <module> exec(__fh.read()) File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'SerialClient'

as per https://answers.ros.org/question/3535... suggests that: "The issue will be solved by adding a dot in front of SerialClient

from SerialClient import * from .SerialClient import * which is located at ~/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python After solving that I get another error:

Traceback (most recent call last): File "/home/asif/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 39, in <module> from rosserial_python import SerialClient, RosSerialServer File "/home/asif/catkin_ws/devel/lib/python2.7/dist-packages/rosserial_python/__init__.py", line 34, in <module> exec(__fh.read()) File "<string>", line 1, in <module> File "/home/asif/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 42, in <module> import StringIO ModuleNotFoundError: No module named 'StringIO' https://stackoverflow.com/questions/1... suggested to change as below: try: from StringIO import StringIO ## for Python 2 except ImportError: from io import StringIO ## for Python 3 after changing that I get another error:

Traceback (most recent call last): File "/home/asif/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 39, in <module> from rosserial_python import SerialClient, RosSerialServer File "/home/asif/catkin_ws/devel/lib/python2.7/dist-packages/rosserial_python/__init__.py", line 34, in <module> exec(__fh.read()) File "<string>", line 1, in <module> File "/home/asif/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 54, in <module> from Queue import Queue ModuleNotFoundError: No module named 'Queue' For this error I found 2 solutions from now thread https://stackoverflow.com/questions/3... :

(1)

Suggests the solution for that to change import queue as Queue. that gives error as below:

`Traceback (most recent call last): File "/home/asif/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 88, in client = SerialClient(port_name, baud, fix_pyserial_for_test=fix_pyserial_for_test) File "/home/asif/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 340, in init self.write_queue = Queue() TypeError: 'module' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/asif/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 100, in client.port.close() NameError: name 'client' is not defined`

(2)

suggests that Queue is in the multiprocessing module so:

from multiprocessing import Queue after applying this change I get this error.: Exception in thread Thread-6: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(self._args, *self._kwargs) File "/home/asif/catkin_ws/src/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 793, in processWriteQueue elif isinstance(data, basestring): NameError: name 'basestring' is not defined

asifbhatti11 commented 3 years ago

For now i can use rosserial in jetson nano using C++ version of rosserial_server as suggested in https://answers.ros.org/question/354667/rosserial-module-serialclient-not-found/ this helps to overcome python version mismatch problem.

After following this link,

Just run : rosrun rosserial_server serial_node instead of rosrun rosserial_python serial_node.py /dev/ttyACM0