[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
Ros node启动与关闭
1. ros运行单位:
Ros程序运行的单位是ros node。
2. ros 节点的启动:
(1)初始化ros节点:通过调用ros::init()接口实现;可以通过参数指定默认节点名字,之所以是默认,是因为在命令行执行程序时,是可以修改节点名字的。
(2)启动ros节点:通过调用ros::NodeHnadle创建NodeHnadle实例nh实现,第一次创建实例时,会调用ros::start(),此时启动本节点。
3. ros节点关闭:
(1)通过调用ros::shutdown()接口,关闭ros节点,此接口会关闭订阅话题、发布话题、请求服务以及提供服务。
(2)在最后一个ros::NodeHnadle对象销毁时,会自动调用ros::shutdown(),以此关闭ros节点。
4. 检测ros节点是否已经关闭:
(1)ros::ok()接口:返回false,说明节点已经关闭。
(2)ros::isShuttingDown()接口:返回true,说明ros::shutdown()被调用,但是节点比一定结束。
注:所以一般使用ros::ok()判断,但是在不会结束的节点,例如“ prolonged service
callback”中,则只能使用ros::isShuttingDown(),因为此节点不会关闭,疑惑这是什么节点?
5. 中断:
(1)在ros::init()选项中,有一选项ros::init_options::NoSigintHandler,决定是否安装默认SIGINT处理函数,若不带此参数,则安装,程序在收到SIGINT信号(ctrl+c)时,ros::ok()返回false,节点可以走关闭流程。若带此参数,需要自己安装SIGINT处理函数,以保证节点可以结束。