Sarvajanik University — SCET
Robotics and Navigation (BTEC14619)
Chapter 4: Robot Programming & ROS
Complete Study Notes + PYQ Answers | [Link] Sem VI
# Syllabus Topic
4.1 Robot Programming Languages — Classification
4.2 ROS Basics — History, Equation, Architecture & Concepts
4.3 Sensors and Robots Supporting ROS
4.4 Ubuntu Linux for Robotics — GUI, Shell Commands
4.5 C++ and Python for Robotic Programming
■ PYQ — Questions from This Topic
Q. Categorize / Classify various robot programming languages. [2 marks | S2024 & S2025 ★★]
Q. What is ROS? / What is a Robot Operating System (ROS)? Explain its working and benefits. [2/4 marks | S2024 &
S2025]
Q. Explain ROS node architecture. [4 marks | S2024 & S2025 ★★]
Q. Explain various services offered by ROS with syntax in detail. [6 marks | S2024]
Q. Write a note on SERVICES and ACTIONS in ROS. [6 marks | S2025]
Q. What is CATKINS in ROS? [2 marks | S2024]
Q. Explain syntax / commands used in ROS programming. [4 marks | S2025]
Q. Narrate Linux commands with example: ls, pwd, rm, sudo. [2 marks | S2024]
Q. With proper diagram, explain working of IR sensor. [6 marks | S2024]
Q. What is Python interpreter? [2 marks | S2025]
Q. Explain ROS architecture. [4 marks | S2025]
4.1 Classification of Robot Programming Languages
Robot programming languages allow users to specify the sequence of motions and operations a robot must perform.
They are broadly classified into four generations based on their level of abstraction.
Classification (4 Levels):
Generation Description Examples
1st Generation (Joint-level Robot is physically guided through motions and positions are
VAL (Unimation), FUNKY
/ Guiding) recorded (teach-pendant).
2nd Generation Programs written as sequences of robot commands.
VAL II, RAIL, AML, MCL
(Robot-level / Explicit) Programmer specifies each move explicitly.
3rd Generation (Task-level High-level language; programmer specifies the task goal, system
AUTOPASS, LUMA
/ Implicit) plans the motion automatically.
4th Generation Natural language or AI-based; robot understands goals without
Emerging / Research stage
(Problem-level) explicit programming.
Other Classification Basis:
• Textual languages: Written as code (VAL, AML, RAPID, KRL, Python)
• Graphical / Visual languages: Block-based or flow-diagram based
• Offline programming languages: Simulation-based, no physical robot needed during programming
• Online programming (Teach pendant): Robot is moved manually; positions stored
■ PYQ — Questions from This Topic
Q. Categorize various robot programming languages. [2 marks | S2024 & S2025 ★★]
■ This 2-mark question appeared in BOTH exams. Write the 4 generations with one example each.
4.2 ROS Basics — History, Equation, Architecture & Concepts
What is ROS?
ROS (Robot Operating System) is an open-source, flexible framework for writing robot software. Despite its name,
ROS is not a traditional operating system. It is a middleware — a collection of tools, libraries, and conventions that
simplify creating complex and robust robot behavior across a wide variety of robotic platforms.
• Developed at Stanford AI Lab (2007), later at Willow Garage (2008–2013)
• Now maintained by Open Robotics (formerly OSRF)
• Runs on Ubuntu Linux (primary), with partial support for Windows & macOS
• Current stable version: ROS 2 Humble / Iron; legacy: ROS 1 Noetic
History of ROS:
Year Milestone
2007 Prototype at Stanford (Switchyard project)
2008 Willow Garage adopts & develops ROS
2010 ROS 1.0 released publicly
2013 Open Source Robotics Foundation (OSRF) takes over
2014 ROS Indigo (first long-term support release)
2017 ROS 2 introduced (addressing real-time & security needs)
2022+ ROS 2 Humble/Iron — actively maintained
The ROS Equation (Core Concept):
ROS can be understood through a simple equation that describes what it provides:
ROS = Plumbing + Tools + Capabilities + Ecosystem
• Plumbing: Communication infrastructure (topics, services, actions) that connects nodes
• Tools: rviz (visualization), rqt (GUI tools), rosbag (recording), roslaunch
• Capabilities: Ready-made libraries for navigation, perception, manipulation, SLAM
• Ecosystem: Large community, thousands of open-source packages on GitHub
Benefits of ROS:
• Hardware abstraction — same code runs on different robots
• Code reuse through packages and libraries
• Language flexibility — supports C++ and Python natively
• Built-in tools for debugging, simulation, logging
• Active open-source community and rich documentation
• Supports distributed computing — nodes can run across multiple machines
■ PYQ — Questions from This Topic
Q. What is a Robot Operating System (ROS)? Explain its working and benefits. [4 marks | S2024]
Q. What is ROS? [2 marks | S2025]
4.2 (cont.) ROS Architecture & Concepts
ROS Architecture — Three Levels:
ROS architecture is organized into three conceptual levels:
Level Description
How ROS code is organized on disk: Packages, Metapackages, Package Manifests
1. Filesystem Level
([Link]), Repositories
How ROS processes communicate at runtime: Nodes, Master, Parameter Server,
2. Computation Graph Level
Topics, Services, Actions, Messages, Bags
How ROS resources are shared: Distributions, Repositories, ROS Wiki, Bug Tracker,
3. Community Level
ROS Answers
Key ROS Concepts (Computation Graph):
Node A node is a single process/program that performs computation. Nodes communicate with each
other using topics, services, or actions. Each node has a unique name in the ROS graph.
Example: /camera_node, /motor_controller, /path_planner
ROS Master The ROS Master provides name registration and lookup to the rest of the computation graph. It
helps nodes find each other. Started using the 'roscore' command. Without the master, nodes
cannot find each other and communicate.
Parameter A shared dictionary accessible by all nodes. Used to store configuration data. Nodes can get/set
Server parameters at runtime using rosparam commands.
Topic A named bus over which nodes exchange messages. Communication is asynchronous and
publish-subscribe based. A node publishes messages to a topic; other nodes subscribe to
receive them. No direct connection between publisher and subscriber. Example: /scan (laser
data), /cmd_vel (velocity commands)
Message A data structure used to communicate over topics. Defined in .msg files. Standard types:
std_msgs, geometry_msgs, sensor_msgs. Example: geometry_msgs/Twist for velocity (linear +
angular).
Service A synchronous request-response communication. One node sends a request; another sends a
response. Defined in .srv files with request and response sections. Example:
/move_base/make_plan service. Used for infrequent, blocking operations.
Action Like services but for long-duration tasks with feedback. Uses .action files with Goal, Result,
and Feedback sections. Client sends a goal; server sends periodic feedback and a final result.
Example: navigation to a goal position. Defined using actionlib.
Bag A file format (.bag) for recording and replaying ROS message data. Useful for testing and
debugging. Commands: rosbag record, rosbag play, rosbag info.
■ PYQ — Questions from This Topic
Q. Explain ROS node architecture. [4 marks | S2024 & S2025 ★★]
Q. Explain ROS architecture. [4 marks | S2025]
Q. Explain various services offered by ROS with syntax in detail. [6 marks | S2024]
Q. Write a note on SERVICES and ACTIONS in ROS. [6 marks | S2025]
Q. What is CATKINS in ROS? [2 marks | S2024]
catkin — The ROS Build System:
catkin is the official build system of ROS (replaced rosbuild in ROS Groovy). It is based on CMake with added
macros for ROS. catkin compiles ROS packages and manages dependencies between them.
• Workspace: A folder containing ROS packages — called catkin workspace
• Standard directory structure: src/ (source), build/ (compiled), devel/ (setup files)
• Key files: [Link] (build rules) and [Link] (dependencies, metadata)
catkin workspace setup & build:
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make # builds all packages in src/
$ source devel/[Link] # add workspace to ROS environment
# Create a new package:
$ cd ~/catkin_ws/src
$ catkin_create_pkg my_robot std_msgs rospy roscpp
ROS Services — Syntax and Usage:
A ROS service is a synchronous request/response mechanism. The service definition (.srv) has two parts separated
by '---': request fields above, response fields below.
Service definition file ([Link]):
# Request
int64 a
int64 b
---
# Response
int64 sum
Service server (Python):
import rospy
from beginner_tutorials.srv import AddTwoInts, AddTwoIntsResponse
def handle_add(req):
return AddTwoIntsResponse(req.a + req.b)
rospy.init_node('add_two_ints_server')
s = [Link]('add_two_ints', AddTwoInts, handle_add)
[Link]()
Service client (Python):
rospy.wait_for_service('add_two_ints')
add = [Link]('add_two_ints', AddTwoInts)
resp = add(3, 5)
print([Link]) # Output: 8
Shell commands for services:
$ rosservice list # list all services
$ rosservice info /name # info about a service
$ rosservice call /name # call a service from terminal
$ rossrv list # list all service types
ROS Actions — Syntax and Usage:
Actions are used for long-running goals with periodic feedback. Defined in .action files using actionlib. Structure:
Goal / Result / Feedback (separated by ---).
Action definition file ([Link]):
# Goal
int32 order
---
# Result
int32[] sequence
---
# Feedback
int32[] partial_sequence
Action client (Python):
import actionlib
from my_pkg.msg import FibonacciAction, FibonacciGoal
client = [Link]('fibonacci', FibonacciAction)
client.wait_for_server()
goal = FibonacciGoal(order=20)
client.send_goal(goal)
client.wait_for_result()
print(client.get_result())
4.3 Sensors and Robots Supporting ROS
Common Sensors with ROS Support:
Sensor ROS Details Examples
Publishes on /scan topic. Message type:
LiDAR (Laser Scanner) sensor_msgs/LaserScan. Used for SLAM, obstacle Hokuyo, RPLIDAR, Velodyne
detection.
Image: sensor_msgs/Image. Camera info:
Camera (RGB / Depth) sensor_msgs/CameraInfo. Packages: image_transport, Intel RealSense, ZED, Kinect
cv_bridge.
sensor_msgs/Imu. Provides orientation, angular velocity,
IMU MPU6050, BNO055
linear acceleration.
GPS sensor_msgs/NavSatFix. Provides lat/lon/altitude. u-blox, SparkFun GPS
Ultrasonic / IR sensor_msgs/Range. Distance measurement. HC-SR04, Sharp IR
nav_msgs/Odometry. Robot position and velocity from
Encoder / Odometry Magnetic encoders
wheel encoders.
Robots with Official ROS Support:
Robot Notes
TurtleBot 2 / 3 Most popular ROS learning platform; differential drive mobile robot
PR2 (Willow Garage) Advanced dual-arm robot; original ROS test platform
Baxter / Sawyer (Rethink Robotics) Collaborative industrial robot arms
UR5 / UR10 (Universal Robots) 6-DOF arms with ros_industrial support
Fetch Robot Mobile manipulator for research
Drone (Parrot, DJI) via hector_quadrotor or MAVROS packages
■ PYQ — Questions from This Topic
Q. With proper diagram, explain working of IR sensor. [6 marks | S2024]
IR Sensor — Working (for 6-mark answer):
An Infrared (IR) sensor detects objects by emitting IR radiation and sensing the reflected signal.
• Components: IR LED (emitter) + Photodiode/Phototransistor (receiver)
• Principle: IR LED emits infrared light → reflects off object → receiver detects reflected light
• Output: Analog voltage (proportional to distance) or Digital HIGH/LOW signal
• Working modes: (1) Reflective mode — emitter & receiver side by side; (2) Through-beam — emitter & receiver
opposite
• ROS topic: Publishes on sensor_msgs/Range topic
• Applications in robotics: Line following, obstacle detection, proximity sensing
■ For diagram: Draw IR LED + phototransistor facing same direction. Show IR beam going out, hitting object, reflecting
back to receiver. Show Vout line going to microcontroller.
4.4 Ubuntu Linux for Robotics — GUI & Shell Commands
Why Ubuntu for Robotics?
• ROS officially supports Ubuntu LTS versions (18.04, 20.04, 22.04)
• Free and open-source — ideal for research and education
• Strong community support and package ecosystem (apt)
• Lightweight, stable, and configurable for embedded systems (Raspberry Pi)
Ubuntu GUI Components:
Ubuntu uses the GNOME desktop environment (or older Unity). Key GUI elements:
• Activities Overview: Search apps, switch windows (Super key)
• Files (Nautilus): Graphical file manager
• Terminal: Command-line interface — most important tool for ROS
• Settings: System configuration (network, display, users)
• Software Center: GUI for installing applications
Essential Shell Commands (Linux Terminal):
■ PYQ — Questions from This Topic
Q. Narrate the following Linux commands with example: 1. ls 2. pwd 3. rm 4. sudo [2 marks | S2024]
Q. Explain syntax / commands used in ROS programming. [4 marks | S2025]
Command Purpose Example
ls List directory contents ls -la (detailed list with hidden files)
ls -l Long format listing ls -l /home/user
pwd Print working directory (current path) pwd → /home/ubuntu/catkin_ws
cd Change directory cd ~/catkin_ws/src
mkdir Make new directory mkdir my_folder | mkdir -p a/b/c
rm Remove files or directories rm [Link] | rm -rf folder/
cp Copy file/folder cp [Link] [Link]
mv Move or rename mv [Link] [Link]
cat Display file contents cat [Link]
nano / vim Text editors in terminal nano my_node.py
sudo Run command as superuser (admin) sudo apt install ros-noetic-slam-gmapping
apt Package manager sudo apt update | sudo apt install pkg
chmod Change file permissions chmod +x my_node.py (make executable)
echo Print text / variable echo $ROS_MASTER_URI
source Execute script in current shell source devel/[Link]
export Set environment variable export ROS_MASTER_URI=[Link]
grep Search text in files grep -r 'rospy' src/
top / htop Show running processes htop
ifconfig / ip Network configuration ip addr show
ssh Remote login ssh ubuntu@[Link]
Essential ROS Shell Commands:
ROS Command Purpose Example
roscore Start ROS Master (required first) roscore
rosrun Run a single ROS node rosrun turtlesim turtlesim_node
roslaunch Launch multiple nodes from .launch file roslaunch my_pkg [Link]
rostopic list List all active topics rostopic list
rostopic echo Print messages on a topic rostopic echo /cmd_vel
rostopic pub /cmd_vel geometry_msgs/Twist
rostopic pub Publish to a topic from terminal
...
rosnode list List running nodes rosnode list
rosnode info Info about a node rosnode info /turtlesim
rosparam set/get Set/get parameter server values rosparam set /speed 1.5
rosmsg list List message types rosmsg list
rossrv list List service types rossrv list
rosbag record Record topics to bag file rosbag record -a (record all)
rosbag play Replay a bag file rosbag play my_data.bag
catkin_make Build catkin workspace cd ~/catkin_ws && catkin_make
catkin_create_pkg Create new ROS package catkin_create_pkg my_pkg std_msgs rospy
4.5 C++ and Python for Robotic Programming
■ PYQ — Questions from This Topic
Q. What is Python interpreter? [2 marks | S2025]
Python Interpreter:
The Python interpreter is a program that reads and executes Python code line by line (interpreted language — no
separate compile step required). ROS uses Python 3 (rospy library). The interpreter converts Python source code into
bytecode and executes it via the Python Virtual Machine (PVM).
• Command to run: python3 my_script.py
• Interactive mode: just type python3 in terminal
• ROS nodes in Python are made executable with: chmod +x [Link]
• Sheband line required: #!/usr/bin/env python3
Python vs C++ in ROS — Comparison:
Aspect Python (rospy) C++ (roscpp)
Speed Slower (interpreted) Faster (compiled)
Ease of use Easier, less verbose More complex syntax
ROS library rospy roscpp
File extension .py .cpp / .h
Use case Rapid prototyping, AI/ML integration Real-time, performance-critical
Compilation Not needed via catkin_make / cmake
Python ROS Node — Publisher Example:
[Link] — Publisher node:
#!/usr/bin/env python3
import rospy
from std_msgs.msg import String
def talker():
pub = [Link]('chatter', String, queue_size=10)
rospy.init_node('talker', anonymous=True)
rate = [Link](10) # 10 Hz
while not rospy.is_shutdown():
msg = 'Hello ROS %s' % rospy.get_time()
[Link](msg)
[Link](msg)
[Link]()
if __name__ == '__main__':
talker()
Python ROS Node — Subscriber Example:
[Link] — Subscriber node:
#!/usr/bin/env python3
import rospy
from std_msgs.msg import String
def callback(data):
[Link]('Received: %s', [Link])
def listener():
rospy.init_node('listener', anonymous=True)
[Link]('chatter', String, callback)
[Link]() # keeps node alive
if __name__ == '__main__':
listener()
C++ ROS Node — Publisher Example (roscpp):
[Link]:
#include 'ros/ros.h'
#include 'std_msgs/String.h'
#include <sstream>
int main(int argc, char **argv) {
ros::init(argc, argv, 'talker');
ros::NodeHandle n;
ros::Publisher pub = [Link]<std_msgs::String>('chatter', 1000);
ros::Rate loop_rate(10);
while (ros::ok()) {
std_msgs::String msg;
[Link] = 'Hello ROS';
[Link](msg);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
Key Python Libraries for Robotics:
Library Use in Robotics
rospy ROS Python client library — nodes, topics, services, actions
cv2 (OpenCV) Computer vision — image processing, object detection
numpy Numerical computation — matrix ops, array math
scipy Scientific computing — optimization, signal processing
matplotlib Plotting — sensor data visualization
smbus / [Link] Raspberry Pi GPIO and I2C communication
tf / tf2_ros Transform library — coordinate frames and transformations
actionlib ROS action client/server implementation
Chapter 4 — Quick Revision & PYQ Answer Guide
2-Mark Questions — One-line Answers:
Q: What is ROS? A: ROS is an open-source middleware framework for robot software
providing tools, libraries, and communication infrastructure for
building robot applications.
Q: What is CATKIN? A: catkin is the official CMake-based build system for ROS that
compiles packages and manages dependencies.
Q: What is Python interpreter? A: A program that reads and executes Python code line by line
without a separate compilation step.
Q: What is a ROS Node? A: A node is a single executable process in ROS that performs
computation and communicates with other nodes via topics,
services, or actions.
Q: What is a ROS Topic? A: A named communication channel over which nodes exchange
messages in a publish-subscribe manner.
Q: What is rostopic echo? A: A ROS command that prints messages being published on a
specified topic to the terminal.
Q: Classify robot programming languages. A: 1st gen (joint-level/guiding), 2nd gen (robot-level/explicit), 3rd gen
(task-level/implicit), 4th gen (problem-level/AI-based).
Q: What is ls command? A: 'ls' lists the contents of a directory. Example: ls -la shows all files
with details.
Q: What is sudo? A: 'sudo' runs a command with superuser (administrator) privileges.
Example: sudo apt install pkg.
Q: What is pwd? A: 'pwd' prints the full path of the current working directory. Example
output: /home/user/catkin_ws
4-Mark Questions — Answer Outline:
Q: Explain ROS node architecture. (★★ BOTH EXAMS)
• ROS uses a distributed architecture where computation is organized as a graph of nodes.
• Nodes: Individual processes. Each node does one task (e.g., read sensor, plan path, control motor).
• ROS Master: Central registry. Nodes register with master; master helps them find each other.
• Topics: Nodes communicate by publishing/subscribing to named channels called topics.
• Services: Synchronous request-response calls between nodes.
• Parameter Server: Shared key-value store for configuration data.
• Messages: Data structures exchanged on topics, defined in .msg files.
Q: Explain ROS architecture. (S2025)
• Three levels: Filesystem (packages, [Link], [Link]), Computation Graph (nodes, topics, services,
master), Community (distributions, wiki, repositories).
• Filesystem: Code organized in packages inside a catkin workspace (src/, build/, devel/).
• Computation Graph: Runtime graph of communicating nodes. Master manages connections.
• Communication: Topics (async pub-sub), Services (sync req-resp), Actions (long-running goals with feedback).
• Tools: rviz (3D visualization), rqt (GUI tools), rosbag (data recording).
6-Mark Questions — Answer Outline:
Q: Explain various services offered by ROS with syntax in detail. / Write a note on SERVICES and ACTIONS in
ROS.
• Define Service: Synchronous request-response mechanism. Suitable for quick, blocking operations.
• Service definition file (.srv): Request section / --- separator / Response section.
• Server node: Registers service, receives request, returns response.
• Client node: Calls service using ServiceProxy, blocks until response received.
• Shell commands: rosservice list, rosservice call, rossrv list.
• Define Action: Asynchronous mechanism for long-running tasks with feedback.
• Action definition file (.action): Goal / --- / Result / --- / Feedback sections.
• Implemented using actionlib library. Client sends goal; server sends periodic feedback and final result.
• Difference: Services block client; Actions allow preemption and feedback during execution.
Study Notes prepared for BTEC14619 — Robotics & Navigation | Sarvajanik University SCET | Chapter 4: Robot Programming & ROS | Based on
Syllabus & PYQ S2024, S2025