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

Scaling data in a topic?

asked 2019-06-24 09:21:10 -0500

gerhmi gravatar image

updated 2019-06-24 09:25:27 -0500

Let's say I have a node (that I didn't write) publishing an Int32 value data between 0 and 1. Is it possible to scale data so it's between 0 and 10 instead of 0 and 1? Ideally, I'm wondering if this can be done in a launch file, though I'm not sure.

Something like:

<remap from="/data" to="/data" * 10 />

if you see what I mean

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-24 09:31:53 -0500

gvdhoorn gravatar image

updated 2019-06-24 09:35:40 -0500

Let's say I have a node (that I didn't write) publishing an Int32 value data between 0 and 1. Is it possible to scale data so it's between 0 and 10 instead of 0 and 1?

I'm going to assume you meant to write:

Let's say I have a node (that I didn't write) publishing an Int32 value data between 0 and 1. Is it possible to scale data so it's between 0 and 10 instead of 0 and 1?

As an Int32 can only encode integer values, so it would only ever be 0 or 1, nothing in between.


This is something that can be done using topic_tools/transform.

One of the examples on that page does something very similar:

convert an orientation quaternion to Euler angles:

rosrun topic_tools transform /imu/orientation /euler geometry_msgs/Vector3 'tf.transformations.euler_from_quaternion([m.x, m.y, m.z, m.w])' --import tf

So for your specific example, it would probably be something like (haven't tested this):

rosrun topic_tools transform /input /output std_msgs/Float32 'm.data * 10.0'

As to your question:

I'm wondering if this can be done in a launch file, though I'm not sure.

Something like:

<remap from="/data" to="/data" * 10 />

No, that is not possible. remaps don't work like that.

edit flag offensive delete link more

Comments

Thanks! I doubted it could be done as a remap, but you can always hope.

gerhmi gravatar image gerhmi  ( 2019-06-24 09:35:17 -0500 )edit

PS: note btw that using std_msgs msgs is not recommended, as they have almost zero semantics.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-24 09:36:11 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-24 09:21:10 -0500

Seen: 279 times

Last updated: Jun 24 '19