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.
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. 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.
The camera view (shown above) is an approximated view of what is actually in the scene. You use the camera as a normal camera on the robot, for example:
You can also use makeSimulation(calico, filename) to make your own worlds:
from Myro import * makeSimulation(calico, "water.py") joystick()
This will load the script "water.py" which can be used to define your own world. The makeSimulation() will first try to load the file from your current directory, or as an absolute or relative filename. If it doesn't find it, it will look in the Calico/modules/Robots/Worlds folder.
There are three pre-defined worlds: "water.py", "indoor.py", and "outdoor.py". Look at those for examples of building your own worlds. You can use any Calico language for defining your own world. The only requirement is that you create a Simulation(). You probably also want to define a robot, and move it to the proper location. You can use "robot.setPose(x, y, angle)" for positioning the robot.
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()
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)
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()
- forward(power, time)
- backward(power, time)
- turnLeft(power, time)
- turnRight(power, time)
- motors(left, right)
- move(translate, rotate)
- getIR(), getIR(0, 1), getIR("left", right")
- getObstacle(), getObstacle(0, 1, 2), getObstacle("left", "center", right")
- getBright(), getBright(0, 1, 2), getBright("left", "center", "right")
- penDown(), penDown("color")
- takePicture() - currently only takes color pictures
- turnBy(degrees) # exact
- turnTo(degrees) # exact
- beep(duration, frequency), beep(duration, frequency1, frequency2)
- gamepad() - control
- joystick() - control
- senses() - info
- setOption("show-sensors", True | False)
- simulation = getSimulation()
- simulation.robots - list of robots in world
Limitations and Future plans
- lights don't currently show up in the camera view
- allow user to move objects in the world via the mouse (use setPose() function)
- allow user to 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).