Challenge - 5 Problems
ROS Parameter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat is the output of this ROS Python node when reading a parameter?
Consider this ROS Python node snippet that reads a parameter named
robot_speed from the parameter server. What will it print if the parameter is not set?ROS
import rospy rospy.init_node('speed_reader') speed = rospy.get_param('robot_speed', 1.0) print(f"Speed is {speed}")
Attempts:
2 left
💡 Hint
Check the default value provided to get_param.
✗ Incorrect
The get_param function returns the default value if the parameter is not found. Here, 1.0 is the default, so it prints 'Speed is 1.0'.
❓ state_output
intermediateWhat is the value of the parameter after this ROS C++ code runs?
Given this ROS C++ snippet that sets a parameter, what will be the value of
robot_mode on the parameter server after execution?ROS
#include <ros/ros.h> int main(int argc, char **argv) { ros::init(argc, argv, "param_setter"); ros::NodeHandle nh; nh.setParam("robot_mode", "AUTO"); nh.setParam("robot_mode", "MANUAL"); return 0; }
Attempts:
2 left
💡 Hint
The last setParam call overwrites the previous value.
✗ Incorrect
The parameter 'robot_mode' is first set to 'AUTO', then immediately overwritten to 'MANUAL'. The final value is 'MANUAL'.
📝 Syntax
advancedWhich option correctly retrieves a nested parameter from the ROS parameter server in Python?
You want to get the nested parameter
/robot/config/max_speed using rospy. Which code snippet correctly retrieves it?Attempts:
2 left
💡 Hint
Use the full absolute parameter name starting with a slash.
✗ Incorrect
The parameter server uses slash-separated paths. The correct absolute path is '/robot/config/max_speed'.
🔧 Debug
advancedWhat error will this ROS Python code raise?
This code tries to get a parameter without a default value. What error occurs if the parameter
robot_name is missing?ROS
import rospy rospy.init_node('name_reader') name = rospy.get_param('robot_name') print(name)
Attempts:
2 left
💡 Hint
Check rospy.get_param behavior when no default is given and parameter is missing.
✗ Incorrect
If the parameter is missing and no default is provided, rospy.get_param raises a KeyError.
🧠 Conceptual
expertHow many parameters are on the server after this sequence of ROS commands?
Assume the parameter server is empty initially. After running these commands in order, how many parameters exist on the server?
1. rosparam set /robot/speed 5
2. rosparam set /robot/mode AUTO
3. rosparam delete /robot/speed
4. rosparam set /robot/speed 10
Attempts:
2 left
💡 Hint
Deleting a parameter removes it, but setting it again adds it back.
✗ Incorrect
After step 1 and 2, two parameters exist. Step 3 deletes one, leaving one. Step 4 adds it back, so total is two.
