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

tfurf's profile - activity

2017-11-07 10:08:32 -0500 received badge  Great Answer (source)
2017-10-30 14:56:20 -0500 received badge  Necromancer (source)
2016-08-05 15:20:28 -0500 answered a question "get" /run_id param into an arg with roslaunch

I'm also trying the do the same thing. My currently, ugly, workaround is this:

test.launch just expects an argument:

<launch> <arg name="run_id"/> ... <param name="run_id" value="$(arg run_id)"/> </launch>

and from the command line, the gross part:

$ roscore & COREPID=$! ; sleep 1; roslaunch test.launch run_id:=$(roslaunch-logs | rev | cut -d/ -f1 | rev) ; kill $COREPID

You might also use the $(eval script) syntax, though it's only available in Kinetic. There should be a better 'official' way to do this, like value="$(run_id)".

2015-04-28 13:19:55 -0500 received badge  Good Answer (source)
2015-01-23 04:35:39 -0500 received badge  Enthusiast
2015-01-07 09:19:59 -0500 received badge  Famous Question (source)
2014-08-19 03:09:11 -0500 commented answer Exporting Python Module With Same Name as Package, with srv/msg

Thanks for the hint. This wasn't clear to me after reading http://wiki.ros.org/PyStyleGuide#Pack... .

2014-08-19 03:06:33 -0500 received badge  Supporter (source)
2014-08-19 03:06:30 -0500 received badge  Scholar (source)
2014-08-18 13:56:32 -0500 received badge  Notable Question (source)
2014-08-18 06:30:08 -0500 commented question Exporting Python Module With Same Name as Package, with srv/msg

See https://github.com/tfurf/rospy-srv-mo... for both working and non-working versions.

2014-08-18 03:42:50 -0500 commented question Exporting Python Module With Same Name as Package, with srv/msg

Do you invoke src/application.py as a script / node?

The src/application.py is called as a node, via roslaunch, with a simple .launch file.

2014-08-18 03:41:55 -0500 commented question Exporting Python Module With Same Name as Package, with srv/msg

What exact command are you invoking when you get the ImportError?

The exception is raised right at import-time, in use_my_service.py (part of the module). The specific line looks like from packagename.srv import MySrv.

2014-08-15 19:46:53 -0500 received badge  Popular Question (source)
2014-08-14 10:50:04 -0500 asked a question Exporting Python Module With Same Name as Package, with srv/msg

EDIT: MWE can be found here.

Per [1] and [2], I'm trying to export a python module that is the same name as the package:

packagename
 CMakeLists.txt
 package.xml               # catkin_python_setup()
 setup.py                  # generate_distutils_setup( ..., packages=['packagename'], ... )
 |- src/
    |- application.py         # import packagename
    |- packagename/
      |- __init__.py
      |- stuff.py
      |- ...

This works as expected, no problem. However, if I introduce a service message and try to import it:

packagename
 CMakeLists.txt
 package.xml
 setup.py
 |- srv/
    |- MySrv.srv
 |- src/
    |- application.py         # import packagename
    |- packagename/
      |- __init__.py
      |- stuff.py
      |- use_my_service.py  # from packagename.srv import MySrv
      |- ...

At runtime I get

ImportError: No module named srv

It works if I change the name of the exported module:

packagename
 CMakeLists.txt
 package.xml
 setup.py                  # generate_distutils_setup( ..., packages=['notpackagename'], ... )
 |- srv/
    |- MySrv.srv
 |- src/
    |- application.py         # import notpackagename
    |- notpackagename/
      |- __init__.py
      |- stuff.py
      |- use_my_service.py # from notpackagename.srv import MySrv
      |- ...

The path in both cases is exactly the same, including

$WORKSPACE_ROOT/devel/lib/python2.7/dist-packages

And in both cases I can locate the appropriate pacakgename/srv/_MySrv.py. In the working case, the output directory structure looks like:

devel/lib/python2.7/dist-packages/
|- notpackagename
  |- __init__.py     # Non-empty, dist-utils generated
|- packagename
  |- __init__.py     # Empty.
  |- srv/
    |- __init__.py 
    |- _MySrv.py

And in the non-working case:

devel/lib/python2.7/dist-packages/
|- packagename
  |- __init__.py     # Non-empty, dist-utils generated.
  |- srv/
    |- __init__.py 
    |- _MySrv.py

It appears that the generated __init__.py for the exported module clobbers the knowledge of the existence of submodules, but I'm not sure, I'm not particularly familiar with how catkin does it's magic for this.

Is my expectation for this to work misguided? If it's not supposed to/going to work, what is the preferred method? To prefix the module with lib, as in [3] ?

2013-07-25 04:46:43 -0500 received badge  Nice Answer (source)
2013-07-24 22:22:38 -0500 received badge  Teacher (source)
2013-07-24 22:22:38 -0500 received badge  Necromancer (source)
2013-07-24 22:08:14 -0500 commented question How to remap a topic to sub namespaces
2013-07-24 22:01:37 -0500 received badge  Editor (source)
2013-07-24 21:59:39 -0500 answered a question Can I access the absolute or parent namespace of a node from within a launch file?

A current hacked solution we came up with: Keep track of the global namespace by always passing down a <arg name="ns" ...> to every included launch file, and include a <arg name="ns" default=""/>. For example, with a simple two-subnode case, being called from an upper launch file.

The upper level launch:

<launch>
  <arg name="ns" default=""/>
  <remap from="$(arg ns)/node1/chatter" to="$(arg ns)/node2/chatter"/>
  <include file="talk_sub.launch" ns="node1">
    <arg name="ns" value="$(arg ns)/node1"/>
  </include>
  <include file="listen_sub.launch" ns="node2">
    <arg name="ns" value="$(arg ns)/node2"/>
  </include>
</launch>

And then in a lower level launch:

<launch>
  <arg name="ns" default=""/>
  <node name="talker" pkg="play" type="talker.py"/>
</launch>

In this way, you are always using the global-remap method, which always works, and you can reference the global namespace without actually knowing it a priori. This allows you to build up launch files with multi-level includes, and "cleanly" remap at the appropriate points. The best place to remap then is always at the lowest namespace where two topics are common, and no higher.

2013-07-24 06:42:35 -0500 commented answer Can I access the absolute or parent namespace of a node from within a launch file?
2013-07-24 06:29:31 -0500 commented question How to remap a topic to sub namespaces

I recently came across this same problem, I don't know the best fix, but just want to say I think the lack of functionality here (I would venture to say "bug") makes it really hard to scale larger projects without some kind of name collision.