Having a problem on Creating a ROS msg and srv in the tutorial
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/__init__.py", line 754, in rosmsgmain sys.exit(rosmsg_cmd_show(ext, full, command)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/__init__.py", line 619, in rosmsg_cmd_show rosmsg_debug(rospack, mode, arg, options.raw) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/__init__.py", line 450, in rosmsg_debug print(get_msg_text(type_, raw=raw, rospack=rospack)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/__init__.py", line 426, in get_msg_text for p in rospack.list(): File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 192, in list self._update_location_cache() File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 184, in _update_location_cache list_by_path(self._manifest_name, path, cache) File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 67, in list_by_path root = ElementTree(None, os.path.join(d, PACKAGE_FILE)) File "/usr/lib/python2.7/xml/etree/ElementTree.py", 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.txt
title 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
Have you modified the
package.xml
andCmakeLists.txt
files correctly ? (If you could edit your question to add them it would be helpful)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
It might be that you are missing
<exec_depend>message_runtime</exec_depend>
in yourpackage.xml
(instead you have<run_depend>message_runtime</run_depend>
) Also have you runcatkin_make
before testingrosmsg show beginner_tutorials/Num
?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 mypackage.xml
by adding this<exec_depend>message_runtime</exec_depend>
,but nothing changedCan you try to change
catkin_package( CATKIN_DEPENDS message_runtime )
tocatkin_package(CATKIN_DEPENDS roscpp rospy std_msgs message_runtime)
?Hi Delb,I restarted the tutorial and it works finally.I doesn't know why it won't shown the
TrackBack info
somehow,instead ofcatkin_package() DEPENDS on the catkin package 'message runtime' which must therefore be listed as a run dependency in the package.xml
.I enter
<exec_depend>message_runtime</exec_depend>
inpackage.xml
,then It runs successfully.Very thank for you help,Very appreciate it