[ros-users] sensor_msgs Low Cost/Android review

Brian Gerkey gerkey at osrfoundation.org
Tue Nov 13 23:46:29 UTC 2012

On Tue, Nov 13, 2012 at 2:55 PM, Edwards, Shaun M. <sedwards at swri.org> wrote:
> I understand why you would want messages to have semantic meaning, but I
> think the thin node wrapper method is problematic from a coding and
> usability standpoint.  From a coding standpoint, each wrapper node would be
> a near copy and paste.  This is almost universally bad coding practice.
> From a usability standpoint, it would require someone to code *something*
> anytime they wanted to take an average of a reading.  I had a recent
> application where I wanted to plot averages and current readings at the same
> time to determine options for reducing noise.  I’d hate to have to program a
> special node every time I wanted to perform the experiment.
> Perhaps there is a way (probably in python) to use some message
> introspection to achieve a generic node.  The node could simply look for
> int/real types and then perform the filtering automatically.  Perhaps a
> parameter list could be used to specify the message members (as strings)
> that should be filtered, intead.  Such an approach may also work with
> messages of multiple members (I’m thinking pose).   What do you think?

Attached is a simple rospy script that uses some of rostopic.  It can
subscribe to any topic that contains a field called 'data' that Python
can do arithmetic with, and can handle mixing types.  It'll do a naive
moving-window average on the received values and publish the result as
a std_msgs/Float64.

To try it, start some publishers:

rostopic pub -r 10 in1 std_msgs/Float64 1.0 &
rostopic pub -r 10 in2 std_msgs/Float32 2.0 &
rostopic pub -r 10 in3 std_msgs/Int64 42 &

Then start the averager:

python avg.py

That's just a quick and dirty demo; lots more can be done in that direction.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: avg.py
Type: application/octet-stream
Size: 1309 bytes
Desc: not available
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20121113/630ba6b9/attachment-0004.obj>

More information about the ros-users mailing list