150 lines
6.4 KiB
Python
Executable File
150 lines
6.4 KiB
Python
Executable File
# LCM type definitions This file automatically generated by lcm.
|
|
try:
|
|
import cStringIO.StringIO as BytesIO
|
|
except ImportError:
|
|
from io import BytesIO
|
|
import struct
|
|
|
|
class robot_control_cmd_lcmt(object):
|
|
__slots__ = ["mode", "gait_id", "contact", "life_count", "vel_des", "rpy_des", "pos_des", "acc_des", "ctrl_point", "foot_pose", "step_height", "value", "duration"]
|
|
|
|
__typenames__ = ["int8_t", "int8_t", "int8_t", "int8_t", "float", "float", "float", "float", "float", "float", "float", "int32_t", "int32_t"]
|
|
|
|
__dimensions__ = [None, None, None, None, [3], [3], [3], [6], [3], [6], [2], None, None]
|
|
|
|
def __init__(self):
|
|
self.mode = 0
|
|
self.gait_id = 0
|
|
self.contact = 0
|
|
self.life_count = 0
|
|
self.vel_des = [ 0.0 for dim0 in range(3) ]
|
|
self.rpy_des = [ 0.0 for dim0 in range(3) ]
|
|
self.pos_des = [ 0.0 for dim0 in range(3) ]
|
|
self.acc_des = [ 0.0 for dim0 in range(6) ]
|
|
self.ctrl_point = [ 0.0 for dim0 in range(3) ]
|
|
self.foot_pose = [ 0.0 for dim0 in range(6) ]
|
|
self.step_height = [ 0.0 for dim0 in range(2) ]
|
|
self.value = 0
|
|
self.duration = 0
|
|
|
|
def encode(self):
|
|
buf = BytesIO()
|
|
buf.write(robot_control_cmd_lcmt._get_packed_fingerprint())
|
|
self._encode_one(buf)
|
|
return buf.getvalue()
|
|
|
|
def _encode_one(self, buf):
|
|
buf.write(struct.pack(">bbbb", self.mode, self.gait_id, self.contact, self.life_count))
|
|
buf.write(struct.pack('>3f', *self.vel_des[:3]))
|
|
buf.write(struct.pack('>3f', *self.rpy_des[:3]))
|
|
buf.write(struct.pack('>3f', *self.pos_des[:3]))
|
|
buf.write(struct.pack('>6f', *self.acc_des[:6]))
|
|
buf.write(struct.pack('>3f', *self.ctrl_point[:3]))
|
|
buf.write(struct.pack('>6f', *self.foot_pose[:6]))
|
|
buf.write(struct.pack('>2f', *self.step_height[:2]))
|
|
buf.write(struct.pack(">ii", self.value, self.duration))
|
|
|
|
def decode(data):
|
|
if hasattr(data, 'read'):
|
|
buf = data
|
|
else:
|
|
buf = BytesIO(data)
|
|
if buf.read(8) != robot_control_cmd_lcmt._get_packed_fingerprint():
|
|
raise ValueError("Decode error")
|
|
return robot_control_cmd_lcmt._decode_one(buf)
|
|
decode = staticmethod(decode)
|
|
|
|
def _decode_one(buf):
|
|
self = robot_control_cmd_lcmt()
|
|
self.mode, self.gait_id, self.contact, self.life_count = struct.unpack(">bbbb", buf.read(4))
|
|
self.vel_des = struct.unpack('>3f', buf.read(12))
|
|
self.rpy_des = struct.unpack('>3f', buf.read(12))
|
|
self.pos_des = struct.unpack('>3f', buf.read(12))
|
|
self.acc_des = struct.unpack('>6f', buf.read(24))
|
|
self.ctrl_point = struct.unpack('>3f', buf.read(12))
|
|
self.foot_pose = struct.unpack('>6f', buf.read(24))
|
|
self.step_height = struct.unpack('>2f', buf.read(8))
|
|
self.value, self.duration = struct.unpack(">ii", buf.read(8))
|
|
return self
|
|
_decode_one = staticmethod(_decode_one)
|
|
|
|
def _get_hash_recursive(parents):
|
|
if robot_control_cmd_lcmt in parents: return 0
|
|
tmphash = (0x476b61e296af96f5) & 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_cmd_lcmt._packed_fingerprint is None:
|
|
robot_control_cmd_lcmt._packed_fingerprint = struct.pack(">Q", robot_control_cmd_lcmt._get_hash_recursive([]))
|
|
return robot_control_cmd_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_cmd_lcmt._get_packed_fingerprint())[0]
|
|
|
|
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]
|