ros 编译包含脚本文件以及launch文件
目录结构如下:

修改CMakeLists.txt文件
install(PROGRAMS
scripts/initial_pos.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
initial_pos.launch文件内容:
<launch>
<node pkg="bp_initialpos" name="initial_pos" type="initial_pos.py" output="screen">
</node>
</launch>
initial_pos.py文件内容:
#!/usr/bin/env python
import rospy
import tf
import time
from tf.transformations import *
from std_msgs.msg import String
from geometry_msgs.msg import Pose
from geometry_msgs.msg import Quaternion
filenm="/opt/bp/tmp"
tms=
tp_x=0.0
tp_y=0.0
tp_a=0.0
i=tms
def get_pos(data):
global tp_x
global tp_y
global tp_a
global i
global tms
(roll, pitch, yaw) = euler_from_quaternion([data.orientation.x, data.orientation.y, data.orientation.z, data.orientation.w])
if(i==):
rospy.loginfo("current position(x:%f,y:%f),theta:%f", data.position.x, data.position.y, yaw)
if(tp_x==round(data.position.x,)):
if(tp_y==round(data.position.y,)):
if(tp_a==round(yaw,)):
rospy.loginfo("still!")
else:
with open(filenm, 'w+') as f:
f.write(str(data.position.x)+","+str(data.position.y)+","+str(yaw))
rospy.loginfo("write!")
else:
with open(filenm, 'w+') as f:
f.write(str(data.position.x)+","+str(data.position.y)+","+str(yaw))
rospy.loginfo("write!")
else:
with open(filenm, 'w+') as f:
f.write(str(data.position.x)+","+str(data.position.y)+","+str(yaw))
rospy.loginfo("write!")
i=tms
tp_x=round(data.position.x,)
tp_y=round(data.position.y,)
tp_a=round(yaw,)
i=i-
#rospy.loginfo("current position(x:%f,y:%f,z:%f)", data.position.x, data.position.y, data.position.z) def poslistener():
# In ROS, nodes are uniquely named. If two nodes with the same
# name are launched, the previous one is kicked off. The
# anonymous=True flag means that rospy will choose a unique
# name for our 'listener' node so that multiple listeners can
# run simultaneously.
rospy.init_node('poslistener', anonymous=True) rospy.Subscriber("robot_pose", Pose, get_pos) # spin() simply keeps python from exiting until this node is stopped
rospy.spin() if __name__ == '__main__':
poslistener()
ros 编译包含脚本文件以及launch文件的更多相关文章
- ROS Learning-010 beginner_Tutorials 编写简单的启动脚本文件(.launch 文件)
ROS Indigo beginner_Tutorials-09 编写简单的启动脚本文件 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu 14.0 ...
- ROS学习笔记六:xxx.launch文件详解
每当我们需要运行一个ROS节点或工具时,都需要打开一个新的终端运行一个命令.当系统中的节点数量不断增加时,每个节点一个终端的模式会变得非常麻烦.那么有没有一种方式可以一次性启动所有节点呢?答案当然是肯 ...
- 4.2 ROS节点运行管理launch文件
4.2 ROS节点运行管理launch文件 关于 launch 文件的使用我们已经不陌生了,在第一章内容中,就曾经介绍到: 一个程序中可能需要启动多个节点,比如:ROS 内置的小乌龟案例,如果要控制乌 ...
- python ros 使用launch文件启动脚本
目录结构 在包里面新建scripts文件夹,里面放运行的脚本文件,记得设置执行权限 然后新建launch文件夹,新建launch文件按照如下格式写: <node pkg="initia ...
- ROS启动多launch文件
在ROS工程中经常需要启动好几个launch文件,比较不方便,有下面两种方法可以更高效些: 重写一个大型的launch文件,将所有的节点的启动配置信息都包含进去. 通过bash写一个xxx.sh文件, ...
- ROS Learning-032 (提高篇-010 Launch)Launch 深入研究 --- (启动文件编程)ROS 的 XML语法简介
ROS 提高篇 之 Launch 深入研究 - 01 - 启动文件的编程 - ROS 的 XML语法简介 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubu ...
- (八) .launch文件 ---编写简单的启动脚本文件
下面我们将介绍,如何编写一个启动脚本程序:(.launch文件) 还记得我们在 创建ROS软件包教程 中创建的第一个程序包(beginner_tutorials)吗,现在我们要使用它. 在 begin ...
- ROS launch 文件的编写
ROS提供了一个同时启动节点管理器(master)和多个节点的途径,即使用启动文件(launch file).事实上,在ROS功能包中,启动文件的使用是非常普遍的.任何包含两个或两个以上节点的系统都可 ...
- Ros学习——launch文件解析
launch文件的重点是:节点(node)元素的集合. roslaunch 则是让所有的节点共享同一个终端. 1.标签(元素)说明 1. group标签 2. node标签 <group ns= ...
随机推荐
- SVM计算过程,对偶形式,核函数
SVM是一个分类方法,用w^X+b定义分类函数, 于是求w.b,为寻最大间隔,引出1/2||w||^2,继而引入拉格朗日因子,化为对单一因数对偶变量a的求解(求解过程中会涉及到一系列最优化或凸二 次规 ...
- 移动端1px细线解决方案总结
现在的PM和UI总以看app的眼光看html5, html页面要做的专业美观,而且必须很精细. 去年的时候UI就告诉我h5上的边框线太粗,把整站都给拉low了. 当时工期紧就没太在意1px粗细, 好在 ...
- mysql表空间文件
1.共享表空间文件.默认表空间文件是ibdata1,大小为10M,且可拓展.共享表空间可以由多个文件组成,一个表可以跨多个文件而存在,共享表空间的最大值限制是64T. 2.独立表空间文件.独立表空间只 ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON MirrorImage
zw版[转发·台湾nvp系列Delphi例程]HALCON MirrorImage procedure TForm1.Button1Click(Sender: TObject);var img, im ...
- http://xx.xxx.xxx.xx:8080/把路径设置成http服务访问的形式
1.官网下载python安装包(eg:python-3.6.3-embed-win32),并解压文件 2.配置环境变量 3.cmd里查看python版本并设置服务路径 4. 访问查看
- Linux服务器配置---ntp
配置ntp ntp就是网络时间同步的服务,时间的准确性非常重要,很多数据在记录时都要知道准确的时间.网上有很多站点,一般国内会设置匹配中科院国家授时中心的时间. 1.安装ntp软件 [root ...
- php抛出异常
php抛出异常:throw new Exception("xxxxxx!"); 实例代码: try{ if ($mysqli->connect_errno) { sleep( ...
- 又一国产855旗舰突然现身:支持5G
12月28日消息,中国联通官方微博放出了vivo NEX 5G版样机.如图所示,该机搭载骁龙855移动平台及X50 5G调制解调器. 早在8月30日,vivo就宣布完成了面向商用5G智能手机的软硬件开 ...
- nginx服务器的rewrite功能
nginx编译的时候默认是把rewrite功能编辑进去的,但是因为rewrite需要使用正则表达式,因此需要安装pcre依赖包. yum install -y pcre pcre-install re ...
- 一个远程启动windows c++程序引发的技术决策现象
还是因为那个8点半前要启动近百套报盘程序的问题,差不多两周前表示自己会抽空给解决掉,一次性启动,直到昨天才差不多能够抽点时间出来开始想怎么解决的问题. 这个问题的复杂点在于除了启动exe外,还需要鼠标 ...