Compare commits
2 Commits
main
...
build/dock
| Author | SHA1 | Date | |
|---|---|---|---|
| eb106e97e7 | |||
| ec0e8e3504 |
9
.dockerignore
Normal file
9
.dockerignore
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
.git
|
||||||
|
.githooks/
|
||||||
|
.idea/
|
||||||
|
.venv/
|
||||||
|
test/
|
||||||
|
typings/
|
||||||
|
.dockerignore
|
||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
FROM debian:trixie AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
RUN apt-get update; apt-get install -y portaudio19-dev libzmq3-dev make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl git libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev alsa-utils musl-dev
|
||||||
|
|
||||||
|
ENV HOME="/root"
|
||||||
|
|
||||||
|
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git ${HOME}/.pyenv
|
||||||
|
ENV PYENV_ROOT="${HOME}/.pyenv"
|
||||||
|
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
|
||||||
|
|
||||||
|
ENV PYTHON_VERSION=2.7.18
|
||||||
|
RUN pyenv install ${PYTHON_VERSION}; pyenv global ${PYTHON_VERSION}
|
||||||
|
|
||||||
|
RUN python -m pip install virtualenv; python -m virtualenv .venv
|
||||||
|
RUN /usr/bin/env bash -c 'source .venv/bin/activate && pip install -r ./requirements.txt'
|
||||||
|
# RUN eval "$(pyenv init - bash)"; pyenv install 2.7; pyenv shell 2.7; python -m pip install virtualenv; python -m virtualenv .venv; source .venv/bin/activate; pip install -r requirements.txt
|
||||||
|
|
||||||
|
# FROM debian:trixie
|
||||||
|
#
|
||||||
|
# WORKDIR /app
|
||||||
|
#
|
||||||
|
# COPY --from=build /app/.venv /app/.venv
|
||||||
|
|
||||||
|
WORKDIR /app/.venv/lib/python2.7/site-packages
|
||||||
|
RUN /usr/bin/env bash -c 'apt-get install -y wget && wget https://community-static.aldebaran.com/resources/2.5.10/Python%20SDK/pynaoqi-python2.7-2.5.7.1-linux64.tar.gz && tar xvfz ./pynaoqi-python2.7-2.5.7.1-linux64.tar.gz && rm pynaoqi-python2.7-2.5.7.1-linux64.tar.gz'
|
||||||
|
RUN echo /app/.venv/lib/python2.7/site-packages/pynaoqi-python2.7-2.5.7.1-linux64/lib/python2.7/site-packages/ > pynaoqi-python2.7.pth
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ENV PYTHONPATH=src
|
||||||
|
|
||||||
|
CMD [ "/bin/bash", "-c", "source .venv/bin/activate && python -m robot_interface.main --qi-url tcp://172.17.0.1:43305" ]
|
||||||
9
asound.conf
Normal file
9
asound.conf
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
pcm.!default {
|
||||||
|
type hw
|
||||||
|
card 2
|
||||||
|
}
|
||||||
|
|
||||||
|
ctl.!default {
|
||||||
|
type hw
|
||||||
|
card 2
|
||||||
|
}
|
||||||
4
install_deps.sh
Executable file
4
install_deps.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
apk add portaudio-dev libzmq gcc musl-dev g++ alsa-utils
|
||||||
|
|
||||||
|
pip install -r requirements.txt
|
||||||
@@ -45,7 +45,10 @@ class MainReceiver(ReceiverBase):
|
|||||||
if message["endpoint"] == "negotiate/ports":
|
if message["endpoint"] == "negotiate/ports":
|
||||||
return MainReceiver._handle_port_negotiation(message)
|
return MainReceiver._handle_port_negotiation(message)
|
||||||
|
|
||||||
return {"endpoint": "negotiate/error", "data": "The requested endpoint is not implemented."}
|
return {
|
||||||
|
"endpoint": "negotiate/error",
|
||||||
|
"data": "The requested endpoint is not implemented.",
|
||||||
|
}
|
||||||
|
|
||||||
def handle_message(self, message):
|
def handle_message(self, message):
|
||||||
if message["endpoint"] == "ping":
|
if message["endpoint"] == "ping":
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from abc import ABCMeta
|
from abc import ABCMeta
|
||||||
|
import os
|
||||||
import zmq
|
|
||||||
|
|
||||||
|
|
||||||
class SocketBase(object):
|
class SocketBase(object):
|
||||||
@@ -19,7 +18,7 @@ class SocketBase(object):
|
|||||||
self.socket = None # Set later by `create_socket`
|
self.socket = None # Set later by `create_socket`
|
||||||
self.bound = None # Set later by `create_socket`
|
self.bound = None # Set later by `create_socket`
|
||||||
|
|
||||||
def create_socket(self, zmq_context, socket_type, port, options=[], bind=True):
|
def create_socket(self, zmq_context, socket_type, port, options=[], bind=False):
|
||||||
"""
|
"""
|
||||||
Create a ZeroMQ socket.
|
Create a ZeroMQ socket.
|
||||||
|
|
||||||
@@ -43,17 +42,19 @@ class SocketBase(object):
|
|||||||
self.socket = zmq_context.socket(socket_type)
|
self.socket = zmq_context.socket(socket_type)
|
||||||
|
|
||||||
for option, arg in options:
|
for option, arg in options:
|
||||||
self.socket.setsockopt(option,arg)
|
self.socket.setsockopt(option, arg)
|
||||||
|
|
||||||
self.bound = bind
|
self.bound = bind
|
||||||
|
host = os.environ.get("CB_HOST", "localhost")
|
||||||
if bind:
|
if bind:
|
||||||
self.socket.bind("tcp://*:{}".format(port))
|
self.socket.bind("tcp://{}:{}".format(host, port))
|
||||||
else:
|
else:
|
||||||
self.socket.connect("tcp://localhost:{}".format(port))
|
self.socket.connect("tcp://{}:{}".format(host, port))
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the ZeroMQ socket."""
|
"""Close the ZeroMQ socket."""
|
||||||
if not self.socket: return
|
if not self.socket:
|
||||||
|
return
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
self.socket = None
|
self.socket = None
|
||||||
|
|
||||||
@@ -65,8 +66,4 @@ class SocketBase(object):
|
|||||||
https://utrechtuniversity.youtrack.cloud/articles/N25B-A-14/RI-CB-Communication#negotiation
|
https://utrechtuniversity.youtrack.cloud/articles/N25B-A-14/RI-CB-Communication#negotiation
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
return {
|
return {"id": self.identifier, "port": self.port, "bind": not self.bound}
|
||||||
"id": self.identifier,
|
|
||||||
"port": self.port,
|
|
||||||
"bind": not self.bound
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user