refactor: added config file and moved constants
- Moved hardcoded configuration constants to a dedicated config.py file. - Created VideoConfig, AudioConfig, MainConfig, and Settings classes in config.py ref: N25B-236
This commit is contained in:
@@ -4,10 +4,10 @@ import logging
|
||||
|
||||
from robot_interface.endpoints.socket_base import SocketBase
|
||||
from robot_interface.state import state
|
||||
|
||||
from robot_interface.core.config import settings
|
||||
|
||||
class VideoSender(SocketBase):
|
||||
def __init__(self, zmq_context, port=5556):
|
||||
def __init__(self, zmq_context, port=settings.agent_settings.video_sender_port):
|
||||
super(VideoSender, self).__init__("video")
|
||||
self.create_socket(zmq_context, zmq.PUB, port, [(zmq.CONFLATE,1)])
|
||||
|
||||
@@ -20,12 +20,13 @@ class VideoSender(SocketBase):
|
||||
return
|
||||
|
||||
video = state.qi_session.service("ALVideoDevice")
|
||||
|
||||
camera_index = 0
|
||||
kQVGA = 2
|
||||
kRGB = 11
|
||||
FPS = 15
|
||||
vid_stream_name = video.subscribeCamera("Pepper Video", camera_index, kQVGA, kRGB, FPS)
|
||||
video_settings = settings.video_config
|
||||
camera_index = video_settings.camera_index
|
||||
kQVGA = video_settings.resolution
|
||||
kRGB = video_settings.color_space
|
||||
FPS = video_settings.fps
|
||||
video_name = video_settings.stream_name
|
||||
vid_stream_name = video.subscribeCamera(video_name, camera_index, kQVGA, kRGB, FPS)
|
||||
thread = threading.Thread(target=self.video_rcv_loop, args=(video, vid_stream_name))
|
||||
thread.start()
|
||||
|
||||
@@ -43,6 +44,6 @@ class VideoSender(SocketBase):
|
||||
try:
|
||||
img = vid_service.getImageRemote(vid_stream_name)
|
||||
#Possibly limit images sent if queuing issues arise
|
||||
self.socket.send(img[6])
|
||||
self.socket.send(img[settings.video_config.image_buffer])
|
||||
except:
|
||||
logging.warn("Failed to retrieve video image from robot.")
|
||||
|
||||
Reference in New Issue
Block a user