<commit_before>#!/usr/bin/env python

import rospy
import numpy as np

import pycopia.OS.Linux.Input as input

from geometry_msgs.msg import PointStamped
from art_msgs.msg import Touch
from art_msgs.srv import TouchCalibrationPoints, TouchCalibrationPointsRequest
from std_srvs.srv import Empty as EmptySrv, EmptyResponse
from std_msgs.msg import Bool, Empty
from copy import deepcopy
import cv2


class Slot:

    def __init__(self, slot_id=None, track_id=None):
        if slot_id is None:
            self.slot_id = -1
        else:
            self.slot_id = slot_id

        if track_id is None:
            self.track_id = -1
        else:
            self.track_id = track_id

        self.x = 0
        self.y = 0

    def __eq__(self, other):
        return self.slot_id == other.slot_id


class ArtTouchDriver:

    def __init__(self):
        self.x = 0
        self.y = 0
        self.touch = False
        self.touch_id = -1
        self.device = input.EventDevice("/dev/input/event17")

        self.slots = []
        self.slot = None
        self.to_delete_id = -1

        self.ns = '/art/interface/touchtable/'

        self.touch_pub = rospy.Publisher(self.ns + "touch", Touch, queue_size=100)  # make sure that all messages will be sent
        self.calibrated_pub = rospy.Publisher(self.ns + 'calibrated', Bool, queue_size=1, latch=True)
        self.calibrating_pub = rospy.Publisher(self.ns + 'calibrating', Bool, queue_size=1, latch=True)
        self.touch_det_pub = rospy.Publisher(self.ns + 'touch_detected', Empty, queue_size=10)
        self.calibrate_req_srv = rospy.Service(self.ns + "calibrate", EmptySrv, self.calibrate_req_srv_cb)

        self.calib_srv = rospy.ServiceProxy('/art/interface/projected_gui/touch_calibration', TouchCalibrationPoints)

        self.set_calibrated(False)
        self.set_calibrating(False)

        self.h_matrix = rospy.get_param('~calibration_matrix', None)

        if self.h_matrix is not None:
            self.set_calibrated(True)

    def set_calibrated(self, state):

        self.calibrated = state
        self.calibrated_pub.publish(self.calibrated)

    def set_calibrating(self, state):
<commit_msg>art_touch_driver: fixed calibration loading from param<commit_after>#!/usr/bin/env python

import rospy
import numpy as np

import pycopia.OS.Linux.Input as input

from geometry_msgs.msg import PointStamped
from art_msgs.msg import Touch
from art_msgs.srv import TouchCalibrationPoints, TouchCalibrationPointsRequest
from std_srvs.srv import Empty as EmptySrv, EmptyResponse
from std_msgs.msg import Bool, Empty
from copy import deepcopy
import cv2
import ast

class Slot:

    def __init__(self, slot_id=None, track_id=None):
        if slot_id is None:
            self.slot_id = -1
        else:
            self.slot_id = slot_id

        if track_id is None:
            self.track_id = -1
        else:
            self.track_id = track_id

        self.x = 0
        self.y = 0

    def __eq__(self, other):
        return self.slot_id == other.slot_id


class ArtTouchDriver:

    def __init__(self):
        self.x = 0
        self.y = 0
        self.touch = False
        self.touch_id = -1
        self.device = input.EventDevice("/dev/input/event17")

        self.slots = []
        self.slot = None
        self.to_delete_id = -1

        self.ns = '/art/interface/touchtable/'

        self.touch_pub = rospy.Publisher(self.ns + "touch", Touch, queue_size=100)  # make sure that all messages will be sent
        self.calibrated_pub = rospy.Publisher(self.ns + 'calibrated', Bool, queue_size=1, latch=True)
        self.calibrating_pub = rospy.Publisher(self.ns + 'calibrating', Bool, queue_size=1, latch=True)
        self.touch_det_pub = rospy.Publisher(self.ns + 'touch_detected', Empty, queue_size=10)
        self.calibrate_req_srv = rospy.Service(self.ns + "calibrate", EmptySrv, self.calibrate_req_srv_cb)

        self.calib_srv = rospy.ServiceProxy('/art/interface/projected_gui/touch_calibration', TouchCalibrationPoints)

        self.set_calibrated(False)
        self.set_calibrating(False)

        self.h_matrix = rospy.get_param('~calibration_matrix', None)

        if self.h_matrix is not None:
            rospy.loginfo("Loaded calibration from param server")
            self.h_matrix = np.matrix(ast.literal_eval(self.h_matrix))
            self.set_calibrated(True)

    def set_calibrated(self, state):

        self.calibrated = state
        self.calibrated_pub.publish(self.calibrated)

    def set_calibrating(self, state):

{'fraction_non_alphanumeric': 0.09352992957746478, 'fraction_numerical': 0.007922535211267605, 'mean_word_length': 2.7376644736842106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3281121', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1466, 'n_words': 326}