Skip to content
Browse files

Merge branch 'master' of github.com:abondis/nopainnogame

  • Loading branch information...
2 parents 3c79e51 + 2e6166a commit d26b67d72e9fac12c2d77ebd42305b85483bb8be @abondis committed Mar 4, 2012
Showing with 80 additions and 11 deletions.
  1. +16 −5 bluetooth/myRobots.py
  2. +11 −6 bluetooth/robotLib.py
  3. BIN bluetooth/robotLib.pyc
  4. +22 −0 bluetooth/robotPoller.py
  5. +31 −0 textpublicitaire.txt
View
21 bluetooth/myRobots.py
@@ -1,5 +1,6 @@
import httplib
import json
+import time
class MyRobots:
@@ -8,19 +9,29 @@ class MyRobots:
def __init__(self, key="1647186ED7164FCE",url="bots.myrobots.com"):
self.key=key
self.url=url
+ self.entry_id=0
+ self.entry_id=self.read()["entry_id"]
def write(self, newdict):
self.conn = httplib.HTTPConnection(self.url)
- current=self.read()
val=""
for key in newdict.keys():
- current[key] = newdict[key]
- for key in current.keys():
- val+= "&" + key + "=" + str(current[key])
+ val+= "&" + key + "=" + str(newdict[key])
+ val+="&status=true"
self.conn.request("GET", "/update?key="+self.key+val)
+ returnid = self.conn.getresponse().read()
+ while returnid == '0':
+ time.sleep(2)
+ self.conn.request("GET", "/update?key="+self.key+val)
+ returnid = self.conn.getresponse().read()
+ self.entry_id=int(returnid)
def read(self):
self.conn = httplib.HTTPConnection(self.url)
self.conn.request("GET","/channels/589/feed/last.json")
- return json.loads(self.conn.getresponse().read())
+ data = json.loads(self.conn.getresponse().read())
+ if data["entry_id"] == self.entry_id: data["updated"] = "false"
+ else: data["updated"] = "true"
+ self.entry_id=data["entry_id"]
+ return data
View
17 bluetooth/robotLib.py
@@ -3,9 +3,12 @@
class Robot:
"""
- Data from robot: f|l|r|b,millimeters_or_deg,0|1
- Data to robot: f|l|r|b,millimeters_or_deg;
- deg is actually a value from 0 to 3 for 90,180,270,360
+ Data from robot: dest,dist,collision[:dest,dist,collision[:...]];
+ Data to robot: dest,dist,contournement[:dest,dist,contournement[:...]];
+ deg is actually a value from 0 to 3 for 90,180,270,360.
+ collision is 1 if there is an object in front at that moment, 0 otherwise.
+ contournement is 0,l or r, for the robot to go around an object.
+ the closing ";" is not used outside this class.
"""
client_socket=None
@@ -22,12 +25,14 @@ def read(self):
time.sleep(.05)
return None
# We got data, let's read until we get a ";"
- while data[-1] != ";":
+ counter = 0
+ while data[-1] != ";" and counter < 10:
newdata = self.read()
if newdata: data += newdata
- return data
+ counter += 1
+ return data[0:-1]
def write(self, value):
+ value += ";"
self.client_socket.send(value)
-
View
BIN bluetooth/robotLib.pyc
Binary file not shown.
View
22 bluetooth/robotPoller.py
@@ -0,0 +1,22 @@
+import robotLib
+import myRobots
+import time
+
+#class RobotPoller:
+r=robotLib.Robot()
+mr=myRobots.MyRobots()
+debug=True
+
+while True:
+ data=mr.read()
+ if debug: print "read data from cloud: ", data
+ if data['updated'] == "true" and data['field4'] != None:
+ r.write(str(data['field4']) + ';')
+ if debug: print "wrote data to robot: ", data['field4'] + ';'
+
+ robotdata=r.read()
+ if debug: print "read data from robot: ", robotdata
+ if robotdata != None:
+ mr.write({'field1': robotdata})
+ if debug: print "wrote data to cloud: ", {'field1': robotdata}
+ time.sleep(2)
View
31 textpublicitaire.txt
@@ -0,0 +1,31 @@
+Are you tired of having to remember to clean your room before you play ?
+
+# (people in a dirty room looking desparate)
+
+Or perhaps, you know or live with someone who can't stop leaving his things on the floor and you don't want to have to manually repeat the same thing over and over again ?
+
+# (Des gens qui se chicanent)
+
+Then, this new product is for you!
+
+# (robot moving with a cool music)
+
+The NPNG-1337 is the companion that you need to help you keep track of a dirty room!
+
+
+This autonomous device, once you leave it running on the floor, will first take care of mapping a room's environment with it's infrared sensors,
+# (videos of the robot going around objects with a full contournement)
+
+then, it will send this data to the cloud thanks to the new and exciting "MyRobots.com" web service.
+# (film the screen of a laptop on the myrobots website)
+
+Once the information is in the cloud, the NPNG-1337 will keep moving around, detecting new objects.
+# (video of the robot stopping in front of trash)
+
+The information will be sent to the cloud NPNG application, and will be available from any webbrowser.
+
+From there, the possibilities are endless:
+ * you could run a fat client application on your computer to prevent you from playing video games if your room is not tidy,
+ * you could configure the application to send an SMS or call you on your cellphone to remind you of the cleaning work that needs to be done.
+ * A lot of exciting features have yet to be implemented, but since the code is free and open source, fully available on GitHub, who knows where it could go with help from the community!
+

0 comments on commit d26b67d

Please sign in to comment.
Something went wrong with that request. Please try again.