In 3.4 Static Broadcaster, it’s mentioned that static transforms can be published using command line, python/C++ script, or launch files. However, in example 3.3.2, why is it necessary to launch the launch file in terminal 3 (the one created in previous section) before running the python script in terminal 4?? In the previous section it is shown that the launch file itself can publish a static transform between ‘world’ and ‘odom’ already, which make running the python script a bit redundant. But it doesn’t work if just running the python script. Did I miss anything here?
Sorry, I do not have any answer. I was also confused a bit about static broadcasters.
First, I did not understand, why we need a node spinning which only broadcasts the static TF in the init phase of the node?
Why it is not enough to use spin_once?
About your question:
Maybe it “does not work” because the static TF broadcasted only once and if there is not other running node, “nobody” catches the TF and “nobody” will remember to it.
But it is totally foggy to me: Who will cache the broadcasted static TF if only the broadcaster node is living? What will happen when the broadcaster node is destroyed? What happens when RVIZ only started after the broadcaster node broadcasts the TF?
I think, that creating a node for static broadcasting is discouraged.
The documentation says:
This tutorial aimed to show how StaticTransformBroadcaster can be used to publish static transforms. In your real development process you shouldn’t have to write this code yourself and should use the dedicated tf2_ros tool to do so. tf2_ros provides an executable named static_transform_publisher that can be used either as a commandline tool or a node that you can add to your launchfiles.
Upon revisiting the course notes today with a fresh perspective, I’ve gained clarity on why launching the file before the script is necessary. The launch file establishes the world frame and publishes the static transform between world and odom. On the other hand, the script generates a static transform between chassis and my_front_turtle_frame, which relies on the existence of the world frame. Without the launch file, the script fails to establish the necessary foundation, leading to unexpected behavior.
In hindsight, I believe the course notes could benefit from an improved description to enhance the flow and overall understanding. The sudden introduction of my_front_turtle_frame without explicit explanation can be confusing, and a more coherent narrative would contribute to a smoother learning experience in the future.
Thank you for joining the discussion. Wish you a joyful Christmas and happy New Year!!!