74 lines
2.8 KiB
Python
74 lines
2.8 KiB
Python
"""LCM type definitions
|
|
This file automatically generated by lcm.
|
|
DO NOT MODIFY BY HAND!!!!
|
|
"""
|
|
|
|
try:
|
|
import cStringIO.StringIO as BytesIO
|
|
except ImportError:
|
|
from io import BytesIO
|
|
import struct
|
|
|
|
class robot_control_response_lcmt(object):
|
|
__slots__ = ["mode", "gait_id", "contact", "order_process_bar", "switch_status", "ori_error", "footpos_error", "motor_error"]
|
|
|
|
__typenames__ = ["int8_t", "int8_t", "int8_t", "int8_t", "int8_t", "int8_t", "int16_t", "int32_t"]
|
|
|
|
__dimensions__ = [None, None, None, None, None, None, None, [12]]
|
|
|
|
def __init__(self):
|
|
self.mode = 0
|
|
self.gait_id = 0
|
|
self.contact = 0
|
|
self.order_process_bar = 0
|
|
self.switch_status = 0
|
|
self.ori_error = 0
|
|
self.footpos_error = 0
|
|
self.motor_error = [ 0 for dim0 in range(12) ]
|
|
|
|
def encode(self):
|
|
buf = BytesIO()
|
|
buf.write(robot_control_response_lcmt._get_packed_fingerprint())
|
|
self._encode_one(buf)
|
|
return buf.getvalue()
|
|
|
|
def _encode_one(self, buf):
|
|
buf.write(struct.pack(">bbbbbbh", self.mode, self.gait_id, self.contact, self.order_process_bar, self.switch_status, self.ori_error, self.footpos_error))
|
|
buf.write(struct.pack('>12i', *self.motor_error[:12]))
|
|
|
|
def decode(data):
|
|
if hasattr(data, 'read'):
|
|
buf = data
|
|
else:
|
|
buf = BytesIO(data)
|
|
if buf.read(8) != robot_control_response_lcmt._get_packed_fingerprint():
|
|
raise ValueError("Decode error")
|
|
return robot_control_response_lcmt._decode_one(buf)
|
|
decode = staticmethod(decode)
|
|
|
|
def _decode_one(buf):
|
|
self = robot_control_response_lcmt()
|
|
self.mode, self.gait_id, self.contact, self.order_process_bar, self.switch_status, self.ori_error, self.footpos_error = struct.unpack(">bbbbbbh", buf.read(8))
|
|
self.motor_error = struct.unpack('>12i', buf.read(48))
|
|
return self
|
|
_decode_one = staticmethod(_decode_one)
|
|
|
|
def _get_hash_recursive(parents):
|
|
if robot_control_response_lcmt in parents: return 0
|
|
tmphash = (0x485da98216eda8c7) & 0xffffffffffffffff
|
|
tmphash = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff
|
|
return tmphash
|
|
_get_hash_recursive = staticmethod(_get_hash_recursive)
|
|
_packed_fingerprint = None
|
|
|
|
def _get_packed_fingerprint():
|
|
if robot_control_response_lcmt._packed_fingerprint is None:
|
|
robot_control_response_lcmt._packed_fingerprint = struct.pack(">Q", robot_control_response_lcmt._get_hash_recursive([]))
|
|
return robot_control_response_lcmt._packed_fingerprint
|
|
_get_packed_fingerprint = staticmethod(_get_packed_fingerprint)
|
|
|
|
def get_hash(self):
|
|
"""Get the LCM hash of the struct"""
|
|
return struct.unpack(">Q", robot_control_response_lcmt._get_packed_fingerprint())[0]
|
|
|