Go to the documentation of this file.00001 """autogenerated by genpy from nasa_r2_common_msgs/ForceControlAxis.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007
00008 class ForceControlAxis(genpy.Message):
00009 _md5sum = "e8efe484fba93bec26ea428bb18a05f9"
00010 _type = "nasa_r2_common_msgs/ForceControlAxis"
00011 _has_header = False
00012 _full_text = """uint8[] axis
00013 float32[] magnitude
00014
00015 uint8 X = 0
00016 uint8 Y = 1
00017 uint8 Z = 2
00018 uint8 ROLL = 3
00019 uint8 PITCH = 4
00020 uint8 YAW = 5
00021
00022 """
00023
00024 X = 0
00025 Y = 1
00026 Z = 2
00027 ROLL = 3
00028 PITCH = 4
00029 YAW = 5
00030
00031 __slots__ = ['axis','magnitude']
00032 _slot_types = ['uint8[]','float32[]']
00033
00034 def __init__(self, *args, **kwds):
00035 """
00036 Constructor. Any message fields that are implicitly/explicitly
00037 set to None will be assigned a default value. The recommend
00038 use is keyword arguments as this is more robust to future message
00039 changes. You cannot mix in-order arguments and keyword arguments.
00040
00041 The available fields are:
00042 axis,magnitude
00043
00044 :param args: complete set of field values, in .msg order
00045 :param kwds: use keyword arguments corresponding to message field names
00046 to set specific fields.
00047 """
00048 if args or kwds:
00049 super(ForceControlAxis, self).__init__(*args, **kwds)
00050
00051 if self.axis is None:
00052 self.axis = ''
00053 if self.magnitude is None:
00054 self.magnitude = []
00055 else:
00056 self.axis = ''
00057 self.magnitude = []
00058
00059 def _get_types(self):
00060 """
00061 internal API method
00062 """
00063 return self._slot_types
00064
00065 def serialize(self, buff):
00066 """
00067 serialize message into buffer
00068 :param buff: buffer, ``StringIO``
00069 """
00070 try:
00071 _x = self.axis
00072 length = len(_x)
00073
00074 if type(_x) in [list, tuple]:
00075 buff.write(struct.pack('<I%sB'%length, length, *_x))
00076 else:
00077 buff.write(struct.pack('<I%ss'%length, length, _x))
00078 length = len(self.magnitude)
00079 buff.write(_struct_I.pack(length))
00080 pattern = '<%sf'%length
00081 buff.write(struct.pack(pattern, *self.magnitude))
00082 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00083 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00084
00085 def deserialize(self, str):
00086 """
00087 unpack serialized message in str into this message instance
00088 :param str: byte array of serialized message, ``str``
00089 """
00090 try:
00091 end = 0
00092 start = end
00093 end += 4
00094 (length,) = _struct_I.unpack(str[start:end])
00095 start = end
00096 end += length
00097 self.axis = str[start:end]
00098 start = end
00099 end += 4
00100 (length,) = _struct_I.unpack(str[start:end])
00101 pattern = '<%sf'%length
00102 start = end
00103 end += struct.calcsize(pattern)
00104 self.magnitude = struct.unpack(pattern, str[start:end])
00105 return self
00106 except struct.error as e:
00107 raise genpy.DeserializationError(e)
00108
00109
00110 def serialize_numpy(self, buff, numpy):
00111 """
00112 serialize message with numpy array types into buffer
00113 :param buff: buffer, ``StringIO``
00114 :param numpy: numpy python module
00115 """
00116 try:
00117 _x = self.axis
00118 length = len(_x)
00119
00120 if type(_x) in [list, tuple]:
00121 buff.write(struct.pack('<I%sB'%length, length, *_x))
00122 else:
00123 buff.write(struct.pack('<I%ss'%length, length, _x))
00124 length = len(self.magnitude)
00125 buff.write(_struct_I.pack(length))
00126 pattern = '<%sf'%length
00127 buff.write(self.magnitude.tostring())
00128 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00129 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00130
00131 def deserialize_numpy(self, str, numpy):
00132 """
00133 unpack serialized message in str into this message instance using numpy for array types
00134 :param str: byte array of serialized message, ``str``
00135 :param numpy: numpy python module
00136 """
00137 try:
00138 end = 0
00139 start = end
00140 end += 4
00141 (length,) = _struct_I.unpack(str[start:end])
00142 start = end
00143 end += length
00144 self.axis = str[start:end]
00145 start = end
00146 end += 4
00147 (length,) = _struct_I.unpack(str[start:end])
00148 pattern = '<%sf'%length
00149 start = end
00150 end += struct.calcsize(pattern)
00151 self.magnitude = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00152 return self
00153 except struct.error as e:
00154 raise genpy.DeserializationError(e)
00155
00156 _struct_I = genpy.struct_I