Core ROS Tutorials (二)
Learning English well
1. What did you do on your first day at your university?
I can’t really remember. After all, it was a long time a ago. I think the first thing I did was that I went through the Orientation for new arrivals. The orientation took me half a day. Then I got settled in my dorm. Then, I registered for some classes and went to the student center. Where I met a nice senior who walked me through all the details we needed to know, such as campus safety and meal plans. He even offered some tips on how to get a high GPA.
2. Leave the darkness of your past behind, so you can focus letting in the light of your future.
3. Time would heal almost all wounds. If your wounds have not been healed up, please wait for a short while.
4. Time will not help us solve problems. It just makes problems we can’t originally figure out no more important.
Beginner Level
11. Writing a Simple Publisher and Subscriber (C++)
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29
Writing the Publisher Node:
- Initialize the ROS system
-
Advertise that we are going to be publishing std_msgs/String messages on the chatter topic to the master
-
Loop while publishing messages to chatter 10 times a second
Writing the Subscriber Node
- Initialize the ROS system
-
Subscribe to the chatter topic
- Spin, waiting for messages to arrive
-
When a message arrives, the chatterCallback() function is called
12. Writing a Simple Publisher and Subscriber (Python)
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29
Python code
#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String
def talker():
pub = rospy.Publisher('chatter', String, queue_size=10)
rospy.init_node('talker', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
hello_str = "hello world %s" % rospy.get_time()
rospy.loginfo(hello_str)
pub.publish(hello_str)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass
13. Examining the Simple Publisher and Subscriber
http://wiki.ros.org/ROS/Tutorials/ExaminingPublisherSubscriber
roscore
# In your catkin workspace $ cd ~/catkin_ws $ source ./devel/setup.bash
$ rosrun beginner_tutorials talker (C++)
$ rosrun beginner_tutorials talker.py (Python)
$ rosrun beginner_tutorials listener (C++)
$ rosrun beginner_tutorials listener.py (Python)
14. Writing a Simple Service and Client (C++)
http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28c%2B%2B%29
15. Writing a Simple Service and Client (Python)
http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28python%29
16. Examining the Simple Service and Client
http://wiki.ros.org/ROS/Tutorials/ExaminingServiceClient
$ rosrun beginner_tutorials add_two_ints_server (C++)
$ rosrun beginner_tutorials add_two_ints_server.py (Python)
$ rosrun beginner_tutorials add_two_ints_client 1 3 (C++)
$ rosrun beginner_tutorials add_two_ints_client.py 1 3 (Python)
17. Recording and playing back data
http://wiki.ros.org/ROS/Tutorials/Recording%20and%20playing%20back%20data
18. Getting started with roswtf
http://wiki.ros.org/ROS/Tutorials/Getting%20started%20with%20roswtf
19. Navigating the ROS wiki
http://wiki.ros.org/ROS/Tutorials/NavigatingTheWiki
20. Where Next?
http://wiki.ros.org/ROS/Tutorials/WhereNext
Important:
At this point in the beginner's tutorials you should have an understanding of the core concepts of ROS.
Given a robot that runs ROS, you could use this understanding to list topics published and subscribed by the robot, to identify the messages consumed by these topics and then write your own nodes that process sensor data and act in the world.
The real attraction of ROS is not the publish/subscribe middle-ware itself but that ROS provides a standard mechanism for developers around the world to share their code. The best "feature" of ROS is its enormous community.
The number of packages available can be overwhelming. This tutorial attempts to give you an idea of what to explore next.
Launching a Simulator
Even if you have a real robot, it is good to get started using a simulator so that if something goes wrong you don't injure yourself or damage an expensive robot.
You can get started with the PR2 Simulator or the Turtlebot Simulator. Alternately, you might search for your robot and check whether it has a simulator of its own.
At this point, you might try to control the simulated robot using a 'teleop' package (e.g., turtlebot_teleop) or use your understanding of ROS to find a topic and write code that sends an appropriate message to drive your robot.
Exploring RViz
RViz is a powerful visualization tool that allows you to view the robot's sensors and internal state. The user guide will help you get started.
Understanding TF
The TF package transforms between different coordinate frames used by your robot and keeps track of these transforms over time. A good understanding of TF is essential when working with any real robot. It is worthwhile to work through the tutorials.
If you're building your own robot, you might at this point consider constructing a URDF model for your robot. If you're using a "standard" robot then one has probably already being built for you. Nevertheless, it may be worthwhile to briefly familiarize yourself with the URDF package.
Going Deeper
At this point, you're probably ready to start getting your robot to perform more sophisticated tasks. The following pages may help you:
-
actionlib - The actionlib package provides a standardized interface for interfacing with preemptible tasks. This is widely used by "higher-level" packages in ROS.
-
navigation - 2D navigation: map-building and path planning.
-
MoveIt - To control the arms of your robot.