[ros-users] Filling in all fields of a ROS msg in C++, at once

Steven Bellens steven.bellens at mech.kuleuven.be
Sun Feb 13 14:38:51 UTC 2011


2011/2/12 Adam Leeper <aleeper at stanford.edu>:
> Hi Steven-
>
> I don't think there is. I wrote myself a helper file with a bunch of
> functions to populate and return a variety of message objects like that so I
> could do it in my main code in a single line.
> e.g.
>
>     std_msgs::ColorRGBA createColorMsg(double red, double blue, double
> green, double alpha)
>     {
>         std_msgs::ColorRGBA color;
>         color.r = red;
>
>         color.g = green;
>         color.b = blue;
>         color.a = alpha;
>         return color;
>     }
>
> It seems like a collection of functions like this would be very helpful in
> general, but I'm not sure where it should live. It seems the best solution
> would be if each message type included such a function with it, or better
> yet, a constructor that supported this, but that would imply some additional
> automation in the message generation script...To the ROS devs: How hard
> would it be to make the message generation step include an overloaded
> constructor for each message type that could take in values?

And on top of that maybe even operators to sum, multiply etc messages
of the same type...

Steven

>
> --Adam
>
>
> Adam Leeper
> Stanford University
> aleeper at stanford.edu
> 719.358.3804
>
>
> On Sat, Feb 12, 2011 at 2:29 PM, Steven Bellens
> <steven.bellens at mech.kuleuven.be> wrote:
>>
>> Hi,
>>
>> is there a way to declare a ROS msg in C++ and filling in all message
>> fields at once?
>> E.g. I want a message geometry_msgs/Pose:
>> const geometry_msgs::Pose world = {position.x = , ... } ?
>>
>> regards,
>>
>> Steven
>> _______________________________________________
>> ros-users mailing list
>> ros-users at code.ros.org
>> https://code.ros.org/mailman/listinfo/ros-users
>
>
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>



More information about the ros-users mailing list