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
rosmsg.rosmsgmain() File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/init.py", line 754, in rosmsgmain sys.exit(rosmsgcmdshow(ext, full, command)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/init.py", line 619, in rosmsgcmdshow rosmsgdebug(rospack, mode, arg, options.raw) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/init.py", line 450, in rosmsgdebug print(getmsgtext(type, raw=raw, rospack=rospack)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosmsg/init.py", line 426, in getmsgtext for p in rospack.list(): File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 192, in list self.updatelocationcache() File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 184, in updatelocationcache listbypath(self.manifestname, path, cache) File "/usr/lib/python2.7/dist-packages/rospkg/rospack.py", line 67, in listbypath root = ElementTree(None, os.path.join(d, PACKAGEFILE)) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 611, in init self.parse(file) File " ", 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
findpackage(catkin REQUIRED COMPONENTS roscpp rospy stdmsgs message_generation )
addmessagefiles( FILES Num.msg )
addservicefiles( FILES AddTwoInts.srv )
generatemessages( DEPENDENCIES stdmsgs )
catkinpackage( CATKINDEPENDS 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 ?
cmakeminimumrequired(VERSION 2.8.3) project(beginner_tutorials)
Compile as C++11, supported in ROS Kinetic and neweraddcompileoptions(-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
Asked by Fran0k on 2018-05-14 18:42:43 UTC
Answers
Your catkin_package() is missing arguments:
catkin_package( CATKIN_DEPENDS message_runtime roscpp rospy std_msgs )
Asked by jnhter on 2019-01-03 04:20:36 UTC
Comments
Have you modified the
package.xml
andCmakeLists.txt
files correctly ? (If you could edit your question to add them it would be helpful)Asked by Delb on 2018-05-15 01:40:31 UTC
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
Asked by Fran0k on 2018-05-15 10:28:24 UTC
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
?Asked by Delb on 2018-05-16 01:28:18 UTC
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 changedAsked by Fran0k on 2018-05-16 02:59:38 UTC
Can you try to change
catkin_package( CATKIN_DEPENDS message_runtime )
tocatkin_package(CATKIN_DEPENDS roscpp rospy std_msgs message_runtime)
?Asked by Delb on 2018-05-17 03:19:44 UTC
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
.Asked by Fran0k on 2018-05-19 08:58:21 UTC
I enter
<exec_depend>message_runtime</exec_depend>
inpackage.xml
,then It runs successfully.Very thank for you help,Very appreciate itAsked by Fran0k on 2018-05-19 09:03:10 UTC