def myhook():
print "shutdown time!"
rospy.on_shutdown(myhook)


rospy.signal_shutdown(reason)
  • 初始化节点关闭
  • reason 为关闭理由,字符串内容。

例子:

#!/usr/bin/env python
import rospy
import math
import sys
from tf import transformations
from geometry_msgs.msg import PoseWithCovarianceStamped
class PoseSetter(rospy.SubscribeListener):
def __init__(self, pose):
self.pose = pose
def peer_subscribe(self, topic_name, topic_publish, peer_publish):
p = PoseWithCovarianceStamped()
print("hh")
p.header.frame_id = "map"
p.pose.pose.position.x = self.pose[]
p.pose.pose.position.y = self.pose[]
(p.pose.pose.orientation.x,
p.pose.pose.orientation.y,
p.pose.pose.orientation.z,
p.pose.pose.orientation.w) = transformations.quaternion_from_euler(, , self.pose[])
p.pose.covariance[*+] = 0.5 * 0.5
p.pose.covariance[*+] = 0.5 * 0.5
p.pose.covariance[*+] = math.pi/12.0 * math.pi/12.0
peer_publish(p)
print("ll")
rospy.signal_shutdown("closed!") x=True
print("dd")
pose = [-9.983256,-2.641909,-1.201580]#x,y,a
rospy.init_node('pose_setter', anonymous=True)
if(x):
print("tt")
pub=rospy.Publisher("initialpose", PoseWithCovarianceStamped,PoseSetter(pose),queue_size=)
x=False
else:
print("x=False")
print("ff")
rospy.spin()
print("pp")

python ros 关闭节点的更多相关文章

  1. python ros 创建节点订阅robot_pose

    建立文件夹hello_rospy,再在该目录下建立子目录src,cd到该src目录,运行如下命令创建工作包 catkin_create_pkg beginner_tutorials std_msgs ...

  2. 理解ROS的节点(NODE)

    经过前面的学习,我们已经知道了如何构建一个ROS的包,这篇博客将介绍ROS中的节点的概念. 在继续之前,请按ctrl+alt+t打开一个终端,在里面输入: sudo apt-get install r ...

  3. ROS 进阶学习笔记(13) - Combine Subscriber and Publisher in Python, ROS

    Combine Subscriber and Publisher in Python, ROS This article will describe an example of Combining S ...

  4. [Flex] 组件Tree系列 —— 打开和关闭节点

    mxm: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:打开和关闭节点--> < ...

  5. ROS向节点传递参数

    ROS的节点有很多中调用方式,包括rosrun,launch,直接运行等,向节点内传递参数的方式也有很多. 1. rosrun + 参数服务器传递 ros::init(argc, argv, &quo ...

  6. Python - 记录我开始学习Python的时间节点

    记录我开始学习Python的时间节点 2019-09-22 从明天开始我要开始学习Python了,坚持学习.坚持写博客,慢慢积累. 结合实例项目,最好能把目前在做的项目用Python实现. 加油!

  7. (六)ROS话题---节点之间通信的方式

    1. 理解 ROS 话题: (Ctrl+Alt+T 打开一个新终端) 运行下面的命令: $ roscore (Ctrl+Alt+T 打开一个新终端) $ rosrun turtlesim turtle ...

  8. python ros topic demo

    发布者: #!/usr/bin/env python #coding=utf- import rospy from std_msgs.msg import String def talker():   ...

  9. python ros 订阅imu数据,实时显示欧拉角

    #!/usr/bin/env python # -*- coding: utf- -*- import rospy import math from sensor_msgs.msg import Im ...

随机推荐

  1. 使用pssh进行并行批量操作

    假如同时给上千台服务器执行一个命令,拷贝一个文件,杀一个进程等,有什么简化运维管理的工具呢?在小型使用中我都是使用for循 环,数量巨大,一方面不确定操作是否成功,一方面for循环语句性能不好估计且是 ...

  2. svn 常见问题记录

    One or more files are in a conflicted state 情景:A组员新增文件并提交,B组员更新出现如下图情况. 解决方案:直接拷贝到B组员工作区.

  3. [LeetCode] 787. Cheapest Flights Within K Stops_Medium tag: Dynamic Programming, BFS, Heap

    There are n cities connected by m flights. Each fight starts from city u and arrives at v with a pri ...

  4. [LeetCode] questions conclustion_Path in Tree

    Path in Tree: [LeetCode] 112. Path Sum_Easy tag: DFS       input: root, target,   return True if exi ...

  5. Windows程序自启动方法汇总

    文件夹 一.当前用户专有的启动文件夹 二.对所有用户有效的启动文件夹 三.Load注册键 四.Userinit注册键 五.Explorer\Run注册键 六.RunServicesOnce注册键 七. ...

  6. js值类型和引用类型的区别

    1:赋值 值类型的赋值:直接将存储的数据赋值一份进行赋值,两份数据在内存中是完全独立的. 引用类型赋值:引用类型的赋值的时候,是将变量中的存储的地址赋值一份单独存储,但是两个变量中修改其中一个对象,另 ...

  7. 003-ubuntu上安装mysql

    安装如下: 1.安装服务端:# sudo apt-get  install mysql-server. 2.安装客户端:# sudo apt-get -y install mysql-server. ...

  8. 浅谈EM算法的两个理解角度

    http://blog.csdn.net/xmu_jupiter/article/details/50936177 最近在写毕业论文,由于EM算法在我的研究方向中经常用到,所以把相关的资料又拿出来看了 ...

  9. MySQL从删库到跑路_高级(七)——事务和锁

    作者:天山老妖S 链接:http://blog.51cto.com/9291927 一.事务简介 1.事务简介 事务(Transaction)是指作为单个逻辑工作单元执行的一系列操作. 2.事物的特效 ...

  10. 20154312《网络对抗》Exp2 后门原理与实践

    常见问题快速链接 Handler failed to bind to xxx.xxx.xx.xxx:xxxx 使用Webcam_snap命令提示1411错误,无法正常拍照 常用后门工具实践 Windo ...