Skip to content
Tutorials Center
My learning

Topics

Lesson 38 of 38 ยท Projects and Practice

Robotics Practice Problems with Solutions

Test yourself with robotics exercises: odometry, Jacobians, PID tuning, a complementary filter, planning questions and a review quiz, with runnable solutions.

The best way to learn robotics is to calculate, simulate, and break things. This lesson gives you worked problems on the topics of the whole course, each with a runnable solution that you can edit. Read the problem, try to predict the answer on paper, then run the code and compare. After the worked problems you will find a list of open challenges and a mixed review quiz.

How to practice

Predict first Estimate the answer before running.
Run and compare Find out where you were wrong.
Change something Edit a parameter and explain the effect.
Test edge cases Zero, huge, negative, unreachable.
1 / 2

Problem 1: Differential-drive odometry

A robot has two wheels, radius r = 0.05 m, separated by b = 0.30 m (the track width). Each wheel has an encoder giving its angular speed. The forward speed is v = r * (wR + wL) / 2 and the turn rate is omega = r * (wR - wL) / b. Integrate the pose (x, y, theta) over time.

Questions: (a) If both wheels spin at 10 rad/s for 4 s, where does the robot end up? (b) If the right wheel spins at 12 and the left at 8 rad/s, what is the radius of the circle it drives, and how long does one full circle take?

Python Problem 1: odometry solution

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that equal wheel speeds drive straight and the radius is (b / 2) * (wR + wL) / (wR - wL). If the wheel radii differ by just 1 percent, the robot will not drive straight: this is how odometry drift starts, and why you need the filters and SLAM from this chapter.

Problem 2: The Jacobian and singularities

For a two-link arm, the Jacobian J relates joint speeds to hand velocity: v_hand = J * q_dot. For L1 = 1, L2 = 0.8:

J = [[-L1 sin q1 - L2 sin(q1+q2), -L2 sin(q1+q2)], [L1 cos q1 + L2 cos(q1+q2), L2 cos(q1+q2)]]

Questions: (a) For q1 = 30ยฐ, q2 = 60ยฐ with both joints at 0.5 rad/s, what is the hand velocity? (b) When is the arm singular (the Jacobian determinant is zero, so it loses a direction of motion)? What happens to the joint speeds needed for a fixed hand velocity near that pose?

Python Problem 2: Jacobian solution

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The determinant equals L1 * L2 * sin(q2), so the arm is singular when q2 = 0 or 180 degrees (fully stretched or folded). Near those poses a tiny hand velocity in some direction needs huge joint speeds, which is why planners avoid singularities and controllers use damped inverses.

Problem 3: Tune a PID controller

A motor with inertia and friction is modeled as omega_dot = (-omega + 2 * u) / 0.5: a first-order system with gain 2 and time constant 0.5 s. A PID controller computes u = Kp e + Ki integral(e) + Kd de/dt to reach a speed setpoint of 10 rad/s.

Questions: Which gains give (a) a small steady-state error, (b) a fast response without too much overshoot? Compare three settings.

Python Problem 3: PID simulation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Read the table: pure P leaves a steady-state error (it must keep some error to produce output); adding I removes it but too much integral causes overshoot and oscillation; D damps the response but amplifies noise in real sensors. Tuning is always a compromise among speed, overshoot and robustness.

Problem 4: A complementary filter for tilt

An IMU gives a gyroscope (angular rate, smooth but drifting) and an accelerometer (gravity direction, noisy but drift-free). A complementary filter fuses them: angle = alpha * (angle + gyro * dt) + (1 - alpha) * accel_angle, with alpha near 0.98.

Question: The true tilt is a steady 20 degrees. The gyro has a bias of 0.5 deg/s and the accelerometer noise has a standard deviation of 3 degrees. How good is each sensor alone, and the fusion?

Python Problem 4: complementary filter

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The filter gets the best of both: the accelerometer anchors the long-term value, the gyro supplies smooth short-term changes. A Kalman filter does the same with optimal weights that adapt over time.

Open challenges (no solutions given)

Try these on your own, using the lessons as reference.

  1. Odometry with encoders. Convert encoder ticks (for example 1,440 ticks per revolution) into wheel distance and extend Problem 1 with unequal wheel radii. How far off after 100 m?
  2. A on a weighted grid.* Add terrain cost (mud, ice) to the delivery robot project and compare path lengths and costs.
  3. Three-link arm. Write IK numerically (Jacobian pseudo-inverse) and verify against FK. How many solutions can you find for one target?
  4. Particle filter without a map. Localize a robot only by odometry and a compass; watch the cloud spread, then add one landmark and see it collapse.
  5. Behavior tree for a cleaning robot with states for cleaning, avoiding obstacles, returning to the dock when the battery is low, and asking for help when stuck for 30 seconds.
  6. SLAM toy. Extend the pose-graph example with a second loop closure and a noisy one. What happens to the solution? How would a robust cost help?
  7. Safety design. For a 2 m/s robot with 0.3 s reaction time and 1 m/sยฒ deceleration, how large should the protective zone be? How does it change on a slope?
  8. Mini-ROS. Add a service ("set speed limit") to the mini-ROS example and a watchdog that stops the robot if /scan goes silent.

Review quiz

Quick check ยท 6 questions

of 6 answered You scored / 6 ยท perfect!

  1. 1. Two wheels at 10 rad/s each (radius 5 cm) for 4 s. How far does the robot travel?

    Speed = r * w = 0.05 * 10 = 0.5 m/s, and over 4 s that is 2 m.
  2. 2. A two-link arm is fully stretched (q2 = 0). What is true about its Jacobian?

    At full stretch the determinant L1 L2 sin(q2) is zero, so the hand cannot move radially.
  3. 3. A PID with pure P control leaves a constant error. Which term removes it?

    The integral term accumulates error over time, driving the steady-state error to zero (with a risk of overshoot).
  4. 4. Why does a complementary filter combine a gyro and an accelerometer?

    High-pass the gyro and low-pass the accelerometer to get a stable, smooth estimate.
  5. 5. Which planner would you choose for a 7-joint arm in a cluttered cell?

    Seven dimensions are far too large for a grid; sampling-based planners scale to high-dimensional C-space.
  6. 6. A sensor reading lies far outside the Kalman filter's predicted range. A robust tracker should...

    Outlier gating protects the estimate from wild measurements, with re-acquisition if rejections persist.

Summary

  • Odometry integrates wheel speeds; small asymmetries cause drift that filters and SLAM must correct.
  • The Jacobian maps joint speeds to hand speed; its determinant reveals singular poses.
  • PID tuning trades speed, overshoot and steady-state error; the integral term removes bias, the derivative damps.
  • A complementary filter fuses a drifting smooth sensor with a noisy absolute one.
  • Choose planners by dimension and uncertainty: grids and A* for 2D, sampling for arms, filters for state.

You have reached the end of the course. Review any chapter from the track page, or build your own robot project with the ideas in this tutorial.

Next: Back to the Robotics tutorial