Skip to content

Commit

Permalink
latest changes to stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
imchipwood committed Nov 8, 2017
1 parent 7db3773 commit d1e5c67
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
25 changes: 22 additions & 3 deletions iSOBOT_Control/commands_A.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
Command,Duration
CMD_EAGLE,1
sleep,4
CMD_23K,1
#CMD_FWRD,18
#CMD_FWLT,15
#CMD_124B,1
#CMD_131A,1
#CMD_43B,1
#CMD_222B,1
#CMD_241B,1
#CMD_42B,1
CMD_114B,1

#CMD_GETUP_BACK,1
#CMD_SLEEP,13
#CMD_STOP,1
#CMD_132A,1

#CMD_FWRD,20
#CMD_LEFT,15
#CMD_FWRD,10
#CMD_2P,1
#CMD_ABA,1
#sleep,4
#CMD_23K,1
4 changes: 3 additions & 1 deletion iSOBOT_Control/commands_B.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Command,Duration
CMD_GORILLA,1
CMD_STOP,1
CMD_143A,1
#CMD_A,1
2 changes: 1 addition & 1 deletion iSOBOT_Control/config_B.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"url": "http://192.168.4.3",
"channel": 1,
"channel": 0,
"commandPath": "commands_B.txt"
}
18 changes: 9 additions & 9 deletions iSOBOT_Control/isobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

commands = {
'sleep': 'sleep',
'CMD_SLEEP': 'sleep',
'CMD_STOP': 0x00,
'CMD_RC': 0x07,
'CMD_PM': 0x08,
Expand Down Expand Up @@ -230,8 +231,8 @@
'CMD_HEAD_RIGHT_45': 0xE2,
'CMD_HEAD_RIGHT_60': 0xE3,
# seems identical to A & B getups
'CMD_GETUP_BELLY': 0xE4,
'CMD_GETUP_BACK': 0xE5,
'CMD_GETUP_BELLY': 0xE4, # sleep for 6 seconds for this one
'CMD_GETUP_BACK': 0xE5, # need to sleep for at least 13 seconds after this one - it's a long motion
# E6 unknown
'CMD_HEAD_SCAN_AND_BEND': 0xE7,
'CMD_ARM_TEST': 0xE8,
Expand Down Expand Up @@ -344,7 +345,7 @@ def makeCmd(self, cmdType=1, cmd1=0, cmd2=0):
def sendCmd(self, cmd):
try:
url = "{}/cmd:{}".format(self._url, cmd)
r = requests.post(url, data={'cmd': cmd}, timeout=2)
r = requests.post(url, data={'cmd': cmd}, timeout=5)
if r.status_code == 200:
if self.debug:
print("{} - HTTP Post success!".format(url.replace('\r', '')))
Expand Down Expand Up @@ -392,14 +393,13 @@ def isobotDoType1(self, action, repeat=3):


if __name__ == "__main__":
from isobot_commands import commands as cmds
bot = iSobot()
commands = [
(cmds['CMD_CHEER1'], 1),
cmds = [
(commands['CMD_CHEER1'], 1),
('sleep', 8),
(0x00, 2),
(cmds['CMD_FWRD'], 10),
(cmds['CMD_GORILLA'], 1),
(commands['CMD_FWRD'], 10),
(commands['CMD_GORILLA'], 1),
# (bot.CMD_MOONWALK),
# (bot.CMD_42B),
# (bot.CMD_1P),
Expand All @@ -410,7 +410,7 @@ def isobotDoType1(self, action, repeat=3):
# (bot.CMD_22K),
]
try:
for cmd, repeat in commands:
for cmd, repeat in cmds:
if isinstance(cmd, str):
print('sleeping {}'.format(repeat))
time.sleep(repeat)
Expand Down
5 changes: 2 additions & 3 deletions iSOBOT_Control/isobot_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ def start(self):
continue
# convert string command to hex #
action = commands[rawcmd]
# convert string duration to float
duration = float(command[DURATION_KEY])
duration = command[DURATION_KEY]

print("{} - Executing command {} - {}, {}".format(self.url, i, action, duration))

if action == COMMAND_SLEEP:
time.sleep(duration)
time.sleep(float(duration))
else:
self.isobotDoType1(action=action, repeat=int(duration))

Expand Down

0 comments on commit d1e5c67

Please sign in to comment.