You are on page 1of 36

Robot operating system

An autonomous robot
Advantages of ROS
• reusability of the program
• communication-based program
• support of development tools
• active community
• formation of the ecosystem
Robot operating system
• Session 1(5.00-6.15pm):Lecture on
– Linux file commands
– Introduction to python
– Running python in linux system
• Session 2(6.15-8.00pm): Practice session

• Important announcement:
– From tomorrow class starts at 6.30pm
https://youtu.be/HbgzrKJvDRw
cat >myf.txt
Hi thism y file
Ctrl+d
cat myf.txt

cat mf1.txt mf2.txt >N.txt


~ - /home/user/
Nano commands
• ^-ctrl key ,M-alt key
• Ma – select
• ^6-unselect
• M6-copy
• ^u-paste
• ^k-cut
ROS commands
• roslaunch <package_name> <launch_file>
• roscd <package_name>
• catkin_create_pkg <package_name>
<package_dependecies>
ROS commands
• rospack list
• rospack list | grep my_package
Node program
#! /usr/bin/env python
import rospy
rospy.init_node(‘myNode1')
print “This is my node"
Node program
#! /usr/bin/env python
import rospy
rospy.init_node(‘myNode1')
rate = rospy.Rate(2)
while not rospy.is_shutdown():
print "Help me Obi-Wan Kenobi, you're my only
hope"
rate.sleep()
.launch file
<launch>
<!-- My Package launch file -->
<node pkg= "bit" type= "pubnode.py" name=
"Bitan_pub_node" output="screen">
</node>
</launch>
Compile a package
• catkin_make
• catkin_make --only-pkg-with-deps
<package_name>
• rosnode list
• rosnode info /ObiWan
• rosparam list
• rosparam get <parameter_name>
• rosparam set <parameter_name> <value>
• roscore
• export | grep ROS
Publisher node
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
rospy.init_node('topic_publisher')
pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
rate = rospy.Rate(2)
count = Twist()
count.linear.x = 0
while not rospy.is_shutdown():
pub.publish(count)
count.linear.x=1.0
rate.sleep()
3.water

1.Pump

2.Pipe
3.Water
(Message)

1.Pump
(Publisher)

2.Pipe
(Topic)
• Message- information that is transmitted from
one node to another
• Publisher – node which publishes a message
• Topic – channel through which a publisher
publishes a message
• Publisher – rosnode list
• Topic – rostopic list
– rostopic info /counter
– rostopic echo /counter
– rostopic -h

• Message- rosmsg show <message>


– rosmsg show std_msgs/Int32
Do it yourself
Subscriber node
#! /usr/bin/env python
import rospy
from std_msgs.msg import Int32
def callback(msg):
print msg.data
rospy.init_node('topic_subscriber')
sub = rospy.Subscriber('counter', Int32, callback)
rospy.spin()
• rostopic echo /counter
• rostopic pub <topic_name> <message_type>
<value>
• rostopic pub /counter std_msgs/Int32 5
Do it yourself
Create a package that launches the code. Modify
the code in order to print the odometry of the
robot.
Note:
The odometry of the robot is published by the
robot into the /odom topic.
You will need to figure out what message uses the
/odom topic, and how the structure of this
message is.
Creating our own catkin space
• Old:
– ROS_PACKAGE_PATH="/home/simulations/public_
sim_ws/src:/opt/ros/kinetic/share“
• New:
– ROS_PACKAGE_PATH="/home/user/my_ck_ws/src
:/home/simulations/public_sim_ws/src:/opt/ros/k
inetic/share"
Creating own catkin space
• mkdir -p ~/<name_of _WS>/src
• catkin_init_workspace (inside src)
• catkin_make(inside WS)
• source ~/my_ck_ws/devel/setup.bash
Create your own message
• Age:
• Year,month,days
Create your own message
Services
Services-Hands on session
• Open a new Rosject in ROS Development studio with your
roll number as a name
• Create a catkin directory in home in your
name(ex:nandakumar_ws)
• Create a message of your choice (note: everybody should
have unique message. Don’t copy from other)
• Create a service using the procedure described in
services.pdf sent through whatsapp
• Create subscriber and publisher nodes using these message
and service
• Share your project and make a video and send it by
tomorrow session
• This will be taken for attendance and evaluation

You might also like