By RWT Robotics Editorial Team Checked against 8 sources Published
You can program a robot in four ways: jog it and record points on a teach pendant, build the program offline in simulation, write code, or show it the task and let a learned policy copy you. Which one to start with depends on the robot you care about: factory arm, hobby rover, competition bot or AI research platform. This guide maps all four, gives you a runnable first step for each, and finishes with a beginner project you can build this month.
Key takeaways
- Most factory robots are still programmed by jogging and recording points, with offline simulation used more and more to cut downtime.
- For hobby and research robots, the usual path is microcontroller code first, then ROS 2 with Python, tested in simulation.
- Install ROS 2 Lyrical Luth on Ubuntu 26.04 if you are starting now: it is supported until May 2031.
- Teaching by demonstration with Hugging Face LeRobot can train an SO-101 arm from about 50 demos, but it needs honest real-world evaluation.
- Learn one vendor language properly. Frames, waypoints and I/O work the same way on every brand.
Fact-checked
We checked these key facts against the sources named, on November 23, 2026:
- The IFR forecasts 655,000 installations in 2026 and 806,000 in 2029 (source: ifr.org)
- The SO-100 and SO-101 are fully integrated in single-arm and bimanual setups (source: huggingface.co)
- FIRST Tech Challenge (grades 7 to 12) runs the 2026-2027 game BIOBUZZ presented by RTX, released September 12, 2026 (source: firstinspires.org)
- The FIRST Robotics Competition (high school) releases its 2027 game, BIOCORE presented by Haas, on January 9, 2027, with programming in Java, C++ or Python (source: firstinspires.org)
- According to the International Federation of Robotics’ World Robotics 2026 report, released September 24, 2026, 603,307 industrial robots were installed worldwide in 2025, up about 11% (source: ifr.org)
How to program a robot: the short answer
Programming a robot means telling a controller where to move, how to move there, and what to do with its sensors and I/O along the way. There are four ways to do it, and most real projects mix two or more:
- Teach pendant or hand-guiding (online programming). You move the real robot to each position and save it. This is the standard on industrial arms and cobots.
- Offline programming and simulation. You build the work cell in CAD, program the path on a PC, then download it to the robot.
- Writing code. C++ or MicroPython on a microcontroller, a vendor language such as ABB RAPID or URScript, or Python and C++ on ROS 2.
- Teaching by demonstration. You drive the robot through a task many times, train a neural network policy on those recordings, and let it run on its own.
If you want a factory job, start with methods 1 and 2. For hobby robots, start with method 3 on an Arduino. Researchers and AI learners should combine method 3 (ROS 2) with method 4.
Four ways to program a robot compared
| Method | Typical robots | Skill needed | Tools | Best for | Main limitation |
|---|---|---|---|---|---|
| Teach pendant / hand-guiding | FANUC, ABB, KUKA, Yaskawa arms; UR and other cobots | Low to medium | Pendant, PolyScope, free-drive button | Fixed, repetitive factory tasks | Robot is out of production while you teach |
| Offline programming (OLP) | Industrial arms in welding, painting, machining cells | Medium to high | RoboDK, ABB RobotStudio, FANUC ROBOGUIDE, Yaskawa MotoSim | Complex paths, many robots, no downtime | Needs calibration and touch-up on the real cell |
| Writing code | Hobby rovers, mobile robots, research arms, any robot with an SDK | Medium to high | Arduino IDE, ROS 2, vendor languages, Gazebo, Webots | Sensor-driven behaviour, autonomy, integration | Steeper learning curve, more to debug |
| Teaching by demonstration | SO-101, ALOHA-style arms, research humanoids | Medium (ML basics) | Hugging Face LeRobot, ACT, SmolVLA | Hard-to-describe manipulation tasks | Brittle outside the training conditions; hard to certify |
Pick your starting point by goal
| Goal | First platform | First language | First milestone | Next step |
|---|---|---|---|---|
| Factory job (integrator, technician) | URSim or a vendor simulator (RobotStudio, ROBOGUIDE) | URScript or RAPID, plus pendant skills | A pick-and-place cycle with gripper I/O | Vendor training course, then OLP with RoboDK |
| Hobby robots | Arduino Uno or ESP32 rover kit | Arduino C++ | Obstacle-avoiding robot | Raspberry Pi plus ROS 2 |
| Competition (teens) | FTC or FRC team robot | Java (FTC); Java, C++ or Python (FRC) | Autonomous period routine | Sensors, odometry, path following |
| Research / AI | ROS 2 Lyrical in Gazebo Jetty, then an SO-101 arm | Python | A ROS 2 node driving a simulated robot | LeRobot imitation learning |
What “programming a robot” actually means
At its core, every robot program runs a sense, think, act loop. Sensors report the world, logic decides what to do, and actuators (motors, grippers, valves) carry it out, hundreds or thousands of times per second.
The robot controller is the dedicated computer that closes that loop in real time. On an industrial arm it is a cabinet that runs the motion planner and servo drives, and your program is only the layer on top. On a hobby rover the “controller” might be a single Arduino. On a ROS 2 robot it is often a split: a microcontroller handles motors, while a Linux computer handles perception and planning. For a broader primer on how the hardware fits together, see our explainer on what robotics is and how robots actually work.
Positions only mean something relative to a coordinate frame. Industrial controllers expose four main frames:
- Joint frame: each axis rotates on its own (J1 to J6).
- World or base frame: X, Y, Z fixed to the robot’s base or the cell.
- Tool frame: axes fixed to the tool centre point (TCP), so “Z” means “along the gripper”.
- User frame (work object): axes fixed to a fixture or a pallet, so you can move the fixture and re-teach only the frame.
All of these follow the right-hand rule. Point your thumb along X and index finger along Y, and your middle finger shows Z. Curl your fingers around an axis to get the positive rotation direction.
Once you understand frames, a robot program turns out to be mostly three things: a list of positions, the motion type between them, and I/O logic (“close gripper, wait for the part sensor, then move”).
Joint vs Cartesian motion
Joint motion interpolates each axis from start angle to end angle. It is fast and avoids singularities, but the tool follows a curved path you do not control directly. Cartesian motion moves the TCP in a straight line (or arc) in space. The controller solves inverse kinematics continuously to do it, which is why linear moves can fail near singularities, where two axes line up and the arm cannot keep the path.
The practical rule: use joint moves for travel through free space and Cartesian moves when the tool is near the part.
Waypoints, motion types (joint, linear, circular) and speed/blending
Every major language has the same three motion types under different names:
| Motion | ABB RAPID | KUKA KRL | FANUC TP | URScript |
|---|---|---|---|---|
| Joint | MoveJ | PTP | J | movej |
| Linear | MoveL | LIN | L | movel |
| Circular | MoveC | CIRC | C | movec |
Blending (ABB “zone”, FANUC “CNT”, UR “blend radius”) lets the robot round the corner at a waypoint instead of stopping. Use a fine or zero blend where precision matters, such as the pick point. Use a large blend for pass-through points to save cycle time.
Method 1: Teach pendant and hand-guiding (online programming)
Online programming means teaching the real robot in its real cell. You jog the arm to each position with a handheld teach pendant, save the point, choose the motion type, and build the sequence step by step. It is still how most factory robots get their programs.
How common is it, exactly? You will see “85%” or “90% of robots are programmed by teach pendant” repeated across vendor blogs. The oldest traceable version is a 2016 Robotiq blog post citing the British Automation and Robot Association at over 90%. No newer survey with a hard figure exists. A January 2026 vendor article still describes online programming as the default in most factories but gives no percentage. Treat the number as an old industry estimate, not current data.
Jogging and recording points
Jogging moves the robot while you hold a deadman (enabling) switch and press axis keys or tilt a 3D joystick. A typical pick-and-place routine on the pendant looks like this:
- Select a slow jog speed and the frame you need (joint to get close, then tool or user frame for fine alignment).
- Jog to a safe home position and record it as a joint move.
- Jog above the pick location and record an approach point.
- Jog straight down to the pick point and record it as a linear move with a fine blend.
- Insert an output instruction to close the gripper and a short wait or an input check.
- Add a linear retreat, then approach, place, open and retreat at the drop location.
- Run the program step by step at reduced speed, then in continuous mode, and only then raise the speed.
Engineer's note
When jogging an industrial arm, always confirm which frame is active (joint, world, tool or user) before pressing a key. Most beginner crashes come from moving in the wrong frame, such as expecting “+Z” to lift the tool when the user frame is tilted.
Hand-guiding / lead-through on cobots
Collaborative robots let you skip most jogging. On a Universal Robots arm you hold the free-drive button and push the arm into position by hand. FANUC CRX, ABB GoFa and KUKA LBR iisy cobots offer similar lead-through modes. The robot’s joint torque sensing or force sensor compensates for gravity, so the arm feels weightless.
Hand-guiding is the fastest way for a beginner to get a working program. It is also less precise than jogging. Use it to rough in waypoints, then refine critical points with fine jog moves or typed coordinates.
When online programming is the wrong choice
Teaching on the pendant has two hard costs. First, the robot is not producing while you teach, which matters when a line stops for hours. Second, complex paths are painful: a weld seam with 200 points, or a deburring path that follows a curved casting, is slow and inconsistent to teach by hand. High-mix cells that change products every week hit both problems. That is where offline programming takes over.
Method 2: Offline programming and simulation
Offline programming (OLP) means writing and testing the robot program on a PC against a 3D model of the cell, then downloading it to the real controller. The robot keeps working while you program, and you catch collisions and reach problems before they cost anything.
The workflow is the same in every tool. Import CAD for the robot, fixtures, parts and tooling. Define the tool frame and user frames. Generate or teach the path, often by picking edges directly off the part CAD. Simulate reach, collisions, singularities and cycle time. Finally, a post-processor translates the path into the robot’s native language and you load it onto the controller.
Vendor vs brand-agnostic OLP tools
Each major manufacturer sells a simulator built around a virtual copy of its own controller. Brand-agnostic tools trade some of that accuracy for one interface across many brands.
| Brand | Language | Offline/sim tool | Notes |
|---|---|---|---|
| ABB | RAPID | RobotStudio | Runs a virtual controller with the same RAPID kernel as the real cabinet |
| KUKA | KRL (paired .src and .dat files) | KUKA.Sim | .src holds the logic and moves, .dat holds the point data |
| FANUC | TP (teach pendant language), KAREL | ROBOGUIDE | TP handles motion; KAREL is a Pascal-like language for logic and communication |
| Yaskawa (Motoman) | INFORM | MotoSim | INFORM jobs are written line by line on the pendant or offline |
| Universal Robots | URScript (under PolyScope) | URSim, free to download | Python-like syntax; the easiest language here for beginners |
| Stรคubli | VAL3 | Stรคubli Robotics Suite | Structured, object-oriented style |
| Comau | PDL2 | Comau’s own tools or RoboDK | Pascal-like syntax |
| Kawasaki | AS language | K-ROSET | Mixes motion and logic commands in one language |
| Multi-brand | Any of the above via post-processors | RoboDK | One environment for dozens of brands; Python API for scripting |
Vendor tools win when cycle-time accuracy and controller-exact behaviour matter. RoboDK wins in shops running mixed fleets, and for learners who want to practise several brands without several licences.
Why the simulated path still needs touch-up on the real robot
A simulation is only as accurate as the model behind it. Real robots have small kinematic errors, fixtures sit a few millimetres off the CAD, and tool frames are rarely measured perfectly. That sim-to-real gap is why OLP projects include calibration: teach three points on each real fixture to align the user frame, measure the real TCP, and then touch up the handful of critical points on the pendant.
Plan for that step. A path that clears a clamp by 2 mm in RobotStudio can hit it on the floor. Keeping the virtual cell in sync with the real one is the core idea behind digital twins in robotics, and it is what makes OLP pay off over the long run.
Method 3: Writing code
Writing code covers three quite different tiers: firmware on microcontrollers, industrial vendor languages, and ROS 2 software on Linux computers. This is the method most people mean when they search “coding for robotics”, and it is where hobby, competition and research robots live.
Microcontrollers: Arduino, ESP32, Raspberry Pi Pico
Microcontrollers run one program in a tight loop with direct access to pins, which makes them ideal for reading sensors and driving motors. Your main options:
| Board | Language | Why pick it |
|---|---|---|
| Arduino Uno | Arduino C++ | Biggest tutorial base, 5 V logic matches most hobby sensors |
| ESP32 | Arduino C++ or MicroPython | Built-in Wi-Fi and Bluetooth for phone or PC control |
| Raspberry Pi Pico | MicroPython or C/C++ | Cheap, Python-friendly, flexible programmable I/O |
| Raspberry Pi (full computer) | Python, C++, ROS 2 | Runs Linux, cameras and ROS 2; often paired with a microcontroller |
The Arduino sketch in the project section below is a complete sense, think, act loop in about 40 lines.
Industrial vendor languages
Vendor languages look old-fashioned, but they are simple: mostly motion commands, I/O and basic logic. Here is a short URScript program for a pick on a Universal Robots arm:
def pick_part():
home = [0, -1.57, 1.57, -1.57, -1.57, 0] # joint angles, radians
above = p[0.40, -0.20, 0.30, 0, 3.14, 0] # x, y, z in metres + rotation vector, base frame
grasp = p[0.40, -0.20, 0.15, 0, 3.14, 0]
movej(home, a=1.4, v=1.05) # joint move through free space
movel(above, a=1.2, v=0.25) # linear approach
movel(grasp, a=0.5, v=0.05) # slow final move
set_digital_out(0, True) # close gripper
sleep(0.5)
movel(above, a=1.2, v=0.25) # retreat straight up
end
The same routine in ABB RAPID uses MoveJ and MoveL with robtarget points, a speed data value such as v100, and a zone such as fine. KUKA KRL uses PTP and LIN. Once you can read one, the others take days, not months.
Learn one vendor language well
Pick URScript or RAPID and learn it properly rather than skimming all of them. Both have free simulators (URSim and RobotStudio’s trial), and the concepts (frames, waypoints, blending, I/O) carry over to FANUC, KUKA and Yaskawa.
The question “how do I learn FANUC, ABB or KUKA programming without access to a robot?” has a clear answer: their simulators. RobotStudio and URSim give you a virtual controller that behaves like the real one, and ROBOGUIDE does the same for FANUC through the vendor. Vendor training centres and community college programmes then add real pendant hours.
ROS 2 Lyrical Luth: nodes, topics, services, actions
ROS 2 is the open-source software framework most research and mobile robots are built on. It is maintained by Open Robotics (the Open Source Robotics Foundation, OSRF), and it splits a robot into small programs that talk to each other. For the bigger picture, see our piece on what ROS 2 is and why more robots are moving to it.
The core concepts:
- Nodes: individual processes, for example a camera driver, a planner or a motor controller.
- Topics: named streams of messages, one-to-many, such as
/scanor/cmd_vel. - Services: request and response calls for quick jobs (“reset odometry”).
- Actions: long-running goals with feedback and cancel (“navigate to the dock”).
- Launch files: Python, XML or YAML files that start many nodes with their parameters at once.
Underneath, ROS 2 uses DDS middleware for communication. Fast DDS remains the default in Lyrical, as Open Robotics and eProsima noted when it marked 11 years of Fast DDS as the default.
Which distro? ROS 2 Lyrical Luth, the twelfth ROS 2 release, reached general availability on May 22, 2026. It is a long-term support (LTS) release supported until May 2031, with Ubuntu 26.04 (Resolute) as the Tier 1 platform on amd64 and arm64. Its first patch release on June 23, 2026 added 93 new packages and 70 updates, so the ecosystem is filling in quickly. ROS 2 Jazzy Jalisco (Ubuntu 24.04) is still supported until May 2029 and remains a sensible choice if a course or robot vendor requires it.
Tutorials “break between versions” for a simple reason. Each distro is a frozen set of package versions, and APIs, message types and package names change between them. A tutorial written for Humble may use a Gazebo package or launch syntax that no longer exists in Lyrical. Match your tutorial’s distro to your install, or pick tutorials from the official docs for your distro.
| Software | Current release | Released | Support until | OS / pairing |
|---|---|---|---|---|
| ROS 2 Lyrical Luth (LTS) | 12th ROS 2 release | May 22, 2026 | May 2031 | Ubuntu 26.04 |
| ROS 2 Jazzy Jalisco (LTS) | Previous LTS | May 2024 | May 2029 | Ubuntu 24.04 |
| Gazebo Jetty (LTS) | 10th major Gazebo release | Sep 30, 2025 | May 2031 | Pairs with Lyrical |
| Gazebo Harmonic (LTS) | Previous LTS | Sep 2023 | May 2029 | Pairs with Jazzy |
| Gazebo Ionic | Non-LTS | Sep 2024 | Dec 2026 | Ending, avoid for new work |
After adding the ROS 2 apt source as described on the official Lyrical install page, a first session looks like this:
sudo apt update
sudo apt install ros-lyrical-desktop
source /opt/ros/lyrical/setup.bash ros2 run turtlesim turtlesim_node
# Terminal 2: drive it with the keyboard
ros2 run turtlesim turtle_teleop_key
# Terminal 3: inspect what is happening
ros2 topic list
ros2 topic echo /turtle1/cmd_vel
And a minimal Python node (rclpy) that publishes a message twice per second:
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class Talker(Node):
def __init__(self):
super().__init__('talker')
self.pub = self.create_publisher(String, 'chatter', 10)
self.count = 0
self.create_timer(0.5, self.tick)
def tick(self):
msg = String()
msg.data = f'hello robot {self.count}'
self.pub.publish(msg)
self.count += 1
def main():
rclpy.init()
rclpy.spin(Talker())
rclpy.shutdown()
if __name__ == '__main__':
main()
Engineer's note
Starting ROS 2 today? Install Lyrical on Ubuntu 26.04. It is LTS until May 2031, so the tutorials you follow and the packages you depend on will stay valid for years.
Simulating first with Gazebo Jetty or Webots
Simulation lets you write and debug robot code before you own a robot. Gazebo Jetty is the LTS simulator paired with ROS 2 Lyrical, and the ros_gz packages bridge Gazebo topics to ROS 2 topics. Webots, the open-source simulator from Cyberbotics, is easier to install, ships with many ready-made robot models and is popular in teaching.
One change to plan for: Open Robotics announced that from 2027, Gazebo and ROS 2 will share release letters, so matching a simulator to a distro will be obvious from the name.
Is simulation good enough to learn on? For software concepts, yes: ROS 2, navigation, kinematics and logic all transfer. It is not good enough for motor tuning, sensor noise, wiring faults and battery sag, which you only learn on hardware. A cheap rover covers that gap. If you want structured practice environments, a ROS lab setup that combines a simulator with a small physical robot is a good option.
Method 4: Teaching by demonstration (robot learning)
Teaching by demonstration replaces hand-written motion code with a neural network that copies examples. You drive the robot through a task, record camera images and joint positions, train a policy on the recordings, and then let the policy control the robot from live camera input. Hugging Face LeRobot has made this practical on hobby budgets, and the LeRobot paper is listed as an ICLR 2026 publication.
The LeRobot workflow
LeRobot’s basic workflow on an SO-101 arm is record about 50 demonstrations, train a policy, then run it. The SO-100 and SO-101 are fully integrated in single-arm and bimanual setups. A leader arm that you move by hand teleoperates a follower arm that does the work.
- Record.
lerobot-recordsaves episodes (camera frames plus joint states) as a dataset. - Train.
lerobot-trainfits a policy, typically ACT (Action Chunking with Transformers) or SmolVLA. - Roll out.
lerobot-rolloutruns the trained policy on the real robot in the newer docs.
# 1. Record demonstrations with a leader arm (ports and IDs are yours)
lerobot-record \
--robot.type=so101_follower --robot.port=/dev/ttyACM0 --robot.id=follower \
--teleop.type=so101_leader --teleop.port=/dev/ttyACM1 --teleop.id=leader \
--robot.cameras="{ front: {type: opencv, index_or_path: 0, width: 640, height: 480, fps: 30}}" \
--dataset.repo_id=${HF_USER}/pick_cube \
--dataset.num_episodes=50 \
--dataset.single_task="Pick up the red cube and place it in the box"
# 2. Train an ACT policy
lerobot-train \
--dataset.repo_id=${HF_USER}/pick_cube \
--policy.type=act \
--output_dir=outputs/train/act_pick_cube \
--policy.device=cuda
# 3. Run it on the real arm
lerobot-rollout \
--strategy.type=base \
--robot.type=so101_follower --robot.port=/dev/ttyACM0 \
--policy.path=outputs/train/act_pick_cube/checkpoints/last/pretrained_model
LeRobot changes quickly, and flag names shift between releases. Older guides evaluate policies with lerobot-record plus --policy.path, so check --help for your installed version.
Did you know?
According to Hugging Face’s LeRobot documentation, a low-cost SO-101 arm can learn a task from about 50 recorded demonstrations instead of hand-written motion code.
ACT vs SmolVLA
ACT is a compact policy trained from scratch on your demos. It is fast to train and strong on a single, well-defined task. SmolVLA is Hugging Face’s small vision-language-action model (about 450 million parameters). It starts from a pretrained backbone and takes a text instruction, so it is better suited to fine-tuning across varied tasks. Pick ACT for your first project. Move to SmolVLA when you want language-conditioned behaviour.
What VLAs can and can’t do today
The most common complaint on LeRobot forums is “my training loss looks fine but the arm fails every time”. People report good loss curves with 0% real-world success. The usual causes:
- Camera drift: the camera moved, or the lighting changed, between recording and rollout.
- Inconsistent demos: you solved the task several different ways, so the policy averages them into a motion that solves none.
- Too little variation: every demo had the cube in one spot, so any other position is unseen.
- Calibration mismatch: the arm was recalibrated after recording, so joint values no longer mean the same thing.
- Overfitting: the final checkpoint memorised the data. Try an earlier checkpoint.
Reality check
Learned policies have not yet replaced classic programming for production work. They cannot guarantee cycle times, repeatability or certified safety, and they degrade outside their training conditions.
Judge the rollout, not the loss
In LeRobot, measure a policy by its real rollout success rate over 10 or 20 trials, not by training loss. Keep the camera mount, lighting and object set fixed between recording and testing.
Where this method does win is in tasks that are easy to show and hard to describe: folding cloth, sorting mixed objects, handling deformable parts. Our explainer on how an AI robot works covers the wider model landscape.
Your first robot program: a step-by-step project
The best first project is an obstacle-avoiding rover. It teaches the full sense, think, act loop with one sensor and two motors, and the same logic ports directly to ROS 2 later.
Parts: an Arduino Uno (or ESP32), a two-wheel-drive chassis with two DC gear motors, an L298N or TB6612FNG motor driver, an HC-SR04 ultrasonic sensor, a battery pack for the motors, and jumper wires.
Quick steps: obstacle-avoiding robot
- Assemble the chassis, motors and caster.
- Wire motors to the driver, driver to Arduino.
- Wire the HC-SR04 to 5 V, GND and two pins.
- Upload the sketch and check serial readings.
- Test motor direction with wheels off the ground.
- Tune stop distance and turn time.
Steps 1 to 6: the hardware build
- Build the chassis. Mount the motors and caster, and keep the sensor at the front, level with the floor.
- Wire the motor driver. Connect each motor to the driver’s outputs. Connect ENA/ENB to PWM pins 5 and 6, IN1 to IN4 to pins 7, 8, 11 and 12. Power the driver from the battery pack and tie its ground to the Arduino ground.
- Wire the sensor. VCC to 5 V, GND to GND, TRIG to pin 9, ECHO to pin 10. On a 3.3 V board such as the ESP32, divide the ECHO signal down.
- Upload the sketch and open the serial monitor to confirm sensible distance readings.
- Test motors with the wheels lifted. If a wheel spins backwards, swap that motor’s two wires.
- Tune. Adjust the 20 cm threshold, the speeds and the 300 ms turn until the robot avoids walls without stalling.
// Obstacle avoider: HC-SR04 + L298N on Arduino Uno
const int TRIG = 9, ECHO = 10;
const int ENA = 5, IN1 = 7, IN2 = 8; // left motor
const int ENB = 6, IN3 = 11, IN4 = 12; // right motor
long readDistanceCm() {
digitalWrite(TRIG, LOW); delayMicroseconds(2);
digitalWrite(TRIG, HIGH); delayMicroseconds(10);
digitalWrite(TRIG, LOW);
long us = pulseIn(ECHO, HIGH, 30000); // 30 ms timeout
if (us == 0) return 999; // no echo: treat as clear
return us / 58; // about 58 us per cm, round trip
}
void drive(int left, int right) { // -255 to 255
digitalWrite(IN1, left >= 0); digitalWrite(IN2, left < 0);
digitalWrite(IN3, right >= 0); digitalWrite(IN4, right < 0);
analogWrite(ENA, abs(left)); analogWrite(ENB, abs(right));
}
void setup() {
pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT);
int outs[] = {ENA, IN1, IN2, ENB, IN3, IN4};
for (int p : outs) pinMode(p, OUTPUT);
Serial.begin(115200);
}
void loop() {
long d = readDistanceCm(); // sense
Serial.println(d);
if (d < 20) { // think
drive(-150, 150); // act: spin away
delay(300);
} else {
drive(180, 180); // act: go forward
}
delay(50);
}
A line follower uses the same structure. Swap the ultrasonic sensor for two or three IR reflectance sensors, and steer toward whichever sensor sees the line. Once that works, add proportional control (steer harder the further off the line you are). That is your first taste of a feedback controller.
Porting it to ROS 2 + Gazebo
In ROS 2 the same logic becomes a node that subscribes to a laser scan and publishes velocity commands. Create a package, drop this file in, and run it against any simulated differential-drive robot in Gazebo Jetty:
import math
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import LaserScan
from geometry_msgs.msg import Twist
class Avoider(Node):
def __init__(self):
super().__init__('avoider')
self.declare_parameter('stop_distance', 0.5) # metres
self.cmd = self.create_publisher(Twist, 'cmd_vel', 10)
self.create_subscription(LaserScan, 'scan', self.on_scan, 10)
def on_scan(self, scan):
# Index of the ray pointing straight ahead (angle 0)
i0 = int(round((0.0 - scan.angle_min) / scan.angle_increment)) % len(scan.ranges)
window = [scan.ranges[(i0 + k) % len(scan.ranges)] for k in range(-15, 16)]
valid = [r for r in window if scan.range_min < r < scan.range_max and math.isfinite(r)]
closest = min(valid, default=float('inf'))
twist = Twist()
if closest < self.get_parameter('stop_distance').value:
twist.angular.z = 0.8 # turn in place
else:
twist.linear.x = 0.2 # drive forward
self.cmd.publish(twist)
def main():
rclpy.init()
rclpy.spin(Avoider())
rclpy.shutdown()
ros2 pkg create --build-type ament_python avoider_pkg \
--dependencies rclpy sensor_msgs geometry_msgs
# add avoider.py and an entry point in setup.py, then:
colcon build --packages-select avoider_pkg
source install/setup.bash
# Bridge Gazebo and ROS 2 topics (names depend on your world/robot)
sudo apt install ros-lyrical-ros-gz
ros2 run ros_gz_bridge parameter_bridge \
/scan@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan \
/cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist ros2 run avoider_pkg avoider
Some newer ROS 2 stacks, including Nav2, expect TwistStamped on cmd_vel rather than Twist. If the robot ignores your commands, check the message type with ros2 topic info /cmd_vel. Next, add wheel encoders and learn robot odometry, which is how the robot estimates where it has driven.
Engineer's note
Write and debug in simulation (Gazebo Jetty or Webots) before you touch hardware. Crashing a simulated robot costs nothing, and you can replay the exact failure as many times as you need.
Which programming language should you learn for robotics?
Learn Python first. It is the main language for ROS 2 scripting, LeRobot, computer vision and most AI work, and its syntax carries straight over to MicroPython and URScript. Add C++ once you need performance or real-time behaviour.
| Language | Where it is used | Learn it when |
|---|---|---|
| Python | ROS 2 (rclpy), LeRobot, OpenCV, RoboDK API, FRC (RobotPy) | First, for almost everyone |
| C++ | Arduino, ROS 2 core and drivers (rclcpp), controllers, motion planning | Second, or first if you start on Arduino |
| Java | FIRST Tech Challenge, FRC | When your team uses it |
| Vendor languages (RAPID, KRL, TP, INFORM, URScript) | Industrial arms | When you target factory work |
So is Python enough? For learning, prototyping and most research, yes. For robotics engineering jobs, no: drivers, controllers and anything with tight timing are written in C++, and job ads reflect it. The honest counter-argument is that people who start on Arduino are already writing simplified C++. For them, going C++ first and Python second works just as well.
On “Arduino first or straight into ROS 2?”: developers with Linux and Python experience can go straight to ROS 2 in simulation. Everyone else should spend a few weeks on Arduino first. Wiring, PWM and sensor timing are easier to learn without a middleware layer in the way.
Learning paths by age and goal
The right path depends less on talent than on access to hardware and a clear first goal. These four routes cover most readers.
Can a 14-year-old learn robotics?
Yes, and a team programme is the best start. FIRST Tech Challenge (grades 7 to 12) runs the 2026-2027 game BIOBUZZ presented by RTX, released September 12, 2026. Teams program in Java or block-based code. The FIRST Robotics Competition (high school) releases its 2027 game, BIOCORE presented by Haas, on January 9, 2027, with programming in Java, C++ or Python.
Younger students should know about one change. LEGO Education chose not to renew its partnership with FIRST, so after the 2026-2027 BIOGLOW season, a SPIKE-based Founders Edition in 2027-2028 will be the final FIRST LEGO League season. After that, FIRST launches its own K-8 programmes and LEGO Education launches its own LEGO League. Families planning ahead should look at FTC or independent Arduino and micro:bit projects.
Did you know?
FIRST says FIRST LEGO League, the first robotics programme for many children, runs its 2026-2027 BIOGLOW season as part of the wider FIRST CANOPY season, followed by a final Founders Edition season in 2027-2028.
University students and software developers
Engineering and CS students should take the ROS 2 path. Learn Lyrical in Gazebo Jetty, build one small physical robot, and contribute to an open-source package. Software developers moving into robotics already have the hardest part. What they usually lack is linear algebra for kinematics, control basics such as PID, and comfort with hardware faults. A Raspberry Pi rover running ROS 2 fills those gaps faster than another course.
Robotics without JEE
Yes, students in India can do robotics without clearing JEE. JEE is the gate to IITs and many NITs, not to robotics. Other routes include B.Tech programmes at private and state universities with their own entrance exams, polytechnic diplomas in mechatronics or electronics followed by lateral entry, and B.Sc. or BCA degrees combined with strong project work. Free NPTEL courses from IIT faculty cover robotics, control and embedded systems. Employers hiring robot programmers and integrators look at portfolios, simulator skills and vendor certifications far more than entrance-exam ranks.
Getting hired programming industrial robots
Factory robot programmer and integrator roles reward practical, brand-specific skills. A realistic path:
- Learn frames, waypoints and I/O in URSim or RobotStudio.
- Take a vendor course (FANUC, ABB, KUKA, Yaskawa and Universal Robots all run them) to get pendant hours and a certificate.
- Learn PLC basics, since robots talk to PLCs over digital I/O and fieldbuses.
- Add offline programming with RoboDK or the vendor tool.
The big four makers dominate installed fleets, which our rundown of the largest robotics companies covers in detail, so FANUC or ABB skills transfer to most employers.
Why the skill matters: 2025 robot market numbers
Industrial robot installations hit a new high in 2025, and every one of those robots needed programming, integration and maintenance. According to the International Federation of Robotics’ World Robotics 2026 report, released September 24, 2026, 603,307 industrial robots were installed worldwide in 2025, up about 11%. The global operational stock reached about 5 million units, up 9%.
| Market | 2025 installations | Change |
|---|---|---|
| World | 603,307 | +11% |
| China | 354,200 (about 59% of world) | Largest market |
| United States | About 38,400 | +12%, now second |
| Japan | 36,219 | โ19%, now third |
China’s 354,200 units were misreported by some outlets as the global total. The world figure is 603,307. The IFR forecasts 655,000 installations in 2026 and 806,000 in 2029.
For job seekers, the US jump matters most. Programmers who can commission a cell are in demand wherever installs grow, and the US passing Japan points to more integration work in North America over the next few years.
Safety rules before you run code on real hardware
Before running any program on a real robot, know where the emergency stop is, run at reduced speed, and test the logic in simulation first. Every serious incident in robot programming starts with skipping one of those three.
- E-stop within reach. Test that it works before each session. On hobby robots, a physical switch on the motor power line lets you cut power quickly, though it is not equivalent to an industrial enabling device or safety-rated stop.
- Reduced speed while teaching. Industrial controllers have a manual reduced-speed mode (T1 on many brands), which ISO 10218 limits to 250 mm/s at the robot’s tool centre point (TCP). Prove a new program step by step in that mode.
- Simulate first. Check reach, collisions and logic in RobotStudio, URSim, Gazebo or Webots before downloading.
- Stay out of the work envelope when the robot runs in automatic mode. Fences, light curtains and area scanners exist for this.
- Cobots are not automatically safe. A UR or FANUC CRX arm limits force, but a sharp tool, a knife-edged part or a high payload can still injure. Collaborative safety is a property of the whole application, which ISO 10218 (revised in 2025) now covers directly.
- Hobby robots bite too. Lithium batteries, spinning gears and runaway rovers cause real injuries. Lift the wheels for the first test.
Your next step is to pick one row from the goal table above and finish its first milestone this month: a pick cycle in URSim, an Arduino avoider, or a ROS 2 node driving a robot in Gazebo Jetty. Once one working program is behind you, every other method in this guide gets easier to learn.
FAQ
How can we program a robot?
You can program a robot in four ways: jogging it and recording points on a teach pendant (or hand-guiding a cobot), programming offline in a simulator such as RoboDK or RobotStudio, writing code in C++, Python or a vendor language, or recording demonstrations and training a policy with tools like LeRobot. Industrial cells mostly use the first two. Hobby and research robots mostly use code.
What are the big 4 of robotics?
In industrial robotics, “the big four” usually means ABB, FANUC, KUKA and Yaskawa, the four makers with the largest installed bases of industrial arms. Each has its own language: RAPID, KAREL and TP, KRL, and INFORM respectively.
Can a 14 year old learn robotics?
Yes. At 14 you can start with Arduino projects at home and join FIRST Tech Challenge, which programs robots in Java or blocks. Python and basic electronics are well within reach at that age. FIRST LEGO League ends after its 2027-2028 Founders Edition season, so FTC is becoming the main FIRST route for that age.
Can I do robotics without JEE?
Yes. JEE only controls entry to IITs and many NITs. Private and state university B.Tech programmes, polytechnic diplomas in mechatronics, and science degrees combined with a strong project portfolio all lead to robotics work. Vendor certifications and simulator skills matter more to integrators than entrance ranks.
What programming language is used for robots?
Python and C++ dominate general robotics and ROS 2. Arduino firmware uses C++. Industrial arms use vendor languages: ABB RAPID, KUKA KRL, FANUC TP and KAREL, Yaskawa INFORM, Universal Robots URScript, Stรคubli VAL3, Comau PDL2 and Kawasaki AS.
Is Python or C++ better for robotics?
Python is better for learning, AI, scripting and fast prototyping. C++ is better for drivers, real-time control and performance-critical ROS 2 nodes. Learn Python first and add C++ when your projects need speed or you apply for engineering roles.
What is teach pendant programming?
It is online programming on the real robot. You use a handheld pendant to jog the arm to each position, save the points, choose joint, linear or circular moves, and add I/O commands. It is simple and accurate to the real cell, but the robot cannot produce while you teach.
What is offline robot programming?
Offline programming means creating and testing the robot program on a PC against a 3D model of the cell, using tools such as RoboDK, ABB RobotStudio, FANUC ROBOGUIDE or Yaskawa MotoSim. A post-processor converts the result into the robot’s language. You still calibrate and touch up key points on the real robot.
Do I need ROS to program a robot?
No. Arduino robots, industrial arms and FTC robots all run without ROS. You need ROS 2 when a robot combines many sensors, navigation, manipulation planning or research code, because it gives you ready-made drivers, tools and packages instead of building that plumbing yourself.
How long does it take to learn robot programming?
A first working Arduino robot takes a few weekends. Getting comfortable with ROS 2 in simulation usually takes a few months of regular practice. Becoming job-ready on an industrial brand typically means a vendor course plus several months of hands-on pendant and simulator work. Steady weekly practice matters more than the total number of hours.
Credits and sources
By RWT Robotics Editorial Team
- Facts were checked against the sources below before publication.
- Published
Checking and sources
- Researched from 8 sources, listed below.
- Facts are checked against those sources; anything we cannot confirm is corrected, labelled or removed.
Sources (8)
- ROS 2 Lyrical Luth Released (discourse.openrobotics.org)
- Lyrical Luth release notes, ROS 2 Documentation (docs.ros.org)
- New packages and patch release for Lyrical 2026-06-23 (discourse.openrobotics.org)
- ROS 2 Lyrical Luth and 11 years of Fast DDS as ROS 2 default middleware (discourse.openrobotics.org)
- ROS 2 Jazzy Jalisco Released (openrobotics.org)
- Gazebo Releases (gazebosim.org)
- New release cadence for Gazebo and better alignment with ROS (discourse.openrobotics.org)
- IFR World Robotics 2026 Executive Summary – Industrial Robots (ifr.org)









