Beginner Tier Exercises
This document consolidates all exercises from the Beginner tier lessons for easy reference and self-assessment.
From B1: Introduction to ROS 2
Exercise B1.1: Explore ROS 2 Commands (Easy)
Objective: Become familiar with the ROS 2 CLI while the talker/listener demo is running.
Setup:
- Open three terminals
- In Terminal 1:
ros2 run demo_nodes_cpp talker - In Terminal 2:
ros2 run demo_nodes_cpp listener - Use Terminal 3 for exploration
Tasks:
-
List all running nodes:
ros2 node listExpected: You should see
/talkerand/listener -
Get detailed information about the talker node:
ros2 node info /talkerQuestion: What topics does the talker publish to?
-
Find what topics the listener subscribes to:
ros2 node info /listenerQuestion: What is the message type used on
/chatter? -
Measure the publishing rate:
ros2 topic hz /chatterQuestion: How many messages per second is the talker publishing?
Acceptance Criteria:
- You can list all running nodes
- You can explain what the
/chattertopic is used for - You can identify the message type (
std_msgs/msg/String) - You know the default publishing rate (1 Hz)
Solution
ros2 node listshows/talkerand/listener- The talker publishes to
/chatter(and/rosout,/parameter_events) - The message type is
std_msgs/msg/String - The default rate is approximately 1 Hz (1 message per second)
Exercise B1.2: Change the Message Rate (Medium)
Objective: Learn how to modify node behavior through parameters.
Tasks:
-
Stop any running talker nodes (Ctrl+C)
-
Start the talker with a higher frequency:
ros2 run demo_nodes_cpp talker --ros-args -p frequency:=5.0 -
Observe the faster output in the talker terminal
-
Verify the new rate:
ros2 topic hz /chatter -
Try different frequencies: 0.5, 2.0, 10.0
Acceptance Criteria:
- Messages appear 5 times per second instead of once
-
ros2 topic hzconfirms approximately 5 Hz - You understand how
--ros-args -psets parameters
Solution
The -p frequency:=5.0 parameter tells the talker to publish at 5 Hz. You should see:
- Output like "Publishing: 'Hello World: X'" appearing 5 times per second
ros2 topic hz /chattershowing approximatelyaverage rate: 5.000
Note: Not all nodes support runtime parameter changes. The demo talker reads this parameter at startup.
Exercise B1.3: Create Your Own Publisher (Challenge)
Objective: Run a Python version of the talker and explore differences.
Tasks:
-
Run the Python talker instead:
ros2 run demo_nodes_py talker -
Compare with the C++ version—do they publish to the same topic?
-
Run both talkers simultaneously and observe what happens at the listener
Questions:
- Can multiple publishers share the same topic?
- What happens to the message count from each publisher?
Acceptance Criteria:
- Both C++ and Python talkers can run
- You understand that multiple publishers can share a topic
- The listener receives messages from both
From B2: Basic Sensors Overview
Exercise B2.1: Sensor Identification (Easy)
Objective: Match robot tasks to appropriate sensors.
Tasks: For each task below, identify which sensor would be most useful:
| Task | Your Answer |
|---|---|
| 1. Detect a door 2 meters ahead | |
| 2. Know if the robot is tilting backward | |
| 3. Pick up an egg without breaking it | |
| 4. Recognize a person's face | |
| 5. Navigate through a cluttered room | |
| 6. Detect when the robot is falling | |
| 7. Find the center of pressure under feet | |
| 8. Read text on a sign |
Acceptance Criteria:
- You can justify each sensor choice
- You understand the primary use case for each sensor type
Solution
- Door detection → LIDAR or Camera (LIDAR for distance, camera for recognition)
- Tilting detection → IMU (gyroscope measures angular velocity, accelerometer detects tilt)
- Egg grasping → Force sensor (precise grip force control)
- Face recognition → RGB Camera (visual processing)
- Room navigation → LIDAR (obstacle detection, SLAM)
- Fall detection → IMU (sudden acceleration changes)
- Center of pressure → Foot force sensors
- Reading text → RGB Camera (optical character recognition)
Exercise B2.2: Message Exploration (Medium)
Objective: Use ROS 2 CLI to explore sensor message structures.
Tasks:
-
View the IMU message definition:
ros2 interface show sensor_msgs/msg/ImuQuestion: What are the three main measurement fields?
-
View the LaserScan message definition:
ros2 interface show sensor_msgs/msg/LaserScanQuestion: What does the
rangesarray contain? -
Find the message type for 3D point clouds:
ros2 interface list | grep -i point -
Examine the Image message:
ros2 interface show sensor_msgs/msg/ImageQuestion: What field specifies the pixel format?
Acceptance Criteria:
- You can describe IMU message structure (orientation, angular_velocity, linear_acceleration)
- You understand LaserScan ranges (distance measurements in meters)
- You found
sensor_msgs/msg/PointCloud2 - You know Image encoding field specifies pixel format
Solution
- IMU fields:
orientation(quaternion),angular_velocity(rad/s),linear_acceleration(m/s²) - LaserScan ranges: Array of distance measurements in meters, one per angle increment
- Point cloud:
sensor_msgs/msg/PointCloud2 - Image encoding: The
encodingfield (e.g., "rgb8", "bgr8", "mono8", "16UC1")
Exercise B2.3: Sensor Data Interpretation (Challenge)
Objective: Interpret sensor readings and understand their meaning.
Scenario: A robot's IMU reports these values:
linear_acceleration:
x: 0.2
y: -0.1
z: 9.7
angular_velocity:
x: 0.01
y: 0.02
z: 0.0
Questions:
- Why is
zacceleration approximately 9.8 m/s²? - Is the robot rotating significantly? How do you know?
- What would
zacceleration show if the robot was in free fall? - If
yangular velocity increased to 1.0 rad/s, what motion would that indicate?
Acceptance Criteria:
- You understand gravity's effect on accelerometer readings
- You can interpret angular velocity values
- You know what free fall would look like in IMU data
Solution
-
Z ≈ 9.8 m/s²: This is gravity! Accelerometers measure all forces including gravity. A stationary robot shows ~9.8 m/s² in the direction opposite to gravity.
-
Rotation: Angular velocities are very small (0.01-0.02 rad/s ≈ 0.5-1°/s), so the robot is nearly stationary rotationally.
-
Free fall: All acceleration components would be approximately 0 (the robot is accelerating with gravity, so no force is felt).
-
Y = 1.0 rad/s: This is about 57°/s rotation around the Y axis, which typically means the robot is pitching (tilting forward/backward) rapidly.
Exercise B2.4: LIDAR Data Analysis (Challenge)
Objective: Process a simulated LIDAR scan.
Given Data:
# Simulated LaserScan data
angle_min = -1.57 # -90 degrees in radians
angle_max = 1.57 # +90 degrees in radians
angle_increment = 0.0175 # ~1 degree
range_min = 0.1
range_max = 10.0
ranges = [2.5, 2.4, 2.3, 2.2, 2.1, 2.0, 1.8, 1.5, 1.2, 1.0,
0.8, 0.7, 0.6, 0.5, 0.5, 0.5, 0.6, 0.7, 0.8, 1.0,
1.2, 1.5, 1.8, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6]
Tasks:
- How many readings are in this scan?
- What is the closest obstacle distance?
- At approximately what angle is the closest obstacle?
- What shape might this obstacle be? (Hint: look at the pattern)
Acceptance Criteria:
- Correct reading count
- Identified minimum distance
- Calculated approximate angle of closest point
- Made a reasonable guess about obstacle shape
Solution
-
Reading count: 30 readings
-
Closest distance: 0.5 meters (appears 3 times)
-
Angle calculation:
- Readings 13, 14, 15 show 0.5m
- Middle point (14) is at index 14
- Angle = angle_min + index × angle_increment
- Angle = -1.57 + 14 × 0.0175 = -1.325 rad ≈ -76° (to the right-front)
-
Obstacle shape: The pattern (decreasing from sides, minimum in middle, then increasing) suggests a curved or circular obstacle like a pillar or a person standing in front of the robot.
Self-Assessment Checklist
After completing all beginner exercises, verify you can:
ROS 2 Fundamentals
- Run the talker/listener demo
- Use
ros2 node listandros2 topic list - Echo messages from a topic
- Get information about nodes and topics
- Modify node parameters at launch
Sensor Understanding
- Explain what each sensor type measures (IMU, LIDAR, Camera, Force)
- Identify ROS 2 message types for each sensor
- Interpret basic sensor readings
- Match sensors to appropriate robot tasks
Ready for Intermediate?
If you checked all boxes above, you're ready to proceed to the Intermediate tier where you'll write your own ROS 2 Python nodes!
Next Steps
Continue to Intermediate Tier: Nodes, Topics, Services, and Actions