Project

General

Profile

Statistics
| Branch: | Revision:

root / scout / power / src / power / msg / _power_state_changed.py @ dd4eb68c

History | View | Annotate | Download (6.37 KB)

1
"""autogenerated by genmsg_py from power_state_changed.msg. Do not edit."""
2
import roslib.message
3
import struct
4

    
5
import std_msgs.msg
6

    
7
class power_state_changed(roslib.message.Message):
8
  _md5sum = "fc98f58bb6056947bbbbbad6cc36490a"
9
  _type = "power/power_state_changed"
10
  _has_header = True #flag to mark the presence of a Header object
11
  _full_text = """Header header
12
#32-bit integer with current voltage info
13
uint32 voltage
14
#power percentage [0-100]
15
uint32 percentage
16
#current draw in mW
17
uint32 draw
18
#are we on external power?
19
bool externalpower
20
#is the battery at a warning state?
21
bool warning
22
#is the battery at a critical state?
23
bool critical
24

25

26
================================================================================
27
MSG: std_msgs/Header
28
# Standard metadata for higher-level stamped data types.
29
# This is generally used to communicate timestamped data 
30
# in a particular coordinate frame.
31
# 
32
# sequence ID: consecutively increasing ID 
33
uint32 seq
34
#Two-integer timestamp that is expressed as:
35
# * stamp.secs: seconds (stamp_secs) since epoch
36
# * stamp.nsecs: nanoseconds since stamp_secs
37
# time-handling sugar is provided by the client library
38
time stamp
39
#Frame this data is associated with
40
# 0: no frame
41
# 1: global frame
42
string frame_id
43

44
"""
45
  __slots__ = ['header','voltage','percentage','draw','externalpower','warning','critical']
46
  _slot_types = ['Header','uint32','uint32','uint32','bool','bool','bool']
47

    
48
  def __init__(self, *args, **kwds):
49
    """
50
    Constructor. Any message fields that are implicitly/explicitly
51
    set to None will be assigned a default value. The recommend
52
    use is keyword arguments as this is more robust to future message
53
    changes.  You cannot mix in-order arguments and keyword arguments.
54
    
55
    The available fields are:
56
       header,voltage,percentage,draw,externalpower,warning,critical
57
    
58
    @param args: complete set of field values, in .msg order
59
    @param kwds: use keyword arguments corresponding to message field names
60
    to set specific fields. 
61
    """
62
    if args or kwds:
63
      super(power_state_changed, self).__init__(*args, **kwds)
64
      #message fields cannot be None, assign default values for those that are
65
      if self.header is None:
66
        self.header = std_msgs.msg._Header.Header()
67
      if self.voltage is None:
68
        self.voltage = 0
69
      if self.percentage is None:
70
        self.percentage = 0
71
      if self.draw is None:
72
        self.draw = 0
73
      if self.externalpower is None:
74
        self.externalpower = False
75
      if self.warning is None:
76
        self.warning = False
77
      if self.critical is None:
78
        self.critical = False
79
    else:
80
      self.header = std_msgs.msg._Header.Header()
81
      self.voltage = 0
82
      self.percentage = 0
83
      self.draw = 0
84
      self.externalpower = False
85
      self.warning = False
86
      self.critical = False
87

    
88
  def _get_types(self):
89
    """
90
    internal API method
91
    """
92
    return self._slot_types
93

    
94
  def serialize(self, buff):
95
    """
96
    serialize message into buffer
97
    @param buff: buffer
98
    @type  buff: StringIO
99
    """
100
    try:
101
      _x = self
102
      buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
103
      _x = self.header.frame_id
104
      length = len(_x)
105
      buff.write(struct.pack('<I%ss'%length, length, _x))
106
      _x = self
107
      buff.write(_struct_3I3B.pack(_x.voltage, _x.percentage, _x.draw, _x.externalpower, _x.warning, _x.critical))
108
    except struct.error, se: self._check_types(se)
109
    except TypeError, te: self._check_types(te)
110

    
111
  def deserialize(self, str):
112
    """
113
    unpack serialized message in str into this message instance
114
    @param str: byte array of serialized message
115
    @type  str: str
116
    """
117
    try:
118
      if self.header is None:
119
        self.header = std_msgs.msg._Header.Header()
120
      end = 0
121
      _x = self
122
      start = end
123
      end += 12
124
      (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
125
      start = end
126
      end += 4
127
      (length,) = _struct_I.unpack(str[start:end])
128
      start = end
129
      end += length
130
      self.header.frame_id = str[start:end]
131
      _x = self
132
      start = end
133
      end += 15
134
      (_x.voltage, _x.percentage, _x.draw, _x.externalpower, _x.warning, _x.critical,) = _struct_3I3B.unpack(str[start:end])
135
      self.externalpower = bool(self.externalpower)
136
      self.warning = bool(self.warning)
137
      self.critical = bool(self.critical)
138
      return self
139
    except struct.error, e:
140
      raise roslib.message.DeserializationError(e) #most likely buffer underfill
141

    
142

    
143
  def serialize_numpy(self, buff, numpy):
144
    """
145
    serialize message with numpy array types into buffer
146
    @param buff: buffer
147
    @type  buff: StringIO
148
    @param numpy: numpy python module
149
    @type  numpy module
150
    """
151
    try:
152
      _x = self
153
      buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
154
      _x = self.header.frame_id
155
      length = len(_x)
156
      buff.write(struct.pack('<I%ss'%length, length, _x))
157
      _x = self
158
      buff.write(_struct_3I3B.pack(_x.voltage, _x.percentage, _x.draw, _x.externalpower, _x.warning, _x.critical))
159
    except struct.error, se: self._check_types(se)
160
    except TypeError, te: self._check_types(te)
161

    
162
  def deserialize_numpy(self, str, numpy):
163
    """
164
    unpack serialized message in str into this message instance using numpy for array types
165
    @param str: byte array of serialized message
166
    @type  str: str
167
    @param numpy: numpy python module
168
    @type  numpy: module
169
    """
170
    try:
171
      if self.header is None:
172
        self.header = std_msgs.msg._Header.Header()
173
      end = 0
174
      _x = self
175
      start = end
176
      end += 12
177
      (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
178
      start = end
179
      end += 4
180
      (length,) = _struct_I.unpack(str[start:end])
181
      start = end
182
      end += length
183
      self.header.frame_id = str[start:end]
184
      _x = self
185
      start = end
186
      end += 15
187
      (_x.voltage, _x.percentage, _x.draw, _x.externalpower, _x.warning, _x.critical,) = _struct_3I3B.unpack(str[start:end])
188
      self.externalpower = bool(self.externalpower)
189
      self.warning = bool(self.warning)
190
      self.critical = bool(self.critical)
191
      return self
192
    except struct.error, e:
193
      raise roslib.message.DeserializationError(e) #most likely buffer underfill
194

    
195
_struct_I = roslib.message.struct_I
196
_struct_3I = struct.Struct("<3I")
197
_struct_3I3B = struct.Struct("<3I3B")