0% found this document useful (0 votes)
17 views49 pages

ROS Concept and Practice Part 1

The document provides an overview of the Robot Operating System (ROS), its goals, philosophy, and when to use it, emphasizing its standardization for robotics applications and community support. It details the installation process, workspace setup, and the creation of ROS packages and nodes, highlighting the benefits of modularity, fault tolerance, and language agnosticism. Additionally, it outlines programming nodes in both Python and C++, including the necessary steps to execute and manage them within the ROS framework.

Uploaded by

chuanrich020709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views49 pages

ROS Concept and Practice Part 1

The document provides an overview of the Robot Operating System (ROS), its goals, philosophy, and when to use it, emphasizing its standardization for robotics applications and community support. It details the installation process, workspace setup, and the creation of ROS packages and nodes, highlighting the benefits of modularity, fault tolerance, and language agnosticism. Additionally, it outlines programming nodes in both Python and C++, including the necessary steps to execute and manage them within the ROS framework.

Uploaded by

chuanrich020709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

ROS

Robot Operating System


What is ROS, When to Use It, and Why?
• ROS Goals
• Provide a standard for robotics applications
• Use and reuse on any robot
What is ROS, When to Use It, and Why?
• ROS Goals
• Provide a standard for robotics applications
• Use and reuse on any robot

• ROS Philosophy
• Don’t reinvent the wheel!
Traditional robotics
Why we use ROS?
When to use ROS?
More robot feature/behavior
More complexity
Beyond a simple use case!
• Simple use case (ROS not
needed)
• Robot opens a door with a servo
motor when it detects a
movement
• Complex use case
• Mobile robot with GPS and
Camera for motion
control/planning
• Simple use case (ROS not needed)
• Robot opens a door with a servo motor when it detects a movement
• Complex use case
• Mobile robot with GPS and Camera for motion control/planning
The big picture!
1. Code separation along a set of communication tools
The big picture!
2. Plug and Play libraries
The big picture!
3. Language Agnostic
• Open source
• Active community (GitHub) ROS’s ultimate goal:
• Easy to get help Develop good/great and
scalable robotic
• Share projects applications
• Contribute
ROS Installation
• Install Ubuntu with a Virtual Machine
Download VM
• https://www.virtualbox.org/
• 1. You would need ubuntu installed on the vm.
• first download the ubuntu 18.04 LTS installer image
• https://old-releases.ubuntu.com/releases/18.04.5/ (64-bit PC (AMD64) desktop image)
• usually 1.8GB size (please download before class)
2. Please install a virtual machine (vm) on your laptop/pc.
• https://www.virtualbox.org/
• name operating system: Ubuntu/Test (example)
• Type: Linux
• Version: Ubuntu (64-bit)
• memory size: (go with suggested size, slide max of the green bar), at least 2GB
• create a virtual hard disc now
• VDI (virtualbox hard disc image)
• Storage: Dynamically allocated
• File location and size: give 25GB (because to host ubuntu and ros)
• ——
• Ubuntu/Test » Settings » System » Processor (give 4 CPUs)
• Ubuntu/Test » Settings » Storage » Controller IDE (point to ubuntu.iso image)
• Start VM
3. Install ubuntu on vm.

4. Head to wiki ros, read how to install ros melodic on your vm.
• If you have a dual boot with Ubuntu 18, u do not need vm

5. Open a terminal and run roscore. Keep this terminal open so roscore
always running in the background.
• Open another terminal, run roscore again. An error should appear
because there can only be 1 ROS master running at a time
ROS Master
• The roscore will launch the ros master
• Ros master is the centre of your ros application
• Provide naming and registration services for all the subprograms
called nodes (more on what is a ros master and how it is used when
we learn ros communication concepts)
Create a Catkin Workspace
• Home directory
• Create a folder catkin_ws in
home directory
• Create a folder src in catkin_ws
• Run the command
catkin_make in catkin_ws
folder
• Build and devel folders created
inside catkin_ws
• CMakeList.txt is created
by catkin to init the
workspace
• So all the code that you
write will be on the src
folder
• Build (catkin_make)
everytime there is a
change in the src files
Setting the terminals
One line for your global ROS installation, and
one line for your own ROS workspace
Check correct path used: "~/catkin_ws"/

***********

vim ~/.bashrc

source /opt/ros/<your_ros_version>/setup.bash
source ~/catkin_ws/devel/setup.bash

***********
To add it directly without having to open a text editor, simply type in your terminal:
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
Creating a ROS package
Will require 2 dependencies – roscpp and rospy
1. roscpp is the c++ ros libraries, allow to use ros functionality in c++
codes
2. rospy is the same for python
3. std_msgs
• my_robot_tutorials folder is created in src folder
• Several files created in my_robot_tutorials folder
• src folder in my_robot_tutorials folder is empty for now
Go inside CMakeLists.txt

• Can see name of package


(my_robot_tutorials)
• Dependencies are added
(roscpp rospy std_msgs)
Go inside package.xml
• Name of package , version
• Can put package description
• Add email
• License – in case you want to
publish it on github

• Can also find the


dependencies
Make catkin again (new changes)
• New package that was
build with catkin

• Now we can say our


environment is
successfully setup, ready
to execute some codes!
ROS Nodes
• Robot app will have several
packages
• Each packages will have programs
• These programs (blue) are called
nodes
• Each nodes are launched separately
and can have similar dependencies
• How does the camera pkg behaves
here? First launch camera driver,
then launch image processing
ROS Nodes
• Since the robot needs to move, we
can design a pkg for motion
planning
• Add a motion planning node to
compute the motion planning for
any given robot
• Add path correction node – role is
to modify the motion planning due
to external factors
• Pkg behaviour? First launch path
correction node then launch
motion planning node
ROS Nodes
• Say the movement is determined by
the robot vision
• So we need to allow nodes from
different packages to communicate
with each other
• We link the image processing node
to the path correction node. The
image processing node will analyze
frames coming from the camera
and sends an analysis of the
environment to the path correction
node. The path correction node will
then be able to notify the motion
planning node
• The hardware control can have
independent units to control the
hardware like wheel, arms, joints, or
anything else. Drivers are needed to
control these motors.
• The drivers are controlled from the
main control loop node
• Position data coming back from
motor encoders is sent back to the
control loop for precise control and
is also published by the state
publisher node
• The motion planning node will
send the computed trajectories to
the main control loop node
• To complete the architecture, the
hardware state of the robot is
published
• And both the motion planning
node and path correction node are
listening to this message (from
state publisher)
ROS Nodes - Summary
• Processes that perform computation, which is a subprogram of your
application, that is responsible for ONE thing
• Nodes are combined into a graph and communicate with each other
using ROS communication tools such as topics, services, and
parameter server
ROS Nodes – Summary / Benefit
1. Reduce code complexity
• do not waste time fixing lengthy codes! Spend time coding new
functionalities)
2. Fault tolerance
• Nodes are not directly linked
• If one node crashes, it will not make other nodes crash
• This is great for debugging
• Example, say there is a critical node running your hardware that is well-
tested, and you just added a new node (for more feature). If the new node
crashes, the crash will not affect the critical hardware node
3. Language agnostics – python, c++
Programming Nodes in Python

• Create scripts folder inside my_robot_tutorials package


• Create a python script called my_first_node.py
• Give the file executable permission
• rospy has many methods such as
init_node, loginfo, and sleep
• Always initialize the node
• Save and run the code
• If you get the error “unable to
register with master node.. “, it
means you forgot to have a terminal
running roscore..
• Otherwise it should print the loginfo
• Rate function is in Hz unit
• 10 Hz = 0.1 second
• While the node is not shutdown, we
continue to loop every 0.1 second

• Ctrl+C to kill
• Run the code again (do not kill it)
• Open a new terminal and run rosnode list
• /my_first_python_node --- because python code is running
• /rosout ---- because roscore is running
• Two terminals cannot run the same node
Programming Nodes in C++

• Cannot run directly


like python
• Must create cpp
executables
Executables CPP
• Make catkin
again
• Run cpp
following the
executable
address
• Try this!

• Check out if the cpp code running

You might also like