Let’s practice a little bit more with Parameters.

Here are 2 quick activities:


1.

Do you remember one of the first nodes we created in the Topic section, with the robot news radio? This node publishes a string on a topic, similar to this “Hi, this is R2D2 from the Robot News Station!”.

Now, it would be better if we could set the robot’s name at run time, so we can launch the node multiple times with different robot names.

Add a “robot_name” parameter, and use the value to publish the string on the “robot_news” topic. Your string template (“Hi, this is <robot_name> from the Robot News Station!”) will now use the name you set at runtime.


2.

Go back to the “led_panel_node”. Here you have an int array representing the states of your Leds (0 for powered off, 1 for powered on). Set this array with a parameter named “led_states”.

Then, create a YAML file to store this parameter and load it at runtime, when you start the node.


-----


This will make you practice on string and array parameters. Of course you can apply those changes in both the Python and Cpp nodes.

I’ll see you in the next lecture for the solution (2 parts).