机器人ros
To get into the field of Robotics, ROS is very crucial when it comes to building a robot. It is not exactly an Operating system but a meta Operating system that makes your work really easy by leveraging all the years of work that people all around the world have contributed to. There is a reason why everybody loves open-source. It makes your work easy by providing you for plugins for most of the crucial tasks that can get extremely iterative and monotonous at a point, thus making you be more focused on the task of dealing with a new problem using robotics and not on the trivial task that has already been done a million times earlier. In other words, it lets you train the team rather than focusing on building the ground.
要进入机器人技术领域,ROS在构建机器人方面至关重要。 它不完全是一个操作系统,而是一个元操作系统,它可以利用世界各地的人们多年来的贡献而使您的工作变得非常轻松。 每个人都喜欢开源是有原因的。 通过为大多数关键任务提供插件,使您的工作变得轻松,这些关键任务在某个时刻可能变得极其反复和单调,从而使您更加专注于使用机器人技术处理新问题的任务,而不是琐碎的任务已经做了一百万次了。 换句话说,它使您可以训练团队,而不必专注于建立地面。
If you haven’t already set up your ROS based environment I would recommend you to refer to my previous article that shows exactly how to do that.
如果您尚未设置基于ROS的环境,则建议您参考我的上一篇文章,该文章确切地显示了如何执行此操作。
To get started with this there are several terms that you will hear when you try to learn ROS. Let's understand them one by one.
首先,当您尝试学习ROS时会听到几个术语。 让我们一一理解它们。
- Roscore 罗斯可
- Nodes节点数
- Topic话题
- Messages留言内容
- Publisher发行人
- Subscriber订户
- Service服务
- Client客户
- Parameter server参数服务器
pub-sub体系结构(The pub-sub architecture)
Let’s take for example the popular cabs service Uber
让我们以受欢迎的出租车服务Uber为例
Consider yourself to be a node that is trying to call a cab. A cab driver is a node who is trying to get a customer. But without the uber app, you both won’t be able to connect to each other. In this example, you being the node named “customer1” is going to broadcast a topic called “cab ride” to the uber mobile application which in ROS analogous to Roscore, a central node that manages all the nodes. Similarly, the cab driver being another node broadcast the same topic named “cab ride” and the Uber app (Roscore) receives both the messages, matches the topic name and eventually, a connection is established between you, the customer, and the cab driver, the service provider. Here the cab driver will be publishing the topic and you being the customer will be subscribing to the topic.
将自己视为试图打出租车的节点。 出租车司机是试图吸引客户的节点。 但是如果没有uber应用,则您将无法彼此连接。 在此示例中,您作为名为“ customer1”的节点将向uber移动应用程序广播一个名为“ cab ride”的主题,该应用程序在ROS中类似于Roscore(管理所有节点的中央节点)。 同样,出租车司机是另一个节点,广播相同的主题,名为“ cab ride”,而Uber应用程序(Roscore)接收到两条消息,匹配主题名称,最终,您,客户和出租车司机之间建立了连接。 ,服务提供商。 在这里,出租车司机将发布主题,而您作为客户将订阅该主题。
This was for your better understanding. Now, let’s take a real case scenario.
这是为了让您更好地理解。 现在,让我们看一个真实的案例。
I have a sensor node and a visualizer node. The sensor node can publish the information it is receiving from a camera and the visualizer node is capable of subscribing to the topic related to such information and will visualize this information on the screen. The information is passed using a standard message predefined either by the community or by the individual developer developing the project.
我有一个传感器节点和一个可视化器节点。 传感器节点可以发布它从相机接收的信息,并且可视化器节点可以订阅与此类信息有关的主题,并将在屏幕上可视化该信息。 使用社区或开发项目的单个开发人员预定义的标准消息传递信息。
主题和消息之间的区别。 (The difference between the topic and a message.)
Let’s take the Uber example again. The topic was named “cab ride”. But there has to be some information that needs to be passed, some details within that topic. such as What is the starting and the destination point. What is the charges to the ride This all will be contained in the message associated with that topic and it varies with time. This means that a topic is an abstract concept and is there to encapsulate the message.
让我们再次以Uber为例。 该主题被称为“驾驶室”。 但是必须传递一些信息,该主题中的一些细节。 例如起点和终点是什么。 乘车收费是多少这一切将包含在与该主题相关的消息中,并且随时间而变化。 这意味着主题是一个抽象概念,可以用来封装消息。
now let’s go to the formal definition of each one of them
现在让我们来看一下其中每个的正式定义
1. Nodes — A node is an executable that uses ROS to communicate with other nodes.
1.节点-节点是使用ROS与其他节点通信的可执行文件。
2. Topic — A named bus, a pipe between nodes through which the messages flow. It is a collection of messages
2.主题-命名总线,即节点之间的管道,消息通过该管道流动。 它是消息的集合
3. Messages — The predefined format of information that is exchanged between the nodes.
3.消息-节点之间交换的信息的预定义格式。
4. Parameter Server -The parameter server (like a chalk box) is typically used to store parameters and configuration values that are shared amongst the running node. Its like the memory accessible to all the nodes.
4.参数服务器-参数服务器(如粉笔盒)通常用于存储在运行节点之间共享的参数和配置值。 就像所有节点都可以访问的内存一样。
5. Roscore — A central or master node provided by the ROS that manages all the other nodes.
5. Roscore — ROS提供的中央或主节点,用于管理所有其他节点。
主流程(Roscore) (The Master process (Roscore))
is responsible for the following (and more):
负责以下(以及更多):
Providing naming and registration services to other running nodes
为其他正在运行的节点提供命名和注册服务
Tracking all publishers and subscribers
跟踪所有发布者和订阅者
Aggregating log messages generated by the nodes
聚合节点生成的日志消息
Facilitating connections between nodes
促进节点之间的连接
服务客户端架构(Service-client architecture)
In service client architecture the Client is analogous to the subscriber and the service is analogous to the publisher but it’s not exactly the same.
在服务客户端体系结构中,客户端类似于订户,而服务类似于发布者,但并不完全相同。
It’s not like pub-sub as in service-client architecture, the service will not only send the data but also process it before sending it. In the pub-sub architecture, the camera node is receiving just a call with no instructions, and the camera node is just publishing the raw image.
这与服务客户端体系结构中的pub-sub不同,该服务不仅会发送数据,还会在发送数据之前对其进行处理。 在pub-sub体系结构中,摄影机节点仅接收不带指令的呼叫,摄影机节点仅发布原始图像。
In the service client architecture, the camera node is receiving some instructions to process the image say convert RGB2GreyScale image and the server needs to first process the image and then only send the image to the client node.
在服务客户端体系结构中,相机节点正在接收一些指令以处理图像,例如转换RGB2GreyScale图像,服务器需要首先处理图像,然后仅将图像发送到客户端节点。
使用的所有命令列表 (List of all the commands used)
Note — mast run all these commands in a new terminal.
注意—在新的终端中桅杆运行所有这些命令。
roscore
— to start the master process.
roscore
—启动主进程。
rosrun turtlesim turtlesim_node
— commanding the turtle to draw on the screen.
rosrun turtlesim turtlesim_node
—命令海龟在屏幕上绘制。
rosrun turtlesim turtle_teleop_key — to use the arrow keys to move the turtle.
rosrun turtlesim turtle_teleop_key-使用箭头键移动乌龟。
rosnode list
— to list all the running nodes on all the terminals running ROS.
rosnode list
—在运行ROS的所有终端上列出所有正在运行的节点。
rostopic list
— to list all the running nodes on all the terminals running ROS.
rostopic list
—在运行ROS的所有终端上列出所有正在运行的节点。
rostopic info /turtle1/cmd_vel
— Getting information about topics
rostopic info /turtle1/cmd_vel
—获取有关主题的信息
rosmsg info geometry_msgs/Twist
— Showing message information in detail
rosmsg info geometry_msgs/Twist
—详细显示消息信息
rosed geometry_msgs Twist.msg.
rosed geometry_msgs Twist.msg.
rostopic echo /turtle1/cmd_vel
— Echoing messages in real-time
rostopic echo /turtle1/cmd_vel
—实时回显消息
Step by step commands to follow through with us and describe what going on.
逐步执行命令以跟我们并描述发生的情况。
Let’s look at the tasks one by one
让我们一一看一下这些任务
启动主节点(Starting the master node)
Now run the master node in a terminal
现在在终端中运行主节点
roscore
roscore
启动turtlesim节点 (Starting the turtlesim node)
Now when the master is running, run the turtlesim nodes. Open a new terminal and run
现在,当主服务器运行时,运行turtlesim节点。 打开一个新的终端并运行
rosrun turtlesim turtlesim_node
rosrun turtlesim turtlesim_node
where turtlesim is the name of the ros package containing the turtlesim node. turtlesim_node is the name of the node executable residing in the package you wish to run
其中turtlesim是包含turtlesim节点的ros软件包的名称。 turtlesim_node是您要运行的程序包中驻留的节点可执行文件的名称。
To move the turtle you need another node in the next terminal
要移动乌龟,您需要在下一个终端中另一个节点
rosrun turtlesim turtle_teleop_key
rosrun turtlesim turtle_teleop_key
where turtlesim is the package and turtle_teleop_key is the name of the executable node now use the arrow keys to move the turtle
其中turtlesim是软件包, turtle_teleop_key是可执行节点的名称,现在使用箭头键移动turtle
注意:如果您忘记了节点的名称,那么在这种情况下,双标签完成功能将非常有用。 (NOTE: if you ever forget the name of the node, then double-tab completion feature is very useful in this scenario.)
列出所有活动节点 (Listing all active nodes)
rosnode list
rosnode列表
We can see that there are three active nodes that have been registered with the ROS Master, /rosout, /teleop_turtle, and /turtlesim.
我们可以看到,已经向ROS Master,/ rosout,/ teleop_turtle和/ turtlesim注册了三个活动节点。
1. /rosout This node is launched by roscore. It subscribes to the standard /rosout topic, the topic to which all nodes send log messages.
1. / rosout该节点由roscore启动。 它订阅了标准/ rosout主题,所有节点都向该主题发送日志消息。
2. /teleop_turtle This is our keyboard teleop node. Notice that it’s not named turtle_teleop_key. There’s no requirement that a node’s broadcasted name is the same as the name of it’s associated executable.
2. / teleop_turtle这是我们的键盘Teleop节点。 请注意,它没有命名为turtle_teleop_key。 不需要节点的广播名称与其关联的可执行文件的名称相同。
2. /turtlesim The node name associated with the turtlebot_sim node
2. / turtlesim与turtlebot_sim节点关联的节点名称
列出所有主题(Listing all topics)
rostopic list
rostopic列表
/rosout_agg
Aggregated feed of messages published to /rosout.
/rosout_agg
汇总到/ rosout的消息的摘要。
/turtle1/cmd_vel
Topic upon which velocity commands are sent/received. Publishing a velocity message to this topic will command turtle1 to move.
/turtle1/cmd_vel
在其上发送/接收速度命令的主题。 向该主题发布速度消息将命令turtle1移动。
/turtle1/color_sensor Each turtle in turtlesim is equipped with a color sensor, and readings from the sensor are published to this topic.
/ turtle1 / color_sensor turtlesim中的每只海龟都配备有颜色传感器,并且该传感器的读数将发布到该主题。
/turtle1/pose
The position and orientation of turtle1 are published to this topic.
/turtle1/pose
的位置和方向已发布到该主题。
了解主题信息 (Knowing the information of the topic)
To know which nodes are publishing or subscribing to a topic or what types of messages are being passed around
了解哪些节点正在发布或订阅某个主题,或者正在传递哪些类型的消息
To get such information use the command “rostopic info (name of the topic)”
要获取此类信息,请使用命令“ rostopic info(主题名称)”
rostopic info /turtle1/cmd_vel
rostopic info /turtle1/cmd_vel
As would be expected, there are two nodes registered on this topic. Our publisher, the teleop_turtle node, and our subscriber, the turtlesim node. Additionally, we can see that the type of message used on this topic is geometry_msgs/Twist.
不出所料,在此主题上注册了两个节点。 我们的发布者,teleop_turtle节点,我们的订阅者,turtlesim节点。 此外,我们可以看到在该主题上使用的消息类型为geometry_msgs / Twist。
了解消息的信息 (Knowing the information of the message)
name of the package containing the message- geometry_msgs name of the message type — Twist
包含消息的程序包名称-geometry_msgs消息类型的名称-Twist
rosmsg show geometry_msgs/Twist
rosmsg show geometry_msgs/Twist
Twist message consists of nothing more than two Vector3 messages. One for linear velocity, and another for angular velocities, with each velocity component being represented by a float64.
Twist消息仅包含两个Vector3消息。 一个用于线速度,另一个用于角速度,每个速度分量由float64表示。
To know everything you may wish to know about the message use the command “rosed”. Its a bash command to simply view and edit the file in your Ros environment
要了解有关该消息的所有信息,请使用命令“ rosed”。 它是一个bash命令,可在您的Ros环境中简单地查看和编辑文件
rosed geometry_msgs Twist.msg.
rosed geometry_msgs Twist.msg.
A file will be opened and this gives us access to the comments and the definition of the message. Ros developer who created the message clarified in the comments what’s the purpose of the message.
将打开一个文件,这使我们可以访问注释和消息的定义。 创建该消息的Ros开发人员在注释中阐明了该消息的目的。
回应主题信息 (Echo-ing the message on a topic)
To look at a topic’s published messages in real-time use “rostopic echo
要实时查看主题的已发布消息,请使用“ rostopic echo <主题名称>”命令
rostopic echo /turtle1/cmd_vel
rostopic echo /turtle1/cmd_vel
Then command the turtle to move(the turtle) from the turtle_teleop_key window, we will be able to see the output message in real-time.
然后命令乌龟从turtle_teleop_key窗口移动(乌龟),我们将能够实时查看输出消息。
Well, apparently these are the basic building block of ROS and is very essential to get started with it. You can also visit the official ROS website and read their tutorials for beginners. It is one of the most extensive and easy to read the documentation on ROS. You can practice the basic content and then you will be all ready to build your own robotic application according to your need. If you want to follow along you can star this Github repository for more robotics content related to Computer Vision, SLAM, 3 D Perception, Navigation, and much more. I am constantly updating it for more resources and if you want to get notified remember to start the repository and follow me on GitHub as well.
好吧,显然,这些是ROS的基本组成部分,对于开始使用它非常重要。 您也可以访问ROS官方网站,并阅读初学者的教程。 它是最广泛,最容易阅读的ROS文档之一。 您可以练习基本内容,然后就可以根据需要准备好自己的机器人应用程序了。 如果您想继续学习,可以给这个Github存储库加注星标,以获得更多与Computer Vision,SLAM,3D Perception,Navigation等相关的机器人技术内容。 我会不断更新它以获取更多资源,如果您想得到通知,请记住启动存储库并在GitHub上关注我。
翻译自: https://medium.com/analytics-vidhya/basics-of-robotics-in-ros-8c9a56d24c6
机器人ros