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

Python 3 in ROS Indigo on Raspberry Pi

asked 2020-01-12 04:33:59 -0600

ravijoshi gravatar image

updated 2020-01-12 04:48:40 -0600

I apologize for posting this question as python3 is not entirely supported for ROS 1. I am using a python3 library (it uses int.from_bytes and int.to_bytes) in my project. I have successfully installed python3 on Raspberry Pi as well. I need to run ROS (Indigo) node on this board. I found brief instructions for python 3 in ROS Indigo here. Unfortunately, it didn't work quite well, or I missed some step.

The answer referred above says to create a virtual environment by using virtualenv -p /usr/bin/python3 and then under it run pip install rospkg. It didn't work. Please see terminal below-

(whill) pi@raspberrypi:~ $ ipython
Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import rospy                                                            
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-fb60b5b51009> in <module>
----> 1 import rospy

ModuleNotFoundError: No module named 'rospy'

Next, I followed the official Wiki page for installing ROS Indigo on the Raspberry Pi here. Please note that all these instructions were executed inside the python3 virtual environment.

From ROS Indigo, I need only publishers and subscribers of standard ROS messages. Therefore I decided to install ROS-Comm by using the following commands-

(whill) pi@raspberrypi:~/ros_catkin_ws $ /home/pi/whill/bin/rosinstall_generator ros_comm --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-ros_comm-wet.rosinstall
(whill) pi@raspberrypi:~/ros_catkin_ws $ /home/pi/whill/bin/wstool init src indigo-ros_comm-wet.rosinstall

I also installed libconsole-bridge-dev as stated in the Wiki page. The remaining dependencies were resolved by running rosdep-

(whill) pi@raspberrypi:~/ros_catkin_ws $ /home/pi/whill/bin/rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:buster

The above took a while to finish. Finally, the catkin workspace was build as shown below-

(whill) pi@raspberrypi:~/ros_catkin_ws $ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo -j2
Base path: /home/pi/ros_catkin_ws
Source space: /home/pi/ros_catkin_ws/src
Build space: /home/pi/ros_catkin_ws/build_isolated
Devel space: /home/pi/ros_catkin_ws/devel_isolated
Install space: /opt/ros/indigo
Additional CMake Arguments: -DCMAKE_BUILD_TYPE=Release
Additional make Arguments: -j2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~  traversing 48 packages in topological order:
~~  - catkin
~~  - genmsg
~~  - gencpp
~~  - genlisp
~~  - genpy
~~  - cmake_modules
~~  - cpp_common
~~  - message_generation
~~  - message_runtime
~~  - mk
~~  - ros
~~  - ros_comm
~~  - rosbash
~~  - rosboost_cfg
~~  - rosbuild
~~  - rosclean
~~  - roscpp_traits
~~  - roscreate
~~  - rosgraph
~~  - roslang
~~  - rosmake
~~  - rosmaster
~~  - rosmsg
~~  - rospack
~~  - roslib
~~  - rosparam
~~  - rospy
~~  - rosservice
~~  - rostime
~~  - roscpp_serialization
~~  - roslaunch
~~  - rosunit
~~  - rosconsole
~~  - roslz4
~~  - rosbag_storage
~~  - rostest
~~  - std_msgs
~~  - rosgraph_msgs
~~  - std_srvs
~~  - xmlrpcpp
~~  - roscpp
~~  - rosout
~~  - message_filters
~~  - rosnode
~~  - rostopic
~~  - roswtf
~~  - topic_tools
~~  - rosbag
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The packages or cmake arguments have changed, forcing cmake invocation

==> Processing catkin package: 'catkin'
==> Creating build directory: 'build_isolated/catkin'
==> cmake /home/pi/ros_catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/pi/ros_catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/opt/ros/indigo -DCMAKE_BUILD_TYPE=Release -G Unix Makefiles in '/home/pi/ros_catkin_ws/build_isolated/catkin'
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info ...
(more)
edit retag flag offensive close merge delete

Comments

I'm not saying it can't be solved, but as an observation: you're using an EOL version of ROS on an OS it was never released for, which uses versions of dependencies Indigo was never built with, trying to use a Python version Indigo was also not written for nor tested with.

My suggestion would be to take out some of these variation points, such as the Indigo requirement. Why do you need to use Indigo? Going to Melodic would make all of this much easier.

gvdhoorn gravatar image gvdhoorn  ( 2020-01-12 05:33:11 -0600 )edit

@gvdhoom: Thank you very much. I understand your concerns. The official Wiki page for installing ROS Indigo on the Raspberry Pi shows Raspbian Wheezy and Jessie OS version. I should use anyone from them. The next thing about the ROS version is that ROS Master is running on Indigo. Therefore I am sticking to Indigo. May I use other ROS in this situation? If yes, then I should choose ROS Kinetic since this is the latest one mentioned in the website.

ravijoshi gravatar image ravijoshi  ( 2020-01-12 07:20:01 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-01-12 05:34:50 -0600

gvdhoorn gravatar image

If you only need Python and standard messages, perhaps skipping the build entirely and using something like rospypi/simple may be a usable short-cut.

edit flag offensive delete link more

Comments

This looks really awesome. I should give it a try in a day or two. I will get back to you with the updates.

ravijoshi gravatar image ravijoshi  ( 2020-01-12 07:30:24 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2020-01-12 04:33:59 -0600

Seen: 568 times

Last updated: Jan 12 '20