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

Writing a Subscriber in Python

asked 2015-07-03 15:26:23 -0500

Sam gravatar image

updated 2015-07-06 21:32:28 -0500

Hello all,

I am trying to write a subscriber program in ROS fuerte with python and I get this error after I type "rosmake packagename" to build my package. I have "import rospy " in the python code but still I get some errors. The error I get is CMake cannot determine linker language for target(then it appears the name of python program)

I am following the ros tutorials and as far as my knowledge I have considered all steps necasary for writing a subscriber.

Can you please help me with my issue?

Here is the code for CMake.txt:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_executable(WhichFace src/WhichFace.py)

and here is the code for Manifest.xml

 <package>
  <description brief="finalPhone">finalPhone  </description>
  <author>pi</author>
  <license>BSD</license>
  <review status="unreviewed" notes=""/>
  <url>http://ros.org/wiki/finalPhone</url>
  <depend package="std_msgs"/>
  <depend package="rospy"/>
</package>

Thanks,

edit retag flag offensive close merge delete

Comments

2

what's the steps you did? The information is not enough to debug.

Po-Jen Lai gravatar image Po-Jen Lai  ( 2015-07-03 21:58:45 -0500 )edit
1

Please the contents of your CMakeLists.txt and package.xml. You are most likely treating a Python program as a C++ program (ie: trying to link it against other libraries). Python nodes do not need to be linked against anything.

gvdhoorn gravatar image gvdhoorn  ( 2015-07-04 02:21:52 -0500 )edit

Sure.This is manifest.xml <package> <description brief="finalPhone">

 finalPhone

</description> <author>pi</author> <license>BSD</license> <review status="unreviewed" notes=""/> <url>http://ros.org/wiki/finalPhone</url> <depend package="std_msgs"/> <depend package="rospy"/>

Sam gravatar image Sam  ( 2015-07-05 10:41:09 -0500 )edit

And this is my Cmakelist.txt:

cmake_minimum_required(VERSION 2.4.6) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) rosbuild_init() set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) rosbuild_add_executable(WhichFace src/WhichFace.py)

Sam gravatar image Sam  ( 2015-07-05 10:43:27 -0500 )edit
1

Can you add this (properly formatted) to your original question? Please use the edit button/link for that (to the right of Comments under your question), and use the Preformatted Text button to format the manifest and build script.

gvdhoorn gravatar image gvdhoorn  ( 2015-07-06 05:31:46 -0500 )edit

Sure.I did it.

Sam gravatar image Sam  ( 2015-07-06 14:08:22 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-07-07 01:52:16 -0500

gvdhoorn gravatar image

Here is the code for CMake.txt:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_executable(WhichFace src/WhichFace.py)

Python nodes are not 'executables' in the sense that you can rosmake them. You cannot rosbuild_add_executable(..) as that will cause CMake (underlying rosbuild) to try and setup all sorts of make targets for building and linking the Python script as if it were a C/C++ program. That is obviously not the case, so it fails.

See wiki/rospy_tutorials/Tutorials/Makefile (make sure to switch to rosbuild at the top of the page) for how to setup a CMakeLists.txt for Python nodes under rosbuild.

edit flag offensive delete link more
0

answered 2015-07-05 10:11:38 -0500

duck-development gravatar image

here you can find a step by step instruction how to setup ans "build" a Python subscriber

edit flag offensive delete link more

Comments

Thanks, Actually I followed a book called:"using ros for robotics programming" which is for furte version.

Sam gravatar image Sam  ( 2015-07-05 10:45:22 -0500 )edit

Try this book, it is very helpful in the beginning with ros. And it use indigo as ros distribution.

duck-development gravatar image duck-development  ( 2015-07-06 13:51:42 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-03 15:26:23 -0500

Seen: 685 times

Last updated: Jul 07 '15