Re: [ros-users] Error with Twist message when used with roso…

Top Page
Attachments:
Message as email
+ (text/plain)
+ genmsg_oct_tick.patch (text/x-patch)
Delete this message
Reply to this message
Author: Eric Perko
Date:  
To: ros-users
Subject: Re: [ros-users] Error with Twist message when used with rosoct
Thanks Brian and Alex. I modified the patch slightly to escape the
apostrophe instead of removing it per Alex's hint. This should work
better in the general case instead of only being correct for things
that needed their grammar fixed anyways :)

After applying my updated patch, I was able to regenerate the Twist
message and it works fine.

- Eric

On Fri, May 14, 2010 at 1:09 PM, Alexander Sorokin <> wrote:
> The way to escape an apostrophe in octave is with another apostrophe:
>
> x = [    '# This expresses velocity in free space broken into it''s linear
> and angular parts. \n'
>
> Alex
>
> On Fri, May 14, 2010 at 9:03 AM, Brian Gerkey <>
> wrote:
>>
>> hi Eric,
>>
>> Try the attached patch against genmsg_cpp (that's where the rosoct
>> code generator lives.  I tried escaping the apostrophe with a
>> backslash, but that doesn't appear to work.  So this patch just
>> removes apostrophes;  they should only appear in comments, so it
>> shouldn't make any difference (and in the case of the Twist message,
>> this approach happens to correct the grammar error that you point out
>> :).
>>
>> Let me know if the patch works (I'm not an Octave user).
>>
>>        brian.
>>
>> On Thu, May 13, 2010 at 11:52 PM, Eric Perko <>
>> wrote:
>> > Hey all,
>> >
>> > I'm trying to get some prototyping code working using the ROS
>> > interface (latest tag) for Octave, but I've encountered a problem with
>> > the Twist message. First, here is the specific error text when running
>> > the attached source:
>> >
>> > octave:1> publish_vel
>> > ans =  1
>> > parse error near line 32 of file
>> >
>> > /opt/ros/stacks/common_msgs/geometry_msgs/msg/oct/geometry_msgs/geometry_msgs_Twist.m
>> >
>> >  syntax error
>> >
>> >>>> x = [    '# This expresses velocity in free space broken into it's
>> >>>> linear and angular parts. \n' ...
>> >
>> >                   ^
>> >
>> > error: error creating function handle "@geometry_msgs_Twist"
>> > error: evaluating argument list element number 2
>> > error: evaluating assignment expression near line 5, column 9
>> > error: near line 5 of file `/home/eric/Downloads/publish_vel.m'
>> >
>> > I do have my .octaverc all setup properly.
>> >
>> > If I edit the Twist.m file and remove the apostrophe from it's, the
>> > attached code runs just fine. It seems that the apostrophes need to be
>> > escaped or replaced or something.
>> >
>> > Also, the grammar in that comment in Twist.msg is wrong - it's should
>> > be its anyways :)
>> >
>> > - Eric
>> >
>> > _______________________________________________
>> > ros-users mailing list
>> >
>> > https://code.ros.org/mailman/listinfo/ros-users
>> >
>> >
>>
>> _______________________________________________
>> ros-users mailing list
>>
>> https://code.ros.org/mailman/listinfo/ros-users
>>
>
>
> _______________________________________________
> ros-users mailing list
>
> https://code.ros.org/mailman/listinfo/ros-users
>
>

Index: genmsg_oct.cpp
===================================================================
--- genmsg_oct.cpp    (revision 9729)
+++ genmsg_oct.cpp    (working copy)
@@ -822,7 +822,7 @@
         for (; it != end; ++it) {
             std::string& line = *it;


-            // Escape bare \ and "
+            // Escape bare \, ',  and "
             size_t pos = line.find("\\");
             while (pos != std::string::npos) {
                 line.insert(pos, "\\");
@@ -835,6 +835,12 @@
                 pos = line.find("\"", pos + 2);
             }


+            pos = line.find("'");
+            while (pos != std::string::npos) {
+                line.insert(pos, "'");
+                pos = line.find("'", pos + 2);
+            }
+
             fprintf(f, "    '%s\\n' ...\n", line.c_str());
         }
         fprintf(f, "];\n\n");