ROS Concept and Practice Part 1
ROS Concept and Practice Part 1
• 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
• 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++