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

Having a problem on Creating a ROS msg and srv in the tutorial

asked 2018-05-14 18:42:43 -0500

Fran0k gravatar image

updated 2018-05-15 10:23:07 -0500

HI ,Everyone ,I faced this problem when i was learning how to creating a ROS msg .

After I typedrosmsg show beginner_tutorials/Num

it shows

Traceback (most recent call last): File "/opt/ros/kinetic/bin/rosmsg", line 35, in <module> rosmsg.rosmsgmain() File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/", line 754, in rosmsgmain sys.exit(rosmsg_cmd_show(ext, full, command)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/", line 619, in rosmsg_cmd_show rosmsg_debug(rospack, mode, arg, options.raw) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/", line 450, in rosmsg_debug print(get_msg_text(type_, raw=raw, rospack=rospack)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/", line 426, in get_msg_text for p in rospack.list(): File "/usr/lib/python2.7/dist-packages/rospkg/", line 192, in list self._update_location_cache() File "/usr/lib/python2.7/dist-packages/rospkg/", line 184, in _update_location_cache list_by_path(self._manifest_name, path, cache) File "/usr/lib/python2.7/dist-packages/rospkg/", line 67, in list_by_path root = ElementTree(None, os.path.join(d, PACKAGE_FILE)) File "/usr/lib/python2.7/xml/etree/", line 611, in __init__ self.parse(file) File "<string>", line 38, in parse cElementTree.ParseError: XML or text declaration not at start of entity: line 6, column 0

instead of

int64 num

AND here is a part of my package.xml

<buildtool_depend>catkin</buildtool_depend> <build_depend>roscpp</build_depend> <build_depend>rospy</build_depend> <build_depend>std_msgs</build_depend> <build_export_depend>roscpp</build_export_depend> <build_export_depend>rospy</build_export_depend> <build_export_depend>std_msgs</build_export_depend> <exec_depend>roscpp</exec_depend> <exec_depend>rospy</exec_depend> <exec_depend>std_msgs</exec_depend> <build_depend>message_generation</build_depend> <run_depend>message_runtime</run_depend>

this is part of myCMakerList.txt

find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation )

add_message_files( FILES Num.msg )

add_service_files( FILES AddTwoInts.srv )

generate_messages( DEPENDENCIES std_msgs )

catkin_package( CATKIN_DEPENDS message_runtime )

and i found that my CMakerList.txttitle shows it was compiled as C++,but pyhton version is what I'm trying to do.Is it matter ?

cmake_minimum_required(VERSION 2.8.3) project(beginner_tutorials)

Compile as C++11, supported in ROS Kinetic and neweradd_compile_options(-std=c++11).## Find catkin macros and libraries.## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)is used, also find other catkin packages

Would you please give me some suggestions what should i do ti fix it,Thank

edit retag flag offensive close merge delete


Have you modified the package.xml and CmakeLists.txt files correctly ? (If you could edit your question to add them it would be helpful)

Delb gravatar image Delb  ( 2018-05-15 01:40:31 -0500 )edit

Hi Delb,Very appreciate for your comment. I failed to upload my file so i add parts of my package.xml and CmakeList.txt in this way.Thanks for your help

Fran0k gravatar image Fran0k  ( 2018-05-15 10:28:24 -0500 )edit

It might be that you are missing <exec_depend>message_runtime</exec_depend> in your package.xml (instead you have <run_depend>message_runtime</run_depend> ) Also have you run catkin_make before testing rosmsg show beginner_tutorials/Num ?

Delb gravatar image Delb  ( 2018-05-16 01:28:18 -0500 )edit

I had,but when i run rosmsg show beginner_tutorials/Num,it also shows TackBack messages ,I wonder if my python is missing some libraries.Besides I edited my package.xml by adding this<exec_depend>message_runtime</exec_depend> ,but nothing changed

Fran0k gravatar image Fran0k  ( 2018-05-16 02:59:38 -0500 )edit

Can you try to change catkin_package( CATKIN_DEPENDS message_runtime ) to catkin_package(CATKIN_DEPENDS roscpp rospy std_msgs message_runtime) ?

Delb gravatar image Delb  ( 2018-05-17 03:19:44 -0500 )edit

Hi Delb,I restarted the tutorial and it works finally.I doesn't know why it won't shown the TrackBack info somehow,instead of catkin_package() DEPENDS on the catkin package 'message runtime' which must therefore be listed as a run dependency in the package.xml.

Fran0k gravatar image Fran0k  ( 2018-05-19 08:58:21 -0500 )edit

I enter<exec_depend>message_runtime</exec_depend> in package.xml,then It runs successfully.Very thank for you help,Very appreciate it

Fran0k gravatar image Fran0k  ( 2018-05-19 09:03:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-03 03:20:36 -0500

jnhter gravatar image

Your catkin_package() is missing arguments:

catkin_package( CATKIN_DEPENDS message_runtime roscpp rospy std_msgs )

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-05-14 18:42:43 -0500

Seen: 959 times

Last updated: May 15 '18