Calico Simulator

From IPRE Wiki
Revision as of 19:24, 25 February 2013 by Myro-user (Talk | contribs) (Functionality)

Jump to: navigation, search

The Calico Simulator is designed to provide a simulated version of the Scribbler/Scribbler2 robot. It currently supports all of the functions except for beep()) for use with our textbook, Learning Computing With Robots.

Using the Simulation

To use the simulated scribbler rather than a real robot, use the following (Python example):

from Myro import *
init("sim")

That will produce in the shell output area:

You are using:
   Simulated Fluke, version 1.0.0
   Simulated Scribbler 2, version 1.0.0
Hello, my name is 'Scribby'!
Ok

From that point forward, most of the Calico Myro robot commands will do as described, and similarly to those run on the real Scribbler.

Simulator.gif

Currently, the simulation is of a Scribbler robot (in image above, upper right corner) in a simple simulated world composed of a square room with purple walls, a pyramid-like box (upper left-hand corner) in the same color as a real orange pyramid in the lab at Bryn Mawr College), a light (bottom right-hand corner), and a blue ball. The ball can be pushed, and can also push back on the robot. The robot will bounce off walls slightly.

The simulator approximates the functionality of the Scribbler robot. Note that the simulation window always shows a visualization of the IR sensors of the Scribbler. (A future version will allow you to turn that visualization off). Also, there is no noise in the simulated sensors---they always provide exact, calculated values. There may be some variation each time you run it, as the user's control program is running in a different thread as the simulation loop. This can be controlled, however, by running the simulation loop manually.

SimulatorCamera.gif

The camera view (shown above) is an approximated view of what is actually in the scene. Note that the ball extends as high as a ball. That will be fixed in a future version. You use the camera as a normal camera on the Fluke, for example:

show(takePicture())

Functionality

The simulator is under development. If you have questions or requests, please post those on the Calico User's forum.

You can constructor your own simulations:

import Myro
from Myro import *
from Graphics import *

sim = Simulation("My World", 500, 400, Color("lightgrey"))
# Add lights first:
sim.addLight((200, 200), 25, Color("orange"))
# Add walls and other objects:
sim.addWall((10, 10), (20, 20), Color("black"))
sim.addWall((100, 100), (120, 120))
# Is movable:
circle = Circle((100, 200), 20)
sim.addShape(circle)
# Start simulation loop:
sim.setup()

# Make a robot (save return, or use Myro.robot)
makeRobot("SimScribbler", sim)

# Control it somehow:
joystick()

Simulation

The simulation has a number of methods that might be useful:

simulation.stop() # stop the default loop, even if running in background
simulation.loop() # blocking
simulation.setPose(robot_number, x, y, theta)
simulation.setOption(robot_number, option, value)

Implemented functions

The following functions have been implemented; however, they have not been calibrated with the real robot yet. Thus, many of the sensors give values, but they may have no relationship with those given by the real robot.

  • init("sim"), initialize(), init()
  • stop()
  • forward(power)
  • backward(power)
  • turnLeft(power)
  • turnRight(power)
  • forward(power, time)
  • backward(power, time)
  • turnLeft(power, time)
  • turnRight(power, time)
  • motors(left, right)
  • move(translate, rotate)
  • translate(power)
  • rotate(power)
  • getStall()
  • getBattery()
  • getIR(), getIR(0, 1), getIR("left", right")
  • getObstacle(), getObstacle(0, 1, 2), getObstacle("left", "center", right")
  • takePicture() - currently only takes color pictures
  • penDown(), penDown("color")
  • senses()
  • gamepad control
  • penUp()
  • setName("name")
  • getName()
  • getLight(...)
  • getBright(), getBright(0, 1, 2), getBright("left", "center", "right")

Additional Functions

  • setOption("show-sensors", True | False)
  • simulation = getSimulation()
  • simulation.window
  • simulation.robots - list of robots in world

Not implemented

  • beep(...)
  • getLine(...)
  • get(...)
  • getInfo(...)
  • getIRMessage(...)
  • setCommunicate()
  • sendIRMessage(string)
  • getBlob()
  • getData()
  • setData()
  • getAll()
  • setLED*()
  • setIRPower()
  • setWhiteBalance()
  • setForwardness()
  • setVolume()
  • setPassword()
  • getConfig()
  • setEchoMode()

Limitations and Future plans

  • beep doesn't (Calico needs sound support, under development)
  • lights don't currently show up in the camera view
  • allow pictures/images in the simulated camera view
  • allow user to move objects in the world (say, via the mouse)
  • allow user to create and change the simulated world settings
  • calibrate values to better reflect those from the real robot
  • implement all of the functions of the real robot
  • create a stand-alone, networked version, to work with other Myro implementations (C++, Java, etc).