实操 | std_msgs/Empty and std_srv_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)
...