Read a topic from inside a launch or urdf file
Hi everyone,
I would like to read a value from a message in a topic (say the message is of type std_msgs/Bool) from inside a urdf or launch file so that I can, for example, turn on or turn off a sensor in runtime just writing true of false into that topic.
Just to contextualize: I want to toggle a sensor when pressing a button in a joystick. For that, I created a subscriber to read the button and a publisher for publishing into the topic /state the state of the sensor. If it was off, when I press the button it turns on and vice-versa. For that I created also a subscriber to read the current state in /state. All of this is already implemented and I can toggle the boolean value in the /state topic every time I press the button.
My question is how can I read the value from this topic, so that I can use it in a xacro urdf file? What I wanted to do is the same as we do with parameters and arguments in a xacro file, but with the ability to "change the parameter/argument value" in runtime (that's why I thought of reading from a topic, but I don't know if it is possible). I am using ROS Kinetic and Gazebo7.