Skip to content

Commit fd5ec8a

Browse files
Updated Robobo main class to add a Generic Command processor for debugging and development reasons
1 parent 6ff39b3 commit fd5ec8a

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="robobopy", # This is the name of the package
8-
version="1.5.0", # The initial release version
8+
version="1.5.1", # The initial release version
99
author="The Robobo Project", # Full name of the author
1010
author_email='info@theroboboproject.com',
1111
description="Robobo remote control library",

src/robobopy/Robobo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,4 +1285,16 @@ def sendSyncAudio(self, syncId):
12851285
:type syncId: int
12861286
"""
12871287
self.rem.sendSyncAudio(syncId)
1288+
1289+
def sendCommand(self, tag, parameters):
1290+
"""
1291+
Send a generic command to the Robobo. Useful for debugging and special instructions not implemented in methods yet.
1292+
1293+
:param tag: Command Tag
1294+
:type tag: str
1295+
1296+
:param parameters: JSON dict containing the parameters of the command
1297+
:type parameters: dict
1298+
"""
1299+
self.rem.sendGenericCommand(tag, parameters)
12881300

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from robobopy.processors.AbstractProcessor import AbstractProcessor
2+
from robobopy.utils.Message import Message
3+
4+
5+
class CommandProcessor(AbstractProcessor):
6+
def __init__(self, state):
7+
super().__init__(state)
8+
self.supportedMessages = []
9+
10+
def sendGenericCommand(self, tag, parameters):
11+
name = tag
12+
id = self.state.getId()
13+
values = parameters
14+
return Message(name, values, id)
15+
16+
17+
18+

src/robobopy/remotelib.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from robobopy.processors.SmartphoneProcessor import SmartphoneProcessor
1414
from robobopy.processors.SoundProcessor import SoundProcessor
1515
from robobopy.processors.SpeechProcessor import SpeechProcessor
16+
from robobopy.processors.CommandProcessor import CommandProcessor
1617
from robobopy.utils.ConnectionState import ConnectionState
1718

1819

@@ -30,7 +31,8 @@ def __init__(self, ip, robot_id=0, secure=False):
3031
"PHONE": SmartphoneProcessor(self.state),
3132
"SOUND": SoundProcessor(self.state),
3233
"SPEECH" : SpeechProcessor(self.state),
33-
"VISION": VisionProcessor(self.state)}
34+
"VISION": VisionProcessor(self.state),
35+
"COMMAND": CommandProcessor(self.state)}
3436

3537
self.wsDaemon = None
3638
self.connectionState = ConnectionState.DISCONNECTED
@@ -263,6 +265,10 @@ def sendSyncAudio(self, syncId):
263265
def sendSync(self, syncId):
264266
msg = self.processors["VISION"].sendSync(syncId)
265267
self.sendMessage(msg)
268+
269+
def sendGenericCommand(self, tag, parameters):
270+
msg = self.processors["COMMAND"].sendGenericCommand(tag, parameters)
271+
self.sendMessage(msg)
266272

267273
def startSpeechDetection(self):
268274
msg = self.processors["SPEECH"].startSpeechDetection()

0 commit comments

Comments
 (0)