# Revision history [back]

tl;dr: use the frame_id field in the header of the Range message to identify individual sensors.

If you're feeling fancy, you could then even use tf2 to transform incoming messages to figure out the exact range relative to some shared origin.

To "encode" the location of the range sensor, you'd set the frame_id field in the header field of the Range message.

Based on information from your URDF (or static transform publishers), you would then be able to transform incoming range information to the appropriate location (essentially: by interpreting it as coming from a specific sensor on your robot) and by doing so would know the relative distance between all sensors and some other link of your robot.

The first thing to do is to set the frame_id field in your loop() body for the two Range messages you publish(). See the IR Ranger Tutorial tutorial for an example.

With that done, you'd ideally use the tf2 library for the transformations, but seeing as you're running this on an Arduino, I'm not sure that is a good idea / available.

If you know the locations of your sensors relative to some shared origin (perhaps the base_link of your robot?), you could do the transform manually on the Arduino side. Alternatively, you could put the Range subscriber on the PC side, and command the motors from there. On the PC, TF is definitely available.