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

Msg gen error (stray '#' in program)

asked 2013-11-12 03:59:25 -0500

Alpha gravatar image

updated 2013-11-12 04:01:52 -0500

Hi there,

I'm building a program this message (Pose2DArray.msg):

Header header
geometry_msgs/Pose2D[] poses

But when I build it, with an empty main function, I get the following errors:

error: stray \ in program
error: stray # in program
error: stray \ in program
error: stray # in program
(more omitted)

This appears to be from the following, in Pose2DArray.h:

return "Header header \n\

\n\ geometry_msgs/Pose2D[] poses\n\
================================================================================\n\ MSG: std_msgs/Header\n\
# Standard metadata for higher-level stamped data types.\n\
# This is generally used to communicate timestamped data \n\
# in a particular coordinate frame.\n\
# \n\
# sequence ID: consecutively increasing ID \n\ uint32 seq\n\
#Two-integer timestamp that is expressed as:\n\
# * stamp.secs: seconds (stamp_secs) since epoch\n\
# * stamp.nsecs: nanoseconds since stamp_secs\n\
# time-handling sugar is provided by the client library\n\ time stamp\n\
#Frame this data is associated with\n\
# 0: no frame\n\
# 1: global frame\n\ string frame_id\n\ \n\
================================================================================\n\ MSG: geometry_msgs/Pose2D\n\
# This expresses a position and orientation on a 2D manifold.\n\ \n\ float64 x\n\ float64 y\n\ float64 theta\n\ ";   }

When I removed all that and replace it with

return "";

everything works. But since it is auto generated, the error re-appears later.

So I tried to remove the Header, so the msg was only

geometry_msgs/Pose2D[] poses

and everything works. Why can't I use Header here? Is this a bug or do I forget something?

edit: putting a comment in there ( # and some text) will also cause this

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-11-12 04:32:48 -0500

updated 2013-11-12 05:56:18 -0500

I would say that you found something of a bug. I generated your message file, and noticed that the return string generated in my Pose2DArray.h file had different line-wrapping than yours. Logically, I assumed that this was because of the different line-ending standards (\r\n vs \n). So then I went back to the Pose2DArray.msg file, and set emacs to save the file as a DOS file (with \r\n) line endings. Regenerating the header file produced a return string with line-wrapping similar to yours. Indeed, then #including this header file in a cpp file produced the same error you are getting.

So, I'm guessing converting the line endings of your msg file to only have \n will fix your problem. I'm not 100% sure, but it is certainly worth a try. If it does fix your problem, then a bug report should probably be filed

EDIT

For reference, I was using rosbuild and Fuerte for this test.

EDIT 2

I just tried this same test on Groovy using catkin, and was still met with this bug. Should probably file a bug report.

EDIT 3

I found this bug report in the gencpp package that mentions incorrectly formatted header strings when ending comment lines with symbols such as ")". I added info about this line-ending problem to that report.

edit flag offensive delete link more

Comments

Well it was indeed the line endings. I created the file with Notepad++ (my ROS environment is remote, I use windows to develop) which was on Windows line endings by default. Changing it to Unix/OSX format did the trick. Glad you already added to the bug report :)

Alpha gravatar image Alpha  ( 2013-11-12 20:22:59 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-12 03:59:25 -0500

Seen: 1,103 times

Last updated: Nov 12 '13