On Wed, Nov 2, 2011 at 1:41 PM, Thibault Kruse wrote: > On 11/02/2011 08:29 PM, Ken Conley wrote: >> >> There is a question I have, which is whether or not arrays of >> messages should be populated with a default instance to make them >> easier to use (those are the hardest case, IMHO, to type). > > It could be useful, but indeed my code is inconsistent in that > it does this only for arrays at the root level. It is more of a bug > really, I did not think too much about it then. >> >>   This may >> or may not be related to your comment re: Quaternions and Headers. >> For Quaternion and Headers, I'll note that we learned the hard way >> that making the core libraries have specific knowledge of messages >> creates annoying future problems, no matter how well intentioned, so >> perhaps a plugin system is in order, as well as possible changes to >> the generated messages themselves. > > I think there is nothing wrong with the general idea of defining > defaults for ros message elements, following convention over > configuration. That would be the right fix for Quaternions IMO, > but I guess a lot of work. > > I believe the issue of giving initial array elements in the completion > is a separate issue that is only relevant for completion. An option > for the prototype command would do for that, traversing the > message and creating instances in empty arrays. > > A plugin system traversing the message and replacing values in > specific message types is thinkable, but I'd say not a priority. > > What's more important I think is to manage the order of elements > to match the .msg file definition. I think my code creates them in > arbitrary order, which I find a bit confusing. The Python message generator generates the __slot__ definitions in field message order, so the approach I described earlier with instantiating the actual message would be beneficial here. It would mainly mean changing the iterator from "for k in dir(obj)" to "for k in obj.__slots__" - Ken >> >> Some union of roslib.messages, rosmsgproto, and rosh bagys seems like >> a good strawman. > > Seems like a lot of work, good luck with it. > > If you want me to clean up the script given your input and create >  unit tests, I can do so. > > cheers, >  Thibault > _______________________________________________ > ros-users mailing list > ros-users@code.ros.org > https://code.ros.org/mailman/listinfo/ros-users >