Bird
Raised Fist0
ROSframework~10 mins

Why ROS is the robotics standard - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize a ROS node named 'robot_controller'.

ROS
ros::init(argc, argv, [1]);
Drag options to blanks, or click blank then click option'
A"robot_controller"
Brobot_controller
C"controller_node"
Dcontroller_node
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the node name in quotes causes a compile error.
2fill in blank
medium

Complete the code to create a ROS publisher for topic 'chatter' with message type std_msgs::String.

ROS
ros::Publisher pub = nh.advertise<std_msgs::String>([1], 1000);
Drag options to blanks, or click blank then click option'
A"chatter"
Bstd_msgs/String
Cchatter
D"std_msgs/String"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the message type or unquoted topic name instead of a quoted string.
3fill in blank
hard

Fix the error in the ROS subscriber callback signature to accept a shared pointer to the message.

ROS
void chatterCallback(const std_msgs::String::ConstPtr& [1]) {
Drag options to blanks, or click blank then click option'
Acallback
Bmessage
Cdata
Dmsg
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that are not descriptive or conventional.
4fill in blank
hard

Fill both blanks to create a ROS service server named 'add_two_ints' with callback function 'add'.

ROS
ros::ServiceServer service = nh.advertiseService([1], [2]);
Drag options to blanks, or click blank then click option'
A"add_two_ints"
Badd
C"addInts"
Dadd_two_ints
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted service names or quoted callback names.
5fill in blank
hard

Fill all three blanks to create a ROS node that publishes 'Hello ROS' every second.

ROS
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<std_msgs::String>([1], 10);
ros::Rate loop_rate([2]);

while (ros::ok()) {
  std_msgs::String msg;
  msg.data = [3];
  pub.publish(msg);
  ros::spinOnce();
  loop_rate.sleep();
}
Drag options to blanks, or click blank then click option'
A"chatter"
B1
C"Hello ROS"
D"hello"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong topic names, incorrect loop rate, or missing quotes around strings.

Practice

(1/5)
1. Why is ROS considered the standard framework in robotics?
easy
A. Because it requires no programming knowledge
B. Because it is the only software that can control robots
C. Because it is developed by a single company
D. Because it allows easy connection of robot parts and code sharing

Solution

  1. Step 1: Understand ROS's main feature

    ROS connects different robot parts easily and allows sharing of code among developers.
  2. Step 2: Compare options

    Only Because it allows easy connection of robot parts and code sharing correctly describes this key feature; others are incorrect or misleading.
  3. Final Answer:

    Because it allows easy connection of robot parts and code sharing -> Option D
  4. Quick Check:

    ROS connects parts and shares code = A [OK]
Hint: Remember ROS connects parts and shares code easily [OK]
Common Mistakes:
  • Thinking ROS is the only robot software
  • Believing ROS is made by one company
  • Assuming no programming is needed
2. Which of the following is the correct way to start a ROS node in a launch file?
easy
A.
B.
C.
D.

Solution

  1. Step 1: Recall ROS launch file syntax

    The correct tag to start a node is <node> with attributes pkg, type, and name.
  2. Step 2: Identify correct option

    <node pkg="my_robot" type="controller" name="robot_controller" /> uses the correct <node> tag and attributes; others use invalid tags.
  3. Final Answer:

    <node pkg="my_robot" type="controller" name="robot_controller" /> -> Option A
  4. Quick Check:

    Use <node> tag to start nodes = B [OK]
Hint: Remember launch files use <node> tag to start nodes [OK]
Common Mistakes:
  • Using incorrect tags like <start> or <run>
  • Confusing launch file syntax with other XML formats
  • Omitting required attributes
3. Given the following ROS Python code snippet, what will be printed when the node runs?
import rospy
rospy.init_node('test_node')
rospy.loginfo('Node started')
medium
A. Node started
B. test_node
C. rospy.init_node called
D. No output

Solution

  1. Step 1: Understand rospy.loginfo behavior

    rospy.loginfo prints the message to the console when the node runs.
  2. Step 2: Identify printed message

    The message 'Node started' is passed to loginfo, so it will be printed.
  3. Final Answer:

    Node started -> Option A
  4. Quick Check:

    rospy.loginfo prints message = A [OK]
Hint: rospy.loginfo prints the given message to console [OK]
Common Mistakes:
  • Thinking init_node prints output
  • Confusing node name with printed message
  • Expecting no output without explicit print
4. Identify the error in this ROS Python node code:
import rospy
rospy.init_node('my_node')
rospy.spin()
print('Node running')
medium
A. print statement runs before spin
B. rospy.spin() blocks, so print never runs
C. init_node is missing parameters
D. Missing import for print function

Solution

  1. Step 1: Understand rospy.spin()

    rospy.spin() blocks the program to keep the node alive and waits for callbacks.
  2. Step 2: Analyze print statement position

    Since spin blocks, the print statement after it will never execute.
  3. Final Answer:

    rospy.spin() blocks, so print never runs -> Option B
  4. Quick Check:

    spin blocks execution after it = C [OK]
Hint: Remember spin() blocks; code after it won't run [OK]
Common Mistakes:
  • Assuming print runs before spin
  • Thinking init_node needs extra parameters
  • Confusing Python 2/3 print syntax
5. A robotics team wants to reuse existing ROS packages to build a new robot quickly. Which feature of ROS makes this possible?
hard
A. ROS does not allow sharing code between teams
B. ROS requires all code to be written from scratch
C. ROS's modular design with reusable nodes and packages
D. ROS only supports one robot model at a time

Solution

  1. Step 1: Understand ROS modularity

    ROS is designed with modular nodes and packages that can be reused across projects.
  2. Step 2: Evaluate options

    ROS's modular design with reusable nodes and packages correctly states this feature; others contradict ROS's collaborative nature.
  3. Final Answer:

    ROS's modular design with reusable nodes and packages -> Option C
  4. Quick Check:

    Modular reusable packages = D [OK]
Hint: ROS modularity enables fast reuse of code and tools [OK]
Common Mistakes:
  • Believing ROS forces writing all new code
  • Thinking ROS supports only one robot model
  • Assuming ROS prevents code sharing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard