LESSON 02 · FOUNDATIONS

A small Linux and Python toolkit

Use a workspace and express physical quantities with explicit units.

Environment and verification

Documented target: Ubuntu 24.04 · ROS 2 Jazzy · Gazebo Harmonic where used. Browser labs tested; ROS/Ubuntu/hardware execution not performed here.

What you will understand

  • Navigate a dedicated directory.
  • Run a unit-aware Python calculation.
  • Read a C++ calculation.

Prerequisites: Meet the robot: sense, decide, act and its stated environment.

The idea, made clear.

Terminal commands act in a working directory. Relative paths resolve from there; absolute paths begin at the filesystem root. Keep exercises in your own directory, separate from system files. Inspect a path before writing or deleting files, and do not treat sudo as a universal fix for permission errors.

Python makes small calculations and ROS nodes approachable. C++ provides compiled binaries, explicit types and detailed resource control. Start with inputs, units and outputs rather than trying to master both languages immediately. Read error messages from the final line upward and fix the underlying cause.

Wheel angular speed in radians per second differs from revolutions per minute. Convert at boundaries and include units in variable names. A plausible number with the wrong units still describes the wrong command. Small numerical assertions catch mistakes before software reaches a motor.

Input + unitsCalculationAssertionOutput
An original overview of the information or commissioning sequence.

Try it, step by step.

1

Create a directory

These commands create your exercise folder.

linux-python-basics-1.txt
mkdir -p ~/nexviora_robotics
cd ~/nexviora_robotics
pwd

Expected: A path ending in nexviora_robotics.

2

Convert wheel speed

Save as wheel_speed.py and run python3 wheel_speed.py.

linux-python-basics-2.py
import math
radius_m = 0.05
rpm = 60.0
rad_s = rpm * 2 * math.pi / 60
print(f"rim speed: {radius_m * rad_s:.3f} m/s")

Expected: rim speed: 0.314 m/s

3

Compare C++

Save as speed.cpp; compile with g++ -std=c++17 speed.cpp -o speed, then run ./speed.

linux-python-basics-3.txt
#include <iostream>
int main() {
  const double radius_m = 0.05;
  const double speed_rad_s = 6.283185307;
  std::cout << radius_m * speed_rad_s << " m/s\n";
}

Expected: Approximately 0.314159 m/s.

Explore the interactive lab →

If something goes wrong

File not found
Check pwd, ls and filename spelling.
Permission denied
Use an account-owned folder before considering privileged commands.

Check your understanding

What unit describes angular velocity?

Make it yours

Assert that 120 RPM converts to approximately 4π rad/s.

Your learning progress

Optional progress stays in this browser. No account needed.

Go to the source documentation

Commands are educational examples for the stated environment, not a transcript of local ROS execution. Verify actual behavior on your machine.

Look up a term · Version notes · Report an issue