Ask Your Question
0

rosserial module SerialClient not found

asked 2020-06-11 11:12:08 -0500

GUENNI gravatar image

updated 2020-06-18 07:00:55 -0500

Following rosserial_arduino tutorial http://wiki.ros.org/rosserial_arduino... I entered the command rosrun rosserial_python serial_node.py /dev/ttyACM0.

Following error occured:

Traceback (most recent call last):
  File "/home/guenther/catkin_ws/install/lib/rosserial_python/serial_node.py", line 39, in <module>
    from rosserial_python import SerialClient, RosSerialServer
  File "/home/guenther/catkin_ws/install/lib/python3/dist-packages/rosserial_python/__init__.py", line 1, in <module>
    from SerialClient import *
ModuleNotFoundError: No module named 'SerialClient'

I am using ROS noetic. The tutorial is also for noetic. Source of rosserial is of noetic-devel branch. This ist my ROS environment

ROS_VERSION=1
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/home/guenther/catkin_ws/install/lib/python3/dist-packages:/home/guenther/catkin_ws/install/share:/opt/ros/noetic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROS_MASTER_URI=http://localhost:11311
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_DISTRO=noetic

echo $PYTHONPATH
/home/guenther/catkin_ws/install/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages:/home/guenther/catkin_ws/devel/lib/python3/dist-packages

I found several questions about this issue, but nothing helped.

Added tries for further investigation:

/home/guenther/catkin_ws is a softlink to /KubuntuDaten/catkin_ws

$PYTHONPATH without sourcing
/home/guenther/catkin_ws/devel/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages

$PYTHONPATH sourced
/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages:/home/guenther/catkin_ws/install/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages:/KubuntuDaten/catkin_ws/devel/lib/python3/dist-packages:/home/guenther/catkin_ws/devel/lib/python3/dist-packages

sys.path in python3
['', '/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages', '/home/guenther/catkin_ws/install/lib/python3/dist-packages', '/opt/ros/noetic/lib/python3/dist-packages', '/KubuntuDaten/catkin_ws/devel/lib/python3/dist-packages', '/home/guenther/catkin_ws/devel/lib/python3/dist-packages', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/guenther/.platformio/penv/lib/python3.8/site-packages']

>>> from SerialClient import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'SerialClient'
>>>

Added rosserial_python to the PYTHONPATH gives:

Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print (sys.path)
['', '/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages/rosserial_python', '/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages', '/home/guenther/catkin_ws/install/lib/python3/dist-packages', '/opt/ros/noetic/lib/python3/dist-packages', '/KubuntuDaten/catkin_ws/devel/lib/python3/dist-packages', '/home/guenther/catkin_ws/devel/lib/python3/dist-packages', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/guenther/.platformio/penv/lib/python3.8/site-packages']
>>> from SerialClient import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages/rosserial_python/SerialClient.py", line 42, in <module>
    import StringIO
ModuleNotFoundError: No module named 'StringIO'

I replaced StringIO by io which leaded to the next missing module Queue. This shows that SerialClient looks for Python2 modules, which are not on the PYTHONPATH.

Adding /usr/lib/python2.7 to the PYTHONPATH leads to following error, when starting python3:


Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = '/usr/lib/python2.7:/KubuntuDaten/catkin_ws/install/lib/python3/dist-packages/rosserial_python:/KubuntuDaten ...
(more)
edit retag flag offensive close merge delete

Comments

Thank you for the editing. How can I see the sourcecode of the posting. So that I can write it next time better.

GUENNI gravatar image GUENNI  ( 2020-06-11 14:55:31 -0500 )edit

Just click the edit button/link below your question.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-12 02:32:52 -0500 )edit

Thanks a lot.

GUENNI gravatar image GUENNI  ( 2020-06-12 02:42:36 -0500 )edit

Further investigation of this issue shows me that there must be a problem with PYTHONPATH and the mix between python2 and python3. I have documented the steps I have taken. Is there a way to add the textfile with the documented steps?

GUENNI gravatar image GUENNI  ( 2020-06-18 06:42:03 -0500 )edit

No.

I suggest you copy-paste the contents and append it to your original question.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-18 06:47:10 -0500 )edit

gvdhoorn, I saw, you commented another question link text about mixing python2 and python3 nodes. This seems to me a similar situation as with my question. Only the main environment in noetic is python3.8 and the rosserial_python has to run under python2.7. Is there a defined way to handle this situation? Is it possible to contact the maintainer of the rosserial package?

In the meantime, I managed to solve the import issues, but then there rises other exceptions when starting the node.

GUENNI gravatar image GUENNI  ( 2020-06-19 15:15:06 -0500 )edit

Please see the rosserial issue tracker. Specifically ros-drivers/rosserial#499.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-19 15:29:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-29 04:51:45 -0500

GUENNI gravatar image

To find a solution for my issue, I decided to switch from the rosserial_python server version to the C++ version of rosserial_server. There I first ran in a new situation, that no connection between my arduino client and the server could be established. The reason was, that rosserial_server sends a hangup signal through the serial line every time it opens the interface, which continuously resets the arduino.The solution is to inhibit the hangup signal with stty -F /dev/ttyACM0 -hupcl. I added this command to <par> {catkin_ws}/src/rosserial/rosserial_server/src/serial_node.cpp



int main(int argc, char* argv[])
{
  ros::init(argc, argv, "rosserial_server_serial_node");

  std::string port;
  int baud;
  ros::param::param<std::string>("~port", port, "/dev/ttyACM0");
  ros::param::param<int>("~baud", baud, 57600);
  system ("stty -F /dev/ttyACM0 -hupcl"); // Added to inhibit hangup signal

  boost::asio::io_service io_service;
  rosserial_server::SerialSession serial_session(io_service, port, baud);
  io_service.run();
  return 0;
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-06-11 11:12:08 -0500

Seen: 74 times

Last updated: Jun 29