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

Brendan Andrade's profile - activity

2016-12-03 16:48:18 -0500 received badge  Great Question (source)
2014-04-03 16:39:26 -0500 commented question Why am I getting an rospy error in __getitem__ raise KeyError(key) ?

import roslib and roslib.load_manifest should not be used if you're using ROS Groovy or later and catkin. Not sure if the inclusion of those lines may be causing your issue.

2013-10-21 02:42:54 -0500 received badge  Good Question (source)
2013-08-23 04:25:31 -0500 received badge  Famous Question (source)
2013-07-12 10:37:35 -0500 commented question Image_view displays empty gray window

you can try running rostopic list which will give you a list of current topics. You may be able to tell which topic you want from the list. It might be /camera/image_raw.

2013-07-02 21:13:04 -0500 received badge  Notable Question (source)
2013-06-19 06:12:37 -0500 received badge  Popular Question (source)
2013-06-14 08:38:49 -0500 received badge  Scholar (source)
2013-06-14 06:20:34 -0500 commented question ImportError with custom action in python

Thank you, Dirk, for your help! Would you prefer to answer to the question below or should I save you the time and write the answer myself?

2013-06-14 06:19:16 -0500 commented question ImportError with custom action in python

My mistake, yes the the node file had the same name as the package. I'm sorry my question did not reflect that. Changing the name of the node solved the problem. Was python node names not matching package names a requirement added with groovy/catkin or was that required with rosbuild/fuerte too?

2013-06-13 09:28:16 -0500 commented question ImportError with custom action in python

No there isn't. When I get a free moment, I'm going to investigate what the python path is when the node runs. Files are generating correctly in devel but then aren't found when the node runs. Could be b/c the python package within the package folder structure has the same name as the ros package?

2013-06-13 04:58:33 -0500 commented question ImportError with custom action in python

Yes, I have.

2013-06-12 04:44:52 -0500 asked a question ImportError with custom action in python

Ubuntu 12.04, Groovy, catkin build

I am trying to define a custom action for a rospy node.

my_foo.py starts with:

#!/usr/bin/env python

import actionlib
import rospy
from geometry_msgs.msg import Twist
from my_foo.msg import *

When I run the node with rosrun, it yields the error:

Traceback (most recent call last):
  File "/home/johndoe/groovy-workspace/src/dcslROS/my_package/src/my_package/my_foo.py", line 16, in <module>
    import my_foo.msg
  File "/home/johndoe/groovy-workspace/src/dcslROS/my_package/src/my_package/my_foo.py", line 16, in <module>
    import my_foo.msg
ImportError: No module named msg

I have tried renaming the python package to not match the ROS package name and changing the setup.py file accordingly but that yielded the same error. The message build files are generated into devel/lib/python2.7/dist-packages/my_foo/msg but are not being found at run time.

My file structure is:

/my_foo
  package.xml
  CMakeLists.txt
  setup.py
  /action
    CustomAction.action
  /src
    my_node1.cpp
    /my_foo
      my_foo.py
      __init__.py

Setup.py:

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
    packages=['my_foo'],
    package_dir={'': 'src'}
)

setup(**d)

__init__.py is an empty file.

CustomAction.action contains:

# Determine whether to connect
bool connect # True = connect robot, False = Do nothing
---
# Determine if successfully connected
bool connected # True = Connected, False = Not connected
---
# Determine if robot is still connecting
bool in_progress # True = still connecting, False = finished

package.xml

<package>
  <name>my_foo</name>
  <version>0.1.0</version>
  <description>
    Description
  </description>
  <maintainer email="foo@aol.com">
    John Doe
  </maintainer>
  <license>BSD</license>

  <url type="website">http://ros.org/wiki/my_foo</url>
  <!-- <url type="bugtracker"></url> -->

  <author>John Doe</author>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>std_msgs</build_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>actionlib</build_depend>
  <build_depend>actionlib_msgs</build_depend>
  <build_depend>genmsg</build_depend>
  <!-- <build_depend>joy</build_depend> -->
  <!-- <build_depend>turtlebot_teleop</build_depend> -->
  <run_depend>std_msgs</run_depend>
  <run_depend>geometry_msgs</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>actionlib</run_depend>
  <run_depend>actionlib_msgs</run_depend>
  <run_depend>genmsg</run_depend>
  <run_depend>joy</run_depend>
  <run_depend>turtlebot_teleop</run_depend>
  <!-- <test_depend>std_msgs</test_depend> -->
  <!-- <test_depend>geometry_msgs</test_depend> -->
  <!-- <test_depend>rospy</test_depend> -->
  <!-- <test_depend>roscpp</test_depend> -->
  <!-- <test_depend>joy</test_depend> -->
  <!-- <test_depend>turtlebot_teleop</test_depend> -->

  <export>

  </export>
</package>

CMakeLists.txt

# http://ros.org/doc/groovy/api/catkin/html/user_guide/supposed.html
cmake_minimum_required(VERSION 2.8.3)
project(my_foo)

# Load catkin and all dependencies required for this package
set(CATKIN_DEPS std_msgs geometry_msgs rospy roscpp genmsg actionlib actionlib_msgs)
set(SYS_DEPS python-bluez python-sys)
find_package(catkin REQUIRED COMPONENTS ${CATKIN_DEPS})

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

# Add action files
add_action_files(
  DIRECTORY action
  FILES CustomAction.action
)

# Install python scripts using distutils
catkin_python_setup()


# Generate action messages
generate_messages(
  DEPENDENCIES actionlib_msgs
)

## DEPENDS: system dependencies of this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## INCLUDE_DIRS: 
## LIBRARIES: libraries you create in this project that dependent projects also ...
(more)
2013-06-05 10:44:38 -0500 received badge  Supporter (source)
2013-05-07 10:19:47 -0500 received badge  Famous Question (source)
2013-04-16 05:28:01 -0500 received badge  Notable Question (source)
2013-04-15 08:44:14 -0500 received badge  Popular Question (source)
2013-04-15 08:40:39 -0500 received badge  Nice Question (source)
2013-04-15 08:39:08 -0500 commented answer Best practices for setting up catkin_make install for python nodes

Would that be considered "best practice" for ROS packages with python nodes?

2013-04-15 07:31:50 -0500 commented answer Best practices for setting up catkin_make install for python nodes

I made this change and it returns the error:error: package directory 'scripts/my_pkg_A' does not exist. Should there be a folder /my_pkg_A/scripts/my_pkg_A? Is that where I should place my_node.py? Would this result in being able to use rosrun my_pkg_A my_node.py after sourcing the install setup?

2013-04-15 07:25:53 -0500 received badge  Student (source)
2013-04-15 07:19:57 -0500 received badge  Editor (source)
2013-04-15 07:19:06 -0500 asked a question Best practices for setting up catkin_make install for python nodes

I am currently updating my code from rosbuild to catkin as I switch from Fuerte to Groovy.

Current setup: Ubuntu 12.04, Groovy

I am looking for best practices for packages with python nodes and libraries.

This is my current file structure:

/groovy-workspace
    /build
    /devel
    /install
    /src
       /my_meta_pkg
           /my_pkg_A
           /my_pkg B
           /my_pkg_etc...

Under /my_pkg_A:

/scripts
    my_node.py
    my_API.py (my_node imports my_API)
    __init__.py
setup.py
__init__.py
package.xml
CMakeLists.txt

setup.py:

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
    packages=['my_pkg_A'],
    package_dir={'': 'src'}
)

setup(**d)

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(my_pkg_A)

# Load catkin and all dependencies required for this package
set(CATKIN_DEPS std_msgs geometry_msgs rospy)
set(SYS_DEPS python-serial python-sys)
find_package(catkin REQUIRED COMPONENTS ${CATKIN_DEPS})

# Install python scripts using distutils
catkin_python_setup()

catkin_package(
    DEPENDS ${SYS_DEPS}
    CATKIN_DEPENDS ${CATKIN_DEPS}
)

install(PROGRAMS scripts/my_node.py scripts/my_API.py
  DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}
)

When I run

catkin_make install

in /groovy-workspace, it fails during the make sequence with the error

error: package directory 'src/my_pkg_A' does not exist

I have deduced that it is looking for the python scripts in the python workspace

/groovy-workspace/src/my_meta_pkg/my_pkg_A/src/my_pkg_A

Would it be best practice to create this directory and move my_node.py, my_API.py, and __init__.py to this directory? Or should I change setup.py to look at /scripts and what would be the best way to do this? Or is there a different way everything should be structured to follow ROS best practices?

Thanks for the help!