def create_position_response(self, status, message, position=None): position_msg = PositionMessage() if position != None: position_msg.position_name = position.position_name position_msg.position_id = position.position_id position_msg.joints = position.joints position_msg.rpy = Position.RPY(position.rpy.roll, position.rpy.pitch, position.rpy.yaw) position_msg.point = Position.Point( position.point.x, position.point.y, position.point.z) position_msg.quaternion = Position.Quaternion(position.quaternion.x, position.quaternion.y, position.quaternion.z, position.quaternion.w) return { 'status': status, 'message': message, 'position': position_msg }
def callback_get_position_list(self, req = None): pos_list = self.get_all_positions() msg_list = [] for pos in pos_list: position_msg = PositionMessage() position_msg.position_name = pos.position_name position_msg.position_id = pos.position_id position_msg.joints = pos.joints position_msg.rpy = Position.RPY(pos.rpy.roll, pos.rpy.pitch, pos.rpy.yaw) position_msg.point = Position.Point( pos.point.x, pos.point.y, pos.point.z) position_msg.quaternion = Position.Quaternion(pos.quaternion.x, pos.quaternion.y, pos.quaternion.z, pos.quaternion.w) msg_list.append(position_msg) return { 'positions': msg_list }