XMLRPC server instead of KeyboardListener for jogging
This commit is contained in:
parent
7e764ddd77
commit
229f4ca6e4
@ -1,11 +1,14 @@
|
|||||||
FROM python:3.9
|
FROM python:3.9
|
||||||
|
|
||||||
ADD dual_ursim_control requirements.txt /dual_ursim_control/
|
ADD requirements.txt requirements.txt
|
||||||
WORKDIR /dual_ursim_control/
|
|
||||||
|
|
||||||
RUN pip3 install -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
ADD dual_ursim_control /dual_ursim_control/
|
||||||
|
WORKDIR /dual_ursim_control/
|
||||||
|
|
||||||
ARG RELEASE_ID
|
ARG RELEASE_ID
|
||||||
ENV RELEASE_ID ${RELEASE_ID:-""}
|
ENV RELEASE_ID ${RELEASE_ID:-""}
|
||||||
|
|
||||||
|
EXPOSE 8888/tcp
|
||||||
|
|
||||||
CMD ["python3", "main.py"]
|
CMD ["python3", "main.py"]
|
@ -13,6 +13,7 @@ import openpyxl
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
|
from xmlrpc.server import SimpleXMLRPCServer
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
# from pynput.keyboard import Listener, Key
|
# from pynput.keyboard import Listener, Key
|
||||||
|
|
||||||
@ -288,6 +289,7 @@ def master_jogging_wait():
|
|||||||
|
|
||||||
while not jogging_wait['Master']:
|
while not jogging_wait['Master']:
|
||||||
pass
|
pass
|
||||||
|
jogging_wait['Master'] = False
|
||||||
|
|
||||||
|
|
||||||
def slave_jogging_wait():
|
def slave_jogging_wait():
|
||||||
@ -296,6 +298,7 @@ def slave_jogging_wait():
|
|||||||
|
|
||||||
while not jogging_wait['Slave']:
|
while not jogging_wait['Slave']:
|
||||||
pass
|
pass
|
||||||
|
jogging_wait['Slave'] = False
|
||||||
|
|
||||||
|
|
||||||
def master_operate_gripper(target_width):
|
def master_operate_gripper(target_width):
|
||||||
@ -817,6 +820,29 @@ def slave_thread(sync_event, path):
|
|||||||
logging.info('Done')
|
logging.info('Done')
|
||||||
|
|
||||||
|
|
||||||
|
class RemoteFuncs:
|
||||||
|
def signal(self, robot):
|
||||||
|
if robot == 'M':
|
||||||
|
jogging_wait['Master'] = True
|
||||||
|
return 0
|
||||||
|
elif robot == 'S':
|
||||||
|
jogging_wait['Slave'] = True
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
logging.debug("Wrong XMLRPC signal input. Value: {0}".format(robot))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
class ServerThread(threading.Thread):
|
||||||
|
def __init__(self):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self.localServer = SimpleXMLRPCServer(('0.0.0.0', 8888))
|
||||||
|
self.localServer.register_instance(RemoteFuncs())
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.localServer.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
logging.config.fileConfig(os.path.join(SCRIPT_DIR, 'log_config.ini'))
|
logging.config.fileConfig(os.path.join(SCRIPT_DIR, 'log_config.ini'))
|
||||||
@ -855,7 +881,10 @@ if __name__ == '__main__':
|
|||||||
'Slave': threading.Event()
|
'Slave': threading.Event()
|
||||||
}
|
}
|
||||||
|
|
||||||
logging.info('Starting keyboard listener')
|
logging.info('Spawning XMLRPC listener thread')
|
||||||
|
xmlrpcServer = ServerThread()
|
||||||
|
xmlrpcServer.daemon = True
|
||||||
|
xmlrpcServer.start()
|
||||||
|
|
||||||
# listener = Listener(on_press=on_press, on_release=on_release)
|
# listener = Listener(on_press=on_press, on_release=on_release)
|
||||||
# listener.start()
|
# listener.start()
|
||||||
@ -879,4 +908,3 @@ if __name__ == '__main__':
|
|||||||
logging.info("Done")
|
logging.info("Done")
|
||||||
|
|
||||||
# TODO: export from ursimulator: root@xu:/var/snap/docker/common/var-lib-docker/volumes/dockursim/_data/programs.UR3#
|
# TODO: export from ursimulator: root@xu:/var/snap/docker/common/var-lib-docker/volumes/dockursim/_data/programs.UR3#
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user