ros中標誌位設計(4)
阿新 • • 發佈:2018-12-30
由於需要涉及控制權的交接事件,需要通過標誌位的方式進行設計。
首先需要自定一個標誌位的資訊在ros中用於標誌位資訊的釋出。
下面是用於標誌位的標頭檔案Flag.h
// Generated by gencpp from file xx_msgs/Flag.msg // DO NOT EDIT! #ifndef XX_MSGS_MESSAGE_FLAG_H #define XX_MSGS_MESSAGE_FLAG_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> namespace xx_msgs { template <class ContainerAllocator> struct Flag_ { typedef Flag_<ContainerAllocator> Type; Flag_() : flag() { } Flag_(const ContainerAllocator& _alloc) : flag(_alloc) { (void)_alloc; } typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _flag_type; _flag_type flag; typedef boost::shared_ptr< ::xx_msgs::Flag_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::xx_msgs::Flag_<ContainerAllocator> const> ConstPtr; }; // struct Flag_ typedef ::xx_msgs::Flag_<std::allocator<void> > Flag; typedef boost::shared_ptr< ::xx_msgs::Flag > FlagPtr; typedef boost::shared_ptr< ::xx_msgs::Flag const> FlagConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::xx_msgs::Flag_<ContainerAllocator> & v) { ros::message_operations::Printer< ::xx_msgs::Flag_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace xx_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False} // {'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'xx_msgs': ['/home/xx/commonspace/ship_ws/src/xx_msgs/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::xx_msgs::Flag_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::xx_msgs::Flag_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::xx_msgs::Flag_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::xx_msgs::Flag_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::xx_msgs::Flag_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::xx_msgs::Flag_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::xx_msgs::Flag_<ContainerAllocator> > { static const char* value() { return "1042664ff3b165ca1987ef393c5212a5"; } static const char* value(const ::xx_msgs::Flag_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x1042664ff3b165caULL; static const uint64_t static_value2 = 0x1987ef393c5212a5ULL; }; template<class ContainerAllocator> struct DataType< ::xx_msgs::Flag_<ContainerAllocator> > { static const char* value() { return "xx_msgs/Flag"; } static const char* value(const ::xx_msgs::Flag_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::xx_msgs::Flag_<ContainerAllocator> > { static const char* value() { return "string flag\n\ "; } static const char* value(const ::xx_msgs::Flag_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::xx_msgs::Flag_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.flag); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct Flag_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::xx_msgs::Flag_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::xx_msgs::Flag_<ContainerAllocator>& v) { s << indent << "flag: "; Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.flag); } }; } // namespace message_operations } // namespace ros #endif // XX_MSGS_MESSAGE_FLAG_H