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

mutantRobot's profile - activity

2018-12-19 02:46:01 -0500 received badge  Famous Question (source)
2018-03-06 02:58:55 -0500 received badge  Notable Question (source)
2017-09-01 02:28:21 -0500 received badge  Self-Learner (source)
2017-09-01 02:28:21 -0500 received badge  Teacher (source)
2017-08-30 11:33:45 -0500 received badge  Famous Question (source)
2017-08-30 00:04:54 -0500 marked best answer import python modules failed...what am I missing?

Hello guys,

I have a question about importing my own python modules from a package I wrote.

I am using ROS Indigo on Ubuntu 14.04.

According to

  1. setup.py manual
  2. install python

Assuming I have a package called mape_misc under catkin_ws/src,

the structure of it is :

src/mape_misc/
├── CMakeLists.txt
    ├── package.xml
    ├── setup.py
    └── src
        └── mape_misc
            ├── __init__.py
            ├── MAPEopcode.py

I wanted to import mape_misc.MAPEopcode in another python packages. Supposing there is a class OPCODE in MAPEopcode.py

However, in the other package, I got

from mape_misc.MAPEopcode import OPCODE
ImportError: No module named mape_misc.MAPEopcode

I'm stuck here right now, the content of my setup.py is :

#!/usr/bin/env python
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

setup_args = generate_distutils_setup(
    package=['mape_misc'],
    package_dir={'': 'src'},
)

setup(**setup_args)

In mape_misc, CMakeLists.txt is:

cmake_minimum_required(VERSION 2.8.3)
project(mape_misc)
find_package(catkin REQUIRED COMPONENTS
  rospy
)
catkin_python_setup()

catkin_package(
  CATKIN_DEPENDS rospy
)

I don't think I need to have a install() because I just want to use modules.

In MAPEopcode I just defined a Enum.

I've tried to clean the build and redo catkin_make, but still no luck.

Thanks for any advice!

Edit 1: I thought for any correct import, catkin_ws/src/mape_misc/src should be in PYTHONPATH. However, after I built everything and source devel/setup.bash, echo $PYTHONPATH showed only: /home/xbot/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/indigo/lib/python2.7/dist-packages:/home/xbot/.local/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-packages

2017-08-30 00:04:54 -0500 received badge  Scholar (source)
2017-08-30 00:04:38 -0500 edited answer import python modules failed...what am I missing?

OK I finally found the problem ------- a really stupid mistake in setup.py, which should contain: packages = ['xxxx']

2017-08-30 00:04:17 -0500 answered a question import python modules failed...what am I missing?

OK I finally found the problem ------- a really stupid mistake in setup.py, which should contain: packages = ['xxxx']

2017-08-29 02:10:05 -0500 edited question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about importing my own python modules f

2017-08-29 02:06:08 -0500 edited question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about importing my own python modules f

2017-08-28 06:57:49 -0500 received badge  Notable Question (source)
2017-08-28 06:57:44 -0500 commented answer import python modules failed...what am I missing?

I confirm the mape_misc was generated under catkin_ws/build

2017-08-28 06:44:49 -0500 commented answer import python modules failed...what am I missing?

Yes there is one under catkin_wx/src, CMakeLists.txt -> /opt/ros/indigo/share/catkin/cmake/toplevel.cmake.

2017-08-28 06:38:17 -0500 received badge  Popular Question (source)
2017-08-28 06:35:22 -0500 commented answer import python modules failed...what am I missing?

I'm a bit confused...there was a CmakeLists.txt in top level catkin_ws/src/mape_misc/ . Do you mean to create another on

2017-08-28 06:15:27 -0500 commented answer import python modules failed...what am I missing?

Thank you. In most time I left it empty but I tried your solution. However it still didn't work. I also noticed that in

2017-08-28 02:47:27 -0500 edited question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about importing my own python modules f

2017-08-28 02:23:01 -0500 edited question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about import my own python modules from

2017-08-28 02:22:13 -0500 edited question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about import my own python modules from

2017-08-28 02:20:51 -0500 edited question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about import my own python modules from

2017-08-28 02:18:30 -0500 asked a question import python modules failed...what am I missing?

import python modules failed...what am I missing? Hello guys, I have a question about import my own python modules from

2017-05-04 03:17:39 -0500 received badge  Enthusiast
2017-03-06 06:17:25 -0500 received badge  Popular Question (source)
2017-03-06 05:29:23 -0500 received badge  Student (source)
2017-03-06 02:09:08 -0500 received badge  Editor (source)
2017-03-06 01:59:32 -0500 asked a question How to call a service from outside ROS

Hello guys,

I was reading the docs and I learnt that ros service client may not be a ros node. Here, ( http://wiki.ros.org/ROS/Technical%20O... ), it said that ' in fact, a service client does not have to be a ROS node'.

I'm using python, and we all know ros service interaction is achieved via xmlrpc, so I'm thinking how code outdide ros can call a service implemented by a specific node. I built a simple example following the tutorial ( http://wiki.ros.org/rospy_tutorials/T... ) and both server & client worked well. However, when I tried in python 2.7.12 using python xmlrpclib ways to call the service (using service provider's url), I always got a '[Errno 111] Connection refused' error.

So does anyone know how to properly do such things? Any help will be appreciated.