std_msgs/Empty and std_srv_msgs/Empty

本文探讨了ROS中两种特殊的Empty消息类型:std_msgs/Empty 和 std_srv_msgs/Empty。这两种消息类型通常用于发送触发信号,例如在发布者/订阅者模型中仅触发某个事件而不需要传递具体数据。文章通过C++和Python示例展示了如何使用std_msgs/Empty来实现无人机起飞指令。

It is interesting and aslo necessary to disscuss about the two types in ROS, std_msgs/Empty and std_srv_msgs/Empty.

The two message type are indicating there are nothing to transmit but a trigger signal.

In a Publisher / Subscriber use case, std_msgs/Empty could be useful when we only want to trigger an event.

For example,

in C++:

#include <std_msgs/Empty.h>

int main(int argc, char **argv){

    init(argc, argv, "takeoff_fly");
    Nodehandle n;
    std_msg::Empty myMsg;
    Publisher takeOff=n.advertise<std_msgs::Empty>("/ardrone/takeoff",1);
    takeOff.publish(myMsg);
    spinOnce();

    return 0;
}

in Python:

from std_msgs.msg import Empty as EmptyMsg
takeOff = rospy.Publisher('/ardrone/takeoff', EmptyMsg, queue_size=1)

...

转载于:https://www.cnblogs.com/casperwin/p/8339363.html

@j-VMware-Virtual-Platform:~$ ros2 topic info /scan --verbose Type: sensor_msgs/msg/LaserScan Publisher count: 1 Node name: rplidar_composition Node namespace: / Topic type: sensor_msgs/msg/LaserScan Topic type hash: RIHS01_64c191398013af96509d518dac71d5164f9382553fce5c1f8cca5be7924bd828 Endpoint type: PUBLISHER GID: 01.0f.54.ad.4b.0e.81.e6.00.00.00.00.00.00.14.03 QoS profile: Reliability: RELIABLE History (Depth): UNKNOWN Durability: VOLATILE Lifespan: Infinite Deadline: Infinite Liveliness: AUTOMATIC Liveliness lease duration: Infinite Subscription count: 2 Node name: _ros2cli_3699 Node namespace: / Topic type: sensor_msgs/msg/LaserScan Topic type hash: RIHS01_64c191398013af96509d518dac71d5164f9382553fce5c1f8cca5be7924bd828 Endpoint type: SUBSCRIPTION GID: 01.0f.54.ad.73.0e.fd.6e.00.00.00.00.00.00.07.04 QoS profile: Reliability: RELIABLE History (Depth): UNKNOWN Durability: VOLATILE Lifespan: Infinite Deadline: Infinite Liveliness: AUTOMATIC Liveliness lease duration: Infinite Node name: slam_toolbox Node namespace: / Topic type: sensor_msgs/msg/LaserScan Topic type hash: RIHS01_64c191398013af96509d518dac71d5164f9382553fce5c1f8cca5be7924bd828 Endpoint type: SUBSCRIPTION GID: 01.0f.54.ad.ba.0e.b0.e5.00.00.00.00.00.00.44.04 QoS profile: Reliability: BEST_EFFORT History (Depth): UNKNOWN Durability: VOLATILE Lifespan: Infinite Deadline: Infinite Liveliness: AUTOMATIC Liveliness lease duration: Infinite j@j-VMware-Virtual-Platform:~$ @j-VMware-Virtual-Platform:~$ ros2 topic list /clock /map /map_metadata /parameter_events /pose /rosout /scan /slam_toolbox/feedback /slam_toolbox/graph_visualization /slam_toolbox/scan_visualization /slam_toolbox/transition_event /slam_toolbox/update /tf /tf_static j@j-VMware-Virtual-Platform:~$ ros2 topic echo /map --no-arr
最新发布
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值