The ROS parameter server stores settings and data that nodes can share and use. It helps keep configuration in one place so many parts of a robot system can access it easily.
ROS parameter server
rosparam set /parameter_name value rosparam get /parameter_name rosparam delete /parameter_name rosparam list
Parameters are stored as key-value pairs on the parameter server.
Use '/' at the start of parameter names for global scope.
/robot_speed with the value 1.5.rosparam set /robot_speed 1.5
/robot_speed parameter.rosparam get /robot_speed
/robot_speed parameter from the server.rosparam delete /robot_speed
rosparam listThis Python ROS node sets a parameter called /greeting with a message. It then reads and prints it. After deleting the parameter, it tries to read it again and prints a default message because the parameter no longer exists.
#!/usr/bin/env python3 import rospy rospy.init_node('param_example_node') # Set a parameter rospy.set_param('/greeting', 'Hello, ROS!') # Get the parameter message = rospy.get_param('/greeting', 'Default message') print(message) # Delete the parameter rospy.delete_param('/greeting') # Try to get the deleted parameter with default message_after_delete = rospy.get_param('/greeting', 'Parameter not found') print(message_after_delete)
Parameters can be simple types like numbers, strings, lists, or dictionaries.
Use rosparam command line tool or API functions to interact with parameters.
Parameters are useful for tuning robot behavior without changing code.
The ROS parameter server stores shared settings for nodes.
Use rosparam commands or API to set, get, and delete parameters.
Parameters help keep robot configuration organized and accessible.
Practice
ROS parameter server?Solution
Step 1: Understand the role of the parameter server
The ROS parameter server is designed to hold parameters that nodes can access and share, such as configuration values.Step 2: Compare options with this role
Options A, B, and D describe other ROS functionalities unrelated to parameter storage.Final Answer:
To store and share configuration settings between ROS nodes -> Option BQuick Check:
Parameter server = shared settings [OK]
- Confusing parameter server with command execution
- Thinking it compiles code
- Mixing it up with visualization tools
robot_speed to 1.5 using rosparam?Solution
Step 1: Identify the command to set a parameter
Therosparam setcommand is used to assign a value to a parameter on the parameter server.Step 2: Verify the syntax
The syntax isrosparam set <param_name> <value>, sorosparam set robot_speed 1.5is correct.Final Answer:
rosparam set robot_speed 1.5 -> Option AQuick Check:
Set parameter = rosparam set [OK]
- Using 'get' instead of 'set' to assign values
- Trying to delete or list with value arguments
- Incorrect command syntax
max_speed is not set on the parameter server?
import rospy
rospy.init_node('speed_node')
max_speed = rospy.get_param('max_speed', 2.0)
print(max_speed)Solution
Step 1: Understand the use of rospy.get_param with default
The functionrospy.get_param('max_speed', 2.0)tries to get the parameter 'max_speed'. If it does not exist, it returns the default value 2.0.Step 2: Apply this to the scenario
Since 'max_speed' is not set, the default 2.0 will be assigned and printed.Final Answer:
It will print 2.0 -> Option CQuick Check:
Missing param returns default = 2.0 [OK]
- Expecting an error if parameter missing
- Assuming None is returned by default
- Confusing default value usage
KeyError. What is the problem?
import rospy
rospy.init_node('node')
value = rospy.get_param('unknown_param')
print(value)Solution
Step 1: Analyze the get_param call without default
Callingrospy.get_param('unknown_param')without a default raises aKeyErrorif the parameter does not exist.Step 2: Confirm the cause of the crash
Since 'unknown_param' is missing and no default is given, the code crashes withKeyError.Final Answer:
The parameter 'unknown_param' does not exist and no default was provided -> Option AQuick Check:
Missing param + no default = KeyError [OK]
- Assuming node init causes KeyError
- Thinking print syntax is wrong
- Ignoring parameter server status
config.yaml. Which command correctly loads all parameters from this file onto the ROS parameter server under the namespace /robot?Solution
Step 1: Identify the command to load parameters from a file
Therosparam loadcommand loads parameters from a YAML file onto the parameter server.Step 2: Confirm the correct syntax for namespace
Usingrosparam load config.yaml /robotloads all parameters under the/robotnamespace.Final Answer:
rosparam load config.yaml /robot -> Option DQuick Check:
Load YAML file with rosparam load [OK]
- Using 'set' instead of 'load' for files
- Trying to 'get' or 'delete' files
- Omitting namespace or using wrong syntax
Ready to prove it?
Pass the test and this pattern moves unknown
