mo1、ROS now includes software for tasks ranging from navigation and localization (SLAM),3D object recognition, action planning, motion control for multi-jointed arms, machine learning and even playing billiards.

2、第一部分的学习按照ros wiki http://wiki.ros.org/ROS/Tutorials
2.1ROS filesystem
rospack allows you to get information about packages.

2.2Creating a ROS Package创建一个ROS包
2.2.1创建一个catkin包

(1)首先创建一个catkin工作空间
http://wiki.ros.org/catkin/Tutorials/create_a_workspace
source /opt/ros/indigo/setup.bash
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ..
catkin_make
source devel/setup.bash
(2)其次创建catkin包
cd ~/catkin_ws/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
(3)Building a catkin workspace and sourcing the setup file
cd ~/catkin_ws
catkin_make
. ~/catkin_ws/devel/setup.bash(这是必须的一步add the workspace to your ROS environment you need to source the generated setup file:)

rospack depends1 rospy(std_msgs roscpp rospy创建的时候的第一个)
rospack depends rospy

2.3 Build a ROS package
Before continuing remember to source your environment setup file if you have not already每次创建ROS包的时候,要先改变一下环境变量。
source /opt/ros/indigo/setup.bash
cd ~/catkin_ws
mkdir build
cd build
cmake ..
make
sudo make install
或者catkin_make

2.4理解ROS节点和roscore, rosnode, and rosrun 等命令行的使用

Nodes can publish or subscribe to a Topic. Nodes can also provide or use a Service.
2.4.1常用命令
1、roscore is the first thing you should run when using ROS.
2、rosnode displays information about the ROS nodes that are currently running.
2.1 The rosnode list command lists these active nodes:
rosnode list
2.2 The rosnode info command returns information about a specific node.
rosnode info /rosout

3、rosrun allows you to use the package name to directly run a node within a package (without having to know the package path).

$ rosrun [package_name] [node_name]

rosrun turtlesim turtlesim_node


按Ctrl+c结束进程。

http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics
4、理解ROS的主题(ROS topic)(rqt-graph)
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

The turtlesim_node and the turtle_teleop_key node are communicating with each other over a ROS Topic. turtle_teleop_key is publishing the key strokes on a topic, while turtlesim subscribes to the same topic to receive the key strokes.

rosrun rqt_graph rqt_graph


当我们把鼠标放在/turtle1/cmd_vel上时,会发现ROS节点(/turtlesim和/teleop_turtle)通过主题(turtle1/cmd_vel)通讯。

5、ROS messages
Communication on topics happens by sending ROS messages between nodes.

rostopic type /turtle1/cmd_vel [rostopic type [topic]] 话题的类型
rosmsg show geometry_msgs/Twist 【rosmsg show [type]】具体的信息

用法:rostopic pub [topic] [msg_type] [args]
rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist – ‘[2.0, 0.0, 0.0]’ ‘[0.0, 0.0, 1.8]’

The previous command will send a single message to turtlesim telling it to move with an linear velocity of 2.0, and an angular velocity of 1.8 .

6、rosservice的应用(http://wiki.ros.org/ROS/Tutorials/UnderstandingServicesParams)

Services are another way that nodes can communicate with each other. Services allow nodes to send a request and receive a response.

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
rosservice list
rosservice type /clear
rosservice call /clear(清除turtlesim之前的轨迹)

rosservice type /spawn |rossrv show
rosservice call /spawn 2 2 0.2 ” ”

6.1 rosparam的应用
(1)rosparam list (list parameter names)

(2)rosparam set [param_name]
rosparam get [param_name]
rosparam set /background_r 150
rosservice call /clear(This changes the parameter value, now we have to call the clear service for the parameter change to take effect: )
执行完之后会有背景颜色的变化。

7、rqt_console和roslaunch
we use rqt_console and rqt_logger_level for debugging and roslaunch for starting many nodes at once。
我们使用rqt_console和rqt_logger_level来做调试。
使用roslaunch来一次性的启动多个节点。
7.1第一步:在两个terminal里面分别输入
rosrun rqt_console rqt_console
rosrun rqt_logger_level rqt_logger_level

这个时候启用turtlesim节点,rosrun turtlesim turtlesim_node

执行完这一句会发现rqt_console上一直在报警。rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 – ‘{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}’
(注意点:在rqt_loggers上显示出新的节点,最右端warn下refresh)

roslaunch to bring up multiple turtlesim nodes and a mimicking node to cause one turtlesim to mimic(模仿) another.下面来学习roslaunch.
7.2roslaunch(http://wiki.ros.org/ROS/Tutorials/UsingRqtconsoleRoslaunch)


这里是一定要注意的,在没有 source the environment 的情况下是不可能roscd beginner_tutorials的,下次一定要注意这个问题。

cd ~/catkin_ws
source devel/setup.bash
roscd beginner_tutorials

mkdir launch
touch turtlemimic.launch
gedit turtlemimic.launch

这时候编辑launch文件

Here we start two groups with a namespace tag of turtlesim1 and turtlesim2 with a turtlesim node with a name of sim. This allows us to start two simulators without having name conflicts. (group部分是给两个turtlesim定义两个名字,这样他们模仿的时候不会出现命名冲突。)

Here we start the mimic node with the topics input and output renamed to turtlesim1 and turtlesim2. This renaming will cause turtlesim2 to mimic turtlesim1. (把主题的输入改成turtlesim1,输出改成turtlesim2,可以让那个turtlesim2模仿turtlesim1)

roslaunch beginner_tutorials turtlemimic.launch

rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 – ‘[2.0, 0.0, 0.0]’ ‘[0.0, 0.0, -1.8]’
这个指令是对turtle1来实现的,但是turtle2也跟着一起运动。

这个时候在终端输入rqt_graph可得:

8、创建一个ROS的信息和服务(Creating a ROS msg and srv)
msg: msg files are simple text files that describe the fields of a ROS message.
srv: an srv file describes a service. It is composed of two parts: a request and a response.
http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv

9、Writing a Simple Publisher and Subscriber (python)
用python写一个简单的发布者和订阅者程序。
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29

cd ~/catkin_ws
source devel/setup.bash
roscd beginner_tutorials
mkdir scripts
cd scripts
wget https://raw.github.com/ros/ros_tutorials/kinetic-devel/rospy_tutorials/001_talker_listener/talker.py
chmod +x talker.py

1 #!/usr/bin/env python (每个Python的ROS节点都要在开头声明这一句,这一句保证了是以python脚本来实现的)
2 # license removed for brevity
3 import rospy
4 from std_msgs.msg import String
5
6 def talker():
7 pub = rospy.Publisher(‘chatter’, String, queue_size=10)
8 rospy.init_node(‘talker’, anonymous=True)
9 rate = rospy.Rate(10) # 10hz
10 while not rospy.is_shutdown():
11 hello_str = “hello world %s” % rospy.get_time()
12 rospy.loginfo(hello_str)
13 pub.publish(hello_str)
14 rate.sleep()
15
16 if name == ‘main‘:
17 try:
18 talker()
19 except rospy.ROSInterruptException:
20 pass

用python订阅节点。
cd ~/catkin_ws
source devel/setup.bash
roscd beginner_tutorials/scripts/
wget https://raw.github.com/ros/ros_tutorials/kinetic-devel/rospy_tutorials/001_talker_listener/listener.py
chmod +x listener.py
下面两部是一定要执行的,因为这在空间里面build your nodes.
cd ~/catkin_ws
catkin_make

代码详细片段:
1 #!/usr/bin/env python
2 import rospy
3 from std_msgs.msg import String
4
5 def callback(data):
6 rospy.loginfo(rospy.get_caller_id() + “I heard %s”, data.data)
7
8 def listener():
9
10 # In ROS, nodes are uniquely named. If two nodes with the same
11 # node are launched, the previous one is kicked off. The
12 # anonymous=True flag means that rospy will choose a unique
13 # name for our ‘listener’ node so that multiple listeners can
14 # run simultaneously.
15 rospy.init_node(‘listener’, anonymous=True)
16
17 rospy.Subscriber(“chatter”, String, callback)
18
19 # spin() simply keeps python from exiting until this node is stopped
20 rospy.spin()
21
22 if name == ‘main‘:
23 listener()

10、Writing a Simple Service and Client (Python)
10.1 Service
cd ~/catkin_ws
source devel/setup.bash
roscd beginner_tutorials/scripts
touch add_two_ints_server.py
gedit add_two_ints_server.py
cd ..
chmod +x scripts/add_two_ints_server.py(make the node executable)


这里我们声明了一个名为add_Two_ints_server的Service, 类型为AddTwoInts,所有的处理都交给handle_add_two_ints.

10.2 Clients
接着server的那部分,

cd scripts/
touch add_two_ints_client.py
gedit add_two_ints_client.py

cd ..
chmod +x scripts/add_two_ints_client.py

move_base运行之前需要4个配置文件,

ros wiki learning相关推荐

  1. ROS wiki教程翻译

    对于ROS非初学者:如果你已经熟悉了ROS  fuerte 或者早期的版本 ,并且仅仅想要探索新类型的构建系统groovy 并且用过hydro及以后的版本catkin,你可以进入更深入的学习教程cat ...

  2. 【ROS wiki】ros wiki官方教程与ROS wiki页面检索

    ROS wiki系列文章简介:ROS wiki系列文章是本人ROS专栏下的子专题.该系列文章主要用来介绍:ROS初学者如何利用好ROS官方提供的ROS wiki平台,来查询ROS资料,了解ROS包的功 ...

  3. ROS wiki系列|ROS入门基础概念讲解

    上一期我们对ROS wiki中ROS部分进行了着重讲解,回顾戳这 这一期我们主要介绍ROS-getting started部分的一些基本概念 相关wiki页面:http://wiki.ros.org/ ...

  4. ROS wiki系列|Documentation-ROS部分讲解

    上一篇文章介绍了ROS wiki的大体结构,回顾戳→ROS wiki系列|ROS wiki初探 接下来的内容就是分模块介绍啦,首先是重头戏Documentation中的ROS部分,上一篇文章讲到这部分 ...

  5. ROS wiki系列|ROS wiki初探(自用)

    在进行ROS学习的过程中,我们总是需要借助一些资料来进行学习,其中,ROS wiki是每个ROS人都必不可少会使用到的工具,在ROS学习中我们也经常要使用ROS wiki来查阅一些语法的解析.功能包的 ...

  6. 【ROS wiki】ros wiki导航页面解析

    ROS wiki系列文章简介:ROS wiki系列文章是本人ROS专栏下的子专题.该系列文章主要用来介绍:ROS初学者如何利用好ROS官方提供的ROS wiki平台,来查询ROS资料,了解ROS包的功 ...

  7. ROS wiki系列|通过ROS wiki-tutorials学习节点

    前面几期我们讲的都是一些入门相关的内容-- ROS wiki系列|ROS wiki初探(自用) ROS wiki系列|Documentation-ROS部分讲解 ROS wiki系列|ROS入门基础概 ...

  8. ROS wiki系列|在ROSwiki中查找特定内容(以launch为例)

    Hello朋友们!最后一期了当然是要来点实际的~前面教了大家那么多内容你们也该学会自己在ROS wiki里找找自己想看的内容啦 But--ROS wiki真的好多,页面跳转又很复杂,搜索框又用不了,咋 ...

  9. 【ROS wiki】ros wiki中查阅常见的消息类型

    ROS wiki系列文章简介:ROS wiki系列文章是本人ROS专栏下的子专题.该系列文章主要用来介绍:ROS初学者如何利用好ROS官方提供的ROS wiki平台,来查询ROS资料,了解ROS包的功 ...

最新文章

  1. EBGAN, LSGAN, BEGAN
  2. 你真的会vue-router吗?
  3. 2017年高级二级计算机考试试题,2017年计算机二级高级Office考试试题操作题
  4. Spring中的BeanPostProcessor接口
  5. js表单验证控制代码大全
  6. 后台返回给前端json字段的大小写问题,Lombok的坑
  7. nextpolish安装_「三代组装」使用Pilon对基因组进行polish
  8. Node.js -- Router模块中有一个param方法
  9. Python3网络爬虫开发实战分析Ajax爬取今日头条街拍美图
  10. Gcc:gcc -o操作
  11. 应届生简历如何写实习经历?
  12. leetcode 14天算法入门 C语言实现
  13. 3D游戏建模概念设计流程
  14. 论文引用文献并插入编号
  15. 清华大学计算机科学系王瑀屏,清华大学材料科学与工程系
  16. python往npy写入数据_Python 存取npy格式数据实例
  17. 【论文笔记】 Leverage Lexical Knowledge Base for Chinese NER via Collborative Graph Network
  18. 骆昊python100天百度云_GitHub - Luffy-cc/Python-100-Days: Python - 100天从新手到大师
  19. [乡土民间故事_徐苟三传奇]第八回_张财主误喊“你来看”
  20. matlab磁铁模拟,用matlab 模拟环形磁铁的磁场分布

热门文章

  1. 国家级、省级认定(备案)科技企业孵化器、众创空间奖励申请指南
  2. acrobat给pdf加多行水印_批量pdf如何添加水印 多个pdf批量加相同水印的方法|支持同时添加文字、图片水印...
  3. autocad2019设置为经典模式
  4. 云计算:数据中心之虚拟机
  5. 【代理设置】Linux Windows 系统下各工具设置代理方式笔记(整理中)
  6. asp环境配置,以及serv_u,dreamware的使用,
  7. LeTex 常用操作
  8. UC优视创始人何小鹏:移动互联网不得不看的5个大坑
  9. 威客、众包、沃客、创易网群殴,中国创意交易网谁是老大?
  10. Fabric配置fabric-sample工程目录,并生成证书