PTENES
MODULE 2.8

💻 How to Program Robots: From the Teach Pendant to Code

There is a ladder of methods for telling a robot what to do—from the teach pendant (without a single line of code) to Python, ROS 2, and natural language. This module covers each step, when to use it, and the learning path for each profile to progress from simple to advanced.

6
Topics
50
Minutes
Intermediate
Level
Practice
Type
simple advanced 🕹️ Teach Pendant guide / record pose 🧱 No-code blocks / flow 🐍 Python SDK / vision / AI 🤖 ROS 2 nodes / topics 🗣️ Natural Language VLA / code-as-policies

Illustrative diagram: each step increases power and complexity—from the teach pendant (no code) to natural language with VLA.

1

🕹️ Teach Pendant and Lead-Through

The dominant method today doesn’t use a single line of code. In teach pendant, you navigate a handheld console to move the arm and record positions. In the lead-through (hand-guiding), you simply hold the arm with your hand and guide it along the path, recording each pose. It is the foundation of cobots (UR, FANUC CRX) and the entry point for anyone who has never programmed before.

📍 How the robot “learns” a routine

Program using a teach pendant and record a sequence of waypoints (waypoints). Each waypoint is a pose — position plus end-effector orientation — relative to a frame (base or tool).

  • •Manual jog: move the arm axis by axis (or in Cartesian space) using the console.
  • •Record a waypoint: save the current pose as a trajectory waypoint.
  • •Speed and acceleration: adjust how fast the robot moves between points.

📊 Why it starts here

  • Dominant method - Most cobot cells on factory floors are programmed this way.
  • No-code - operators learn in hours, not months; ideal for repetitive tasks.
  • UR and FANUC CRX cobots - native lead-through: press a button and guide the arm by hand.

💡 Practical Tip

Before recording waypoints, define the base/tool frames clearly. An incorrect tool frame makes the robot "think" the gripper is somewhere else—and shifts the entire trajectory. Mastering frames is the first leap in quality for anyone programming with a teach pendant.

Key concepts

Waypoints
Journey points
Pose / frames
Base and tool
Manual jog
Move via the console
Lead-through
Guide by hand
2

🧱 No-Code and Blocks / Flow

The second step adds logic without writing text. Visual interfaces— Blockly-style blocks, flowcharts, and the UR's PolyScope with drag-and-drop — letting you build conditionals, loops, and waits by dragging pieces. This makes it accessible: those who know how to use a teach pendant can now program behavior, not just trajectories.

Visual program (illustrative)
▸ Programa
  ┌ Loop (sempre)
  │   ◆ Se sensor_peca == verdadeiro
  │       → MoveJ  waypoint_pegar
  │       → Garra  fechar
  │       → MoveL  waypoint_soltar
  │       → Garra  abrir
  │   ◆ Senao
  │       → Esperar  0.5 s
  └ Fim Loop

✓ When to use NO-CODE

  • ✓Repetitive task with few variations (pick-and-place)
  • ✓Team without programmers; operators assemble the routine
  • ✓Simple logic: sensor-based if statements, loops, wait, ready-made templates
  • ✓Rapid prototyping in the cell, without a build cycle

✗ When NO-CODE hits a wall

  • ✗Complex logic with many branches and states
  • ✗Integrate computer vision or external AI
  • ✗Reuse across robots from different manufacturers
  • ✗Version and test code like real software

Key concepts

if/loop blocks
Drag-and-drop logic
Action nodes
Move, gripper, wait
Conditional
If per sensor
Templates
Reuse of routines
3

🐍 Python and the Frontier of Code

Python and the most widely used language in robotics and AI. With it, you control cobots via an SDK (e.g., ur_rtde), processes computer vision, and integrates AI models. Moving from no-code to code opens up complex tasks that blocks can’t handle—and, in practice, leads to better salaries.

controle_cobot.py (illustrative)
# Mover um cobot UR e acionar a garra (ilustrativo)
from rtde_control import RTDEControlInterface as RTDEControl
robo = RTDEControl("192.168.0.10")
pose = [-0.14, -0.40, 0.20, 0, 3.14, 0]   # x, y, z + rotacao
robo.moveL(pose, speed=0.25, acceleration=0.5)
robo.setStandardDigitalOut(0, True)         # fecha a garra

📈 What the Code Unlocks

  • Control Loop - read sensors and react in real time, beyond what blocks allow.
  • Computer vision - locate parts with a camera and calculate the grasp pose in real time.
  • Reusable scripts - version, test, and reuse code across projects.

💡 Practical Tip

You don't need to give up the teach pendant to learn Python. Start by recording the trajectory in the console, export the poses, and use the SDK only for the parts blocks can't handle (vision, decision-making, integration). This "hybrid" approach is the real path for moving from operator to technician.

Key concepts

SDK
ur_rtde, manufacturer
Control Loop
Read and React
Vision
Camera + pose
Scripts
Reusable
4

🤖 ROS 2: The Standard Middleware

Despite the name, ROS 2 is not a real operating system — it is a middleware: a layer that connects the parts of a robot. Programs become nodes that communicate through topics (publish/subscribe), messages e services. AMRs, humanoids, and academic research run ROS 2.

🧩 The ecosystem that comes with it

ROS 2's strength is not just communication: it's the mature toolchain you can reuse instead of rewriting.

  • •Nav2: autonomous navigation for mobile robots (AMRs).
  • •MoveIt 2: motion planning and arm manipulation.
  • •Gazebo: physics simulation to test before using real hardware.
in ROS 2 publishing a topic (illustrative)
import rclpy
from geometry_msgs.msg import Twist

no = rclpy.create_node("motorista")
pub = no.create_publisher(Twist, "/cmd_vel", 10)
cmd = Twist()
cmd.linear.x = 0.2     # anda pra frente
pub.publish(cmd)         # publica no topico /cmd_vel

💡 Practical Tip

You don't need a physical robot to learn ROS 2: Gazebo simulates physics and sensors. Many robotics engineers start by publishing topics on a virtual robot before touching expensive hardware—make mistakes in simulation, not in the production cell.

Key concepts

Nodes / topics
Publish/subscribe
Messages
Services and data
Nav2 / MoveIt 2
Navigation and arms
Gazebo
Physical simulation
5

🗣️ Programming with Natural Language

The new frontier: you describe the task in Portuguese and the robot generates and executes the routine. Connects directly to module 2.7 (VLA). In the "code-as-policies", an LLM writes the control code, and a human reviews it before it runs. The skill is no longer “typing code”; it becomes “clearly specifying the task and reviewing what the AI generated.”

✨ How code-as-policies works

You write a task prompt ("separate the red parts from the conveyor belt"). The LLM generates the code that operates the robot; you review and approve it. AI speeds things up, but responsibility for safety remains with humans.

  • •Task Prompt: describe the goal, not the steps.
  • •VLA: vision-language-action models that link perception to movement.
  • •Human review: approve the code before it touches the hardware.

🚫 Attention: security of self-generated code

LLM-generated code can be syntactically perfect and still send the arm into a collision. Never run self-generated code directly in production: validate it in simulation, limit speed/force, and keep the operator in the loop. AI writes quickly, but it isn't responsible for an accident—you are.

Key concepts

Code-as-policies
LLM writes control code
Task Prompt
Objective in text
VLA
Vision-language-action
Human review
Safety in the loop
6

🧭 Which Path to Follow

There is no "right way"—there is the the right step for your profile. The path is progressive: each level opens a new salary tier and connects to the certifications in module 3.4. The key is not to skip steps, but to climb one at a time while building a project portfolio.

1

Operator: teach pendant → no-code

From guided arm to block-based logic

Start by mastering lead-through and waypoints; then move on to no-code (PolyScope, blocks) to program conditionals and loops. At this point, you can deliver complete cells without writing code.

2

Technical: no-code → Python

The leap to code

Those who already build logic with blocks learn Python and SDKs (ur_rtde) to integrate vision and decision-making. It’s the step where salaries rise the most, because it unlocks tasks that no-code can’t handle.

3

Engineer: Python → ROS 2 → VLA

Top of the ladder

With a solid foundation in Python, move on to ROS 2 (complex systems, AMRs, humanoids) and the VLA / natural language frontier. Keep learning: today's frontier becomes tomorrow's standard.

✓ How to climb the ladder

  • ✓Master one step before moving on to the next
  • ✓Build a portfolio of real projects at each level
  • ✓Link learning to certifications (module 3.4)
  • ✓Keep learning continuously: the frontier is moving

✗ Mistakes made by those who get lost

  • ✗Skip to ROS 2 without a Python foundation
  • ✗Thinking no-code “doesn’t count” as a skill — it does, and a lot
  • ✗Study only theory without delivering any projects
  • ✗Stop learning once you reach a comfortable plateau

💡 Practical Tip

Honestly identify your current rung and aim for the one immediately above it—not the top. An operator who learns no-code is worth more than an operator who is stuck; a technician who learns Python is worth more than a block-based technician. The ladder pays off at every step, not just at the end.

Key concepts

Track by role
Operator to engineer
From simple to complex
One step at a time
Portfolio
Real Projects
Continuous learning
The frontier is shifting

🏁 Module Summary

✓
Teach pendant and lead-through - the dominant no-code method: records waypoints and poses by guiding the arm; the basis for UR and FANUC CRX cobots.
✓
No-code and blocks - visual logic (Blockly, PolyScope) with if/loop/wait; makes it accessible, but hits limits with complexity and integration.
✓
Python - SDK (ur_rtde), control loop, computer vision, and AI; the leap that unlocks complex tasks and better pay.
✓
ROS 2 - middleware with nodes, topics, and messages; Nav2, MoveIt 2, and Gazebo power AMRs, humanoids, and research.
✓
Natural Language / VLA - Code-as-policies: describe the task, AI generates the code, and a human reviews it. Safety remains a human responsibility.
✓
Route by profile - operator, technician, engineer: each level pays off and connects to the certifications in module 3.4.

Next Track:

Track 3 - Strategic: how to lead the robotics transition at the organizational level, from pilot to scale.