Core ROS Tutorials (三)

Learning english well:

 1. Life is thickly sown with thorns, and there is no other remedy but pass quickly through them with your beautiful smile and heart.

 2. Not everything that is faced can be changed, but nothing can be changed until it is faced.

 3. Take time to deliberate, but when the time for action has arrived, stop thinking and go.

 4. If you are fine,the sun will always shine.

 5. We must accept finite disappointment, but we must never lose infinite hope. -- Mattin Luther King

 6. When you wake up in the morning, set a goal that today you must be better than yesterday. Do it everyday, grow better!

 7. The greatest test of courage on earth is to bear defeat without losing heart.

 8. The world is like a mirror: frown at it and it frowns at you; smile, and it smiles too.

 9. No matter how hard it is, just keep going because you only fail when you give up.

 10. When you have choices, choose the best. When you have no choice, do your best.

 11. There's a crack in everything.That's how the light gets in.

 12. freshman sophomore junior senior undergraduate candidate for doctor's degree   overseas student

 13. Sometimes you gotta shut up, swallow your pride and accept that you're wrong. It's not giving up. It's called growing up.

 14. To give up is easy. But to hold it together when everyone else thinks you'd fall apart is so difficult.

 15. The good life is one inspired by love and guided by knowledge.

 16. The future belongs to those who believe in the beauty of their dreams. 

 17. Life is like a cup of tea. It won't be bitter for a lifetime but for a short while anyway.

 18. Make the person mature is not the time, but the experience. subway tasted, through the nature; through the world, see light the world. 

 19. There is no heart hurt by pursuing dream. When you long for something sincerely,the whole world will help you. 

 20. Sometime you just have to hold your head up high, blink away the tears and say good-bye. 

ROS introduction:

ROS (Robot Operating System) provides libraries and tools to help software developers create robot applications. It provides hardware abstraction,device drivers, libraries, visualizers, message-passing, package management, and more. ROS is licensed under an open source, BSD license.

 

 

1. INTRO TO THE ROBOT OPERATING SYSTEM (https://www.clearpathrobotics.com/2014/01/how-to-guide-ros-101/)

Instead  (http://www.clearpathrobotics.com/assets/guides/ros/Intro%20to%20the%20Robot%20Operating%20System.html)

 

WHAT IS ROS?

ROS (Robot Operating System) is a BSD-licensed system for controlling robotic components from a PC. A ROS system is comprised of a number of independent nodes, each of which communicates with the other nodes using a publish/subscribe messaging model. For example, a particular sensor’s driver might be implemented as a node, which publishes sensor data in a stream of messages. These messages could be consumed by any number of other nodes, including filters, loggers, and also higher-level systems such as guidance, pathfinding, etc.

 

WHY ROS?

Note that nodes in ROS do not have to be on the same system (multiple computers) or even of the same architecture! You could have a Arduino publishing messages, a laptop subscribing to them, and an Android phone driving motors. This makes ROS really flexible and adaptable to the needs of the user. ROS is also open source, maintained by many people.

 

 

General Concepts 

ROS starts with the ROS Master. The Master allows all other ROS pieces of software (Nodes) to find and talk to each other. That way, we do not have to ever specifically state “Send this sensor data to that computer at 127.0.0.1. We can simply tell Node 1 to send messages to Node 2.


Note: How do Nodes do this? By publishing and subscribing to Topics.

 

Let’s say we have a camera on our Robot. We want to be able to see the images from the camera, both on the Robot itself, and on another laptop.

 

In our example, we have a Camera Node that takes care of communication with the camera, a Image Processing Node on the robot that process image data,and a Image Display Node that displays images on a screen. To start with, all Nodes have registered with the Master. Think of the Master as a lookup table where all the nodes go to find where exactly to send messages.

In registering with the ROS Master, the Camera Node states that it will Publish a Topic called /image_data (for example). Both of the other Nodes register that they are Subscribed to the Topic /image_data.

Thus, once the Camera Node receives some data from the Camera, it sends the /image_data message directly to the other two nodes. (Through what is essentially TCP/IP)

Now you may be thinking, what if I want the Image Processing Node to request data from the Camera Node at a specific time? To do this, ROS implements Services.

A Node can register a specific service with the ROS Master, just as it registers its messages. In the below example, the Image Processing Node first requests /image_data, the Camera Node gathers data from the Camera, and then sends the reply.

 

Good resource about ROS(Robot Operating System) (http://www.clearpathrobotics.com/assets/guides/ros/)

 

2. Getting Started with Ubuntu

       (http://www.clearpathrobotics.com/assets/guides/ros/Getting%20Started%20with%20Ubuntu.html)

1. To learn how to use ROS, we must first learn the basics of Ubuntu! Ubuntu is a Linux based open source operating system.

2. The bulk of development will be done using the terminal. 

3. Here are some of the most used commands

CommandDescription
ls Lists files and folders
cd <folder> Change the working directory to <folder>
pwd Prints the current working directory
cp <src><dest> Copies <src> to <dest>
sudo Executes the command as the root user
mkdir<directory> Creates a directory in your working directory named <directory>
gedit or nano <file> Opens a text editor to edit <file>

      very important:

                                     To install a package:  sudo apt-get install  

      ROS packages will be named ros-. For example, to install the Clearpath Robotics Indigo Husky packages 

                                     sudo apt-get install ros-indigo-husky-desktop

3Practical Example  (http://www.clearpathrobotics.com/assets/guides/ros/Practical%20Example.html)

command:  rostopic pub /hello std_msgs/String “Hello Robot"

break down the parts of that command

 

 rostopic pub – This commands ROS to publish a new topic.

/hello – This is the name of the new topic. (Can be whatever you want)

std_msgs/String – This is the topic type. We want to publish a string topic. In our overview examples above, it was an image data type.

“Hello Robot” – This is the actual data contained by the topic. I.E. the message itself.

Testing command: rostopic echo /hello.  return "data: Hello Robot"

4. Drive a Husky  http://www.clearpathrobotics.com/assets/guides/ros/Drive%20a%20Husky.html

        Open a terminal window (Ctrl + Alt + T), and enter the following:

sudo apt-get update
sudo apt-get install ros-indigo-husky-desktop
sudo apt-get install ros-indigo-husky-simulator

 

 open new terminal window   roslaunch husky_gazebo husky_empty_world.launch

 open another terminal window   roslaunch husky_viz view_robot.launch

 

We can now command the robot to go forwards. Open a terminal window, and use the command below, copy pasting this one won’t work! You can tab complete this command by hitting the tab key after geometry_msgs/Twist:

rostopic pub /husky_velocity_controller/cmd_vel geometry_msgs/Twist "linear:
        x: 0.5
        y: 0.0
        z: 0.0
angular:
        x: 0.0
        y: 0.0
        z: 0.0" -r 10 

You can also see the structure of how topics are passed around the system.  Leave the publishing window running, and open a terminal window. Type in:  

                                                                                             rosrun rqt_graph rqt_graph 

Using tf

In ROS, tf is a special topic that keeps track of coordinate frames, and how they relate to each other. So, our simulated Husky starts at (0,0,0) in the world coordinate frame. When the Husky moves, it’s own coordinate frame changes. Each wheel has a coordinate frame that tracks how it is rotating, and where it is. Generally, anything on the robot that is not fixed in space, will have a tf describing it. In the rqt_graph section, you can see that the /tf topic is published to and subscribed from by many different nodes.

One intuitive way to see how the tf topic is structured for a robot is to use the view_frames tool provided by ROS. Open a terminal window. Type in:

rosrun tf view_frames

         Wait for this to complete, and then type in:      evince frames.pdf

 

 

 

 

 

 

posted @ 2018-09-18 11:51  三才  阅读(305)  评论(0编辑  收藏  举报