This is a bit of a pet peeve, but I found
overly complicated for a new user.
The function returns an instance of a class that uses a list of other classes each of which takes several named arguments.
Another option is:
ld = LaunchDescription()
turtlebot3_node = Node(
While longer, it makes it much more clear what is happening and why… Especially for someone learning Python.
I completely agree with you. I don’t understand why the creators of ROS2 decided to make it so complicated!!!
Any way, that is how it is, and that piece of code is basic for ROS2 understanding. It is very basic. Let me write it here for better clarification:
Given your level of Python, you don’t need to understand how this code works, but just what is it doing and how to use it for your purposes.
What that code is doing
- Just launching a ROS2 program. As you know, every ROS2 program is identified by in which package is its code and which is its executable file.
How to use it
- Very easy. You only need to know which ROS2 program you want to launch. That is identified by its package and its executable. Then, just copy/paste that code and substitute the content of
executable=‘teleop_keyboard’with the proper package and executable names.
That is how you should proceed right now in order to advance in ROS2.
About the solution you propose, I don’t agree at all that is simpler, since you introduce a lot of new concepts and more complicated function. But if you think it is simpler for you, please keep using it. At the end, what matters is that we understand what we are doing in order to reach the goal.
I think it is a mater of learning styles. Some people like to cut and paste while other try break thing down into an understandable sequence of steps which they can use.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.