Ejemplo n.º 1
0
Python is more powerful than javascript with the Mirbot, because we have access to more commands, can use multiple Mirobots simultaneously, and even access them from the command line without using the web app at all.

We always need to import the Mirobot module in Python before using it! 
We always need to create the Mirobot object in Python before using it!

Basics

# Setup in the web app

from mirobot import Mirobot 	# Import the module

m = Mirobot()					# Create the object to use

# Movement

m.forward(100)			# Move forward by 100 mm

m.back(100)

m.left(45)				# Turn left by 45 degrees

m.right(90)

# Pen Control

m.penup()					# Move the pen up

m.pendown()

# Sensors
Ejemplo n.º 2
0
mirobot = Mirobot(debug=True)
# Autoconnect to a Mirobot on our network (there can be only one)
mirobot.autoConnect()

# Get a menu so we can select which Mirobot to connect to
#mirobot.autoConnect(interactive=True)

# Specify the id of the Mirobot we want to connect to
#mirobot.autoConnect(id='Mirobot-abcd')

print("Mirobot version: %s" % mirobot.version)

# set up error handling
mirobot.errorNotify(on_error)

mirobot.forward(100)
mirobot.right(90)
mirobot.back(100)
mirobot.penup()

while True:
  state = mirobot.collideState()
  if state == 'left':
    mirobot.back(100)
    mirobot.left(90)
  if state == 'right':
    mirobot.back(100)
    mirobot.right(90)
  else:
    mirobot.forward(10)