Jyro Simulator¶
Jyro Python Robot Simulator¶
Pure-Python simulator for robots.¶
In [2]:
from jyro.simulator import *
import math
In [3]:
sim = Physics()
In [4]:
def world(sim):
sim.addBox(0, 0, 5, 5, fill="backgroundgreen", wallcolor="lightgrey") # meters
sim.addBox(1, 1, 2, 2, "purple")
## brightness of 1 is radius 1 meter
sim.addLight(4, 4, 1.00, color=Color(255, 255, 0, 64))
sim.addLight(4, 2, 1.00, color=Color(255, 255, 0, 64))
In [5]:
world(sim)
In [6]:
import random
class MyPioneer(Pioneer):
def __init__(self, name, x, y, angle):
Pioneer.__init__(self, name, x, y, angle)
self.addDevice(PioneerFrontSonars(maxRange=5.0))
#self.addDevice(Gripper())
self.addDevice(PioneerFrontLightSensors(5))
def brain(self):
self.move(random.random() * 2 - 1,
random.random() * 2 - 1)
In [7]:
robot = MyPioneer("Pioneer", 2.50, 4.50, math.pi / 2) # meters, radians
In [8]:
robot
Out[8]:
In [9]:
sim.addRobot(robot)
In [10]:
canvas = Canvas((250, 250))
In [11]:
sim.draw(canvas)
Out[11]:
In [12]:
#robot.setPose(4.5, 4.0, math.pi / 2)
In [13]:
robot.move(1, 1)
In [14]:
from IPython.display import display, clear_output
In [15]:
%%time
import time
for i in range(70):
sim.step(run_brain=False)
for r in sim.robots:
sim.draw(canvas)
clear_output(wait=True)
display(canvas)
time.sleep(.085) # sleep for a bit
CPU times: user 516 ms, sys: 24 ms, total: 540 ms
Wall time: 6.54 s
In [16]:
robot.getPose()
Out[16]:
(1.8312560941005205, 4.28695669992235, 2.287611019615305)
In [17]:
%%time
import numpy
light0 = numpy.zeros((100,100))
light1 = numpy.zeros((100,100))
robot.setPose(2.50, 4.50, math.pi / 2)
for i in range(70):
sim.step(run_brain=False)
for r in sim.robots:
x, y, a = robot.getPose()
light0[int(y/canvas.max_y * 100), int(x/canvas.max_x * 100)] = r.device["light"].scan[0]
light1[int(y/canvas.max_y * 100), int(x/canvas.max_x * 100)] = r.device["light"].scan[1]
CPU times: user 80 ms, sys: 0 ns, total: 80 ms
Wall time: 79.7 ms
70 steps * 0.1 seconds/step = 7 seconds
7 seconds / 85 ms
In [18]:
7 / .056
Out[18]:
125.0
Looks like it simulates about 80 - 100 simulated seconds for every real second, or is 80 - 100 times faster than real life.
Checking Light Readings¶
New simulated light sensors are 75% direct light and 25% ambient light.
In [19]:
%matplotlib inline
import matplotlib.pyplot as plt
In [20]:
fig1 = plt.figure()
sp0 = fig1.add_subplot(111)
p0 = sp0.matshow(light0, origin="lower")
fig1.colorbar(p0)
Out[20]:
<matplotlib.colorbar.Colorbar at 0x7fc1c4b5aba8>
In [21]:
fig2 = plt.figure()
sp1 = fig2.add_subplot(111)
p1 = sp1.matshow(light1, origin="lower")
fig2.colorbar(p1)
Out[21]:
<matplotlib.colorbar.Colorbar at 0x7fc1c4a64ef0>
Differences between two light sensors¶
In [22]:
fig3 = plt.figure()
sp3 = fig3.add_subplot(111)
p3 = sp3.matshow(light1 - light0, origin="lower")
fig3.colorbar(p3)
Out[22]:
<matplotlib.colorbar.Colorbar at 0x7fc1c49c1160>
In [23]:
def sampleLight(angle, resolution=50):
light0 = numpy.zeros((resolution,resolution))
light1 = numpy.zeros((resolution,resolution))
for x in range(resolution):
for y in range(resolution):
for r in sim.robots:
r.setPose(x/resolution * canvas.max_x,
y/resolution * canvas.max_y,
angle)
light0[y, x] = r.device["light"].scan[0]
light1[y, x] = r.device["light"].scan[1]
fig = plt.figure()
sp = fig.add_subplot(111)
p = sp.matshow(light0, origin="lower")
fig.colorbar(p)
In [24]:
robot.setPose(2.5, 4.5, 0)
sim.draw(canvas)
Out[24]:
In [25]:
sampleLight(0) # face up, north
In [26]:
robot.device["light"].scan
Out[26]:
[0.5453626300613212, 0.5139231911477004]
In [27]:
robot.setPose(2.5, 4.5, math.pi)
sim.draw(canvas)
Out[27]:
In [28]:
sampleLight(math.pi)
In [29]:
robot.setPose(2.5, 4.5, math.pi/2)
sim.draw(canvas)
Out[29]:
In [30]:
sampleLight(math.pi/2)
In [31]:
robot.setPose(2.5, 4.5, math.pi/4)
sim.draw(canvas)
Out[31]:
In [32]:
sampleLight(math.pi/4)
In [33]:
robot.setPose(2.5, 4.5, math.pi * 3/4)
sim.draw(canvas)
Out[33]:
In [34]:
sampleLight(math.pi * 3/4)
In [35]:
robot.setPose(2.5, 4.5, math.pi * 3/4)
sim.draw(canvas)
Out[35]:
In [36]:
robot.addDevice(Camera(120, 80))
Out[36]:
In [37]:
robot.device["camera"].getImage()
Out[37]:
In [38]:
robot.move(0, .5)
for i in range(10):
sim.step(run_brain=False)
In [39]:
robot.device["camera"].getImage()
Out[39]:
In [40]:
img = robot.device["camera"].getImage()
img = img.resize((240, 160))
img
Out[40]:
In [41]:
vsim = VSimulator(robot, world)
robot.brain = lambda self: self.move(1,1)
Jyro Visual Simulator¶
This notebook demonstrates creating a visual simulation of the Pioneer robot from MobileRobots.
Here is a picture of the Pioneer robot:
First, we import the items that we will need:
In [1]:
from jyro.simulator import *
import math
We create a Pioneer robot by giving it a name, x-coordinate, y-coordinate, and a facing angle in radians. The coordinates are given in meters.
In [2]:
robot = Pioneer("Pioneer", 2.50, 4.50, math.pi * 3/2) # meters, radians
To see a top-down view of the robot in the notebook:
In [3]:
robot
Out[3]:
Next, we add some devices to the Pioneer, including sonar sensors, light sensors, a camera, and a gripper.
In [4]:
robot.addDevice(Pioneer16Sonars())
Out[4]:
In [5]:
robot.addDevice(PioneerFrontLightSensors())
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-4bc1997da056> in <module>()
----> 1 robot.addDevice(PioneerFrontLightSensors())
TypeError: __init__() missing 1 required positional argument: 'maxRange'
In [6]:
robot.addDevice(Camera(120, 80))
Out[6]:
In [7]:
robot.addDevice(Gripper())
Out[7]:
Finally, we create a world function that takes a simulator and adds items to the world:
In [8]:
def world(sim):
sim.addBox(0, 0, 5, 5, fill="backgroundgreen", wallcolor="lightgrey") # meters
sim.addBox(1, 1, 2, 2, "purple")
sim.addLight(4, 4, 2.25, color=Color(255, 255, 0, 64))
To create a visual simulation, pass in the robot and the world function. Optionally, you can set gamepad=True to control the robot with a gamepad.
In [9]:
VSimulator(robot, world, gamepad=True);
In [14]:
robot.brain = lambda self: self.move(1,-1)
In [15]:
robot.getPose()
Out[15]:
(2.5, 4.5, 4.71238898038469)
If you are viewing (rather than executing) this notebook, then the above simulation looks like this:
In [16]:
sim = Simulator(robot, world, gamepad=True)
0.00 seconds
Pioneer: (2.5, 4.5, 4.71238898038469)
In [17]:
sim.step(1.70)
1.70 seconds
Pioneer: (3.547280510061178, 3.421679606793642, 3.0123889803846913)
Robot Find Light¶
Creating a dataset for finding the light.
In [1]:
from jyro.simulator import (Robot, Pioneer, Pioneer16Sonars, PioneerFrontLightSensors,
Camera, Simulator, VSimulator)
import numpy as np
from math import pi
from random import random
In [2]:
def make_world(physics):
physics.addBox(0, 0, 4, 4, fill="backgroundgreen", wallcolor="gray")
physics.addBox(1.75, 2.9, 2.25, 3.0, fill="blue", wallcolor="blue")
physics.addLight(2, 3.5, 1.0)
In [3]:
def make_robot():
robot = Pioneer("Pioneer", 2, 1, 0) #paremeters are x, y, heading (in radians)
robot.addDevice(Camera())
robot.addDevice(Pioneer16Sonars())
light_sensors = PioneerFrontLightSensors(3) #parameter defines max range
#light_sensors.lightMode = 'ambient'
robot.addDevice(light_sensors)
return robot
In [4]:
def get_senses(robot):
light = robot["light"].getData()
#print("light", light)
sonar = robot["sonar"].getData()
#print("sonar", sonar)
return [light, sonar]
In [5]:
def random_start(robot):
robot.setPose(0.5 + random()*2.5, 0.5 + random()*2, random()*2*pi)
In [6]:
def determine_move(senses):
"""Returns tuple of (translation, rotation) movement"""
lights = senses[0]
left_light = lights[0]
right_light = lights[1]
light_diff = abs(left_light-right_light)
sonars = senses[1]
# if found light, then stop
if sum(lights) > 1.8:
return (0, 0)
# if getting close to an obstacle in front, turn to avoid it
elif min(sonars[2:6]) < 0.5:
# if closer on left, turn right
if min(sonars[1:4]) < min(sonars[4:7]):
return (0, -0.3)
# otherwise, turn left
else:
return (0, 0.3)
# if diff in light readings is high enough or total of light readings is
# low ennough, then turn towards the light
elif light_diff > 0.1 or sum(lights) < 0.1:
# if brighter on left side, turn slightly left
if left_light > right_light:
return (0.1, 0.3)
else:
return (0.1, -0.3)
# default is to go straight
else:
return (0.3, 0)
def find_light_brain(robot):
senses = get_senses(robot)
translate, rotate = determine_move(senses)
robot.move(translate, rotate)
In [7]:
robot = make_robot()
vsim = VSimulator(robot, make_world) #create a visual simulator to watch robot's behavior
random_start(robot)
vsim.update_gui()
robot.brain = find_light_brain
In [8]:
robot["camera"].getImage().resize((240, 160))
Out[8]:
In [9]:
robot["camera"].lights
Out[9]:
[(2.661347914428072, 1.9886887713326211)]
In [10]:
robot["camera"].scan
Out[10]:
[(151, 9, 3.1468658102018714, 0.6853134189798128),
(151, 9, 3.205917041685684, 0.6794082958314316),
(151, 9, 3.271427583532677, 0.6728572416467322),
(151, 9, 3.117340854250534, 0.6882659145749466),
(151, 9, 2.955939301808889, 0.7044060698191111),
(151, 10, 2.813799179070223, 0.7186200820929777),
(151, 10, 2.6879332300963967, 0.7312066769903603),
(151, 11, 2.575952233737128, 0.7424047766262871),
(151, 11, 2.475923400873351, 0.752407659912665),
(151, 11, 2.3862669170965702, 0.761373308290343),
(151, 11, 2.3056804602620136, 0.7694319539737986),
(151, 12, 2.233080789922769, 0.7766919210077231),
(151, 12, 2.1675613146576613, 0.7832438685342339),
(151, 12, 2.1083576826492845, 0.7891642317350716),
(151, 12, 2.054822509355691, 0.7945177490644308),
(151, 12, 2.006404088175722, 0.7993595911824277),
(151, 12, 1.9626309549651584, 0.8037369045034841),
(151, 13, 1.9230983499660799, 0.807690165003392),
(151, 13, 1.8874580699053687, 0.8112541930094631),
(151, 13, 1.855410109638303, 0.8144589890361698),
(151, 13, 1.8266954680809961, 0.8173304531919005),
(151, 13, 1.8010907999569872, 0.8198909200043012),
(151, 13, 1.7784038489031955, 0.8221596151096804),
(151, 13, 1.7584693819658332, 0.8241530618034167),
(151, 13, 1.7411464026794672, 0.8258853597320532),
(151, 13, 1.726315305661425, 0.8273684694338576),
(151, 13, 1.7138759757197426, 0.8286124024280257),
(151, 13, 1.70374598830988, 0.8296254011690121),
(151, 13, 1.6958592459161284, 0.8304140754083871),
(151, 13, 1.6901649600661617, 0.8309835039933839),
(151, 13, 1.6866268159290632, 0.8313373184070937),
(151, 13, 1.6852223823983883, 0.8314777617601612),
(151, 13, 1.6859427943949996, 0.8314057205605),
(151, 13, 1.6887925940390223, 0.8311207405960979),
(151, 13, 1.6937898161250025, 0.8306210183874997),
(151, 13, 1.700966267038597, 0.8299033732961403),
(151, 13, 1.7103680115403526, 0.8289631988459647),
(151, 13, 1.722056088186009, 0.8277943911813992),
(151, 13, 1.7361075622433133, 0.8263892437756686),
(151, 13, 1.7526166634867562, 0.8247383336513243),
(151, 13, 1.7716965367527164, 0.8228303463247283),
(151, 13, 1.7934810363489488, 0.8206518963651052),
(151, 13, 1.8181272471987486, 0.8181872752801251),
(151, 13, 1.8458184304946816, 0.8154181569505319),
(151, 13, 1.876767429202236, 0.8123232570797765),
(151, 13, 1.9112211316817869, 0.8088778868318214),
(151, 12, 1.949465798554368, 0.8050534201445633),
(151, 12, 1.9918332863340396, 0.8008166713665961),
(151, 12, 2.0387089690575677, 0.7961291030942432),
(151, 12, 2.0054235864692225, 0.7994576413530778),
(151, 13, 1.9140926223573742, 0.8085907377642625),
(151, 13, 1.832927119961525, 0.8167072880038475),
(151, 13, 1.7604929736783075, 0.8239507026321693),
(151, 13, 1.6956213995870806, 0.8304378600412919),
(151, 13, 1.637350561557506, 0.8362649438442494),
(151, 14, 1.5848822220366188, 0.8415117777963381),
(151, 14, 1.5375492910943342, 0.8462450708905666),
(151, 14, 1.4947903656360915, 0.8505209634363908),
(151, 14, 1.4561303674579862, 0.8543869632542014),
(151, 14, 1.4211653031102505, 0.857883469688975)]
In [11]:
get_senses(robot)
Out[11]:
[[0.1461228864206821, 0.12172244605589383],
[2.6372377111130882,
2.854330863239106,
2.0527609659953323,
1.5421885828814874,
1.4881493361730065,
1.8251022517793707,
1.1900404307087387,
1.0197245152096421,
1.0079192040998226,
1.1047337454336814,
1.5508853769772477,
2.205636881674792,
2.130937951766538,
1.2567712693888453,
3.0386776706954968,
2.6490431220491546]]
In [12]:
def generate_data(robot, make_world, trials, filename):
sim = Simulator(robot, make_world)
fp = open(filename, "w")
for i in range(trials):
#print("Trial %d" % i)
random_start(robot)
while True:
senses = get_senses(robot)
translate, rotate = determine_move(senses)
if translate == 0 and rotate == 0:
break # found light, so end trial
robot.move(translate, rotate)
sim.step()
lights = senses[0]
sonars = [min(v/3.0, 1.0) for v in senses[1]] #normalize sonar values
for value in lights:
fp.write("%.3f " % value)
for value in sonars[1:7]:
fp.write("%.3f " % value)
fp.write("%.1f %.1f\n" % (translate, rotate))
fp.close()
In [13]:
generate_data(robot, make_world, 5, "testing_data.txt")
jyro¶
jyro package¶
Subpackages¶
jyro.simulator package¶
Submodules¶
jyro.simulator.canvas module¶
jyro.simulator.color module¶
jyro.simulator.device module¶
-
class
jyro.simulator.device.
Camera
(width=60, height=40, field=120)[source]¶ Bases:
jyro.simulator.device.Device
-
class
jyro.simulator.device.
DepthCamera
(maxDist, *args, **kwargs)[source]¶ Bases:
jyro.simulator.device.Camera
-
class
jyro.simulator.device.
Device
(type)[source]¶ Bases:
object
-
class
jyro.simulator.device.
Gripper
[source]¶ Bases:
jyro.simulator.device.Device
-
class
jyro.simulator.device.
LightSensor
(geometry, maxRange, noise=0.0)[source]¶ Bases:
jyro.simulator.device.Device
-
class
jyro.simulator.device.
RangeSensor
(name, geometry, arc, maxRange, noise=0.0)[source]¶ Bases:
jyro.simulator.device.Device
jyro.simulator.robot module¶
-
class
jyro.simulator.robot.
Blimp
(*args, **kwargs)[source]¶ Bases:
jyro.simulator.robot.Robot
-
class
jyro.simulator.robot.
Pioneer
(name, x, y, a, color='red')[source]¶ Bases:
jyro.simulator.robot.Robot
-
class
jyro.simulator.robot.
Puck
(*args, **kwargs)[source]¶ Bases:
jyro.simulator.robot.Robot
-
class
jyro.simulator.robot.
Robot
(name, x, y, a, boundingBox=None, color='red')[source]¶ Bases:
object
-
class
jyro.simulator.robot.
Scribbler
(name, x, y, a, color='red')[source]¶ Bases:
jyro.simulator.robot.Robot
jyro.simulator.simulator module¶
A Pure Python 2D Robot Simulator
- 2017 Calysto Developers. Licensed under the GNU GPL.
-
class
jyro.simulator.simulator.
Box
(ul, lr, outline='black', fill='white')[source]¶ Bases:
jyro.simulator.simulator.Shape
>>> box = Box((0, 10), (5, 0)) >>> box.max_min() ((5, 10), (0, 0))
-
class
jyro.simulator.simulator.
Light
(x, y, brightness, color)[source]¶ Bases:
object
A light source.
Parameters: Example
>>> lgt = Light(3, 2, 1.0, Color(100,100,100)) >>> lgt.reset()
-
class
jyro.simulator.simulator.
Physics
[source]¶ Bases:
object
>>> physics = Physics()
-
class
jyro.simulator.simulator.
Segment
(start, end, id=None, type=None)[source]¶ Bases:
object
Represent a line segment.
>>> segment = Segment((0,0), (0,10), 42, "wall") >>> segment.length() 10.0
-
class
jyro.simulator.simulator.
SequenceViewer
(title, function, length, play_rate=0.5)[source]¶ Bases:
ipywidgets.widgets.widget_box.VBox
-
class
jyro.simulator.simulator.
Simulator
(robot=None, worldf=None, size=None, gamepad=False, trace=False)[source]¶ Bases:
object
>>> from jyro.simulator import (Pioneer, Simulator, Camera, ... PioneerFrontSonars, Gripper, ... PioneerFrontLightSensors) >>> def worldf(sim): ... sim.addBox(0, 0, 10, 10, fill="white", wallcolor="grey") # meters ... sim.addBox(1, 1, 2, 2, "purple") ... sim.addBox(7, 7, 8, 8, "purple") ... ## brightness of 1 is radius 1 meter ... sim.addLight(7, 7, 4.25, color=Color(255, 255, 0, 64))
>>> robot = Pioneer("Pioneer", 5.00, 5.00, math.pi / 2) # meters, radians >>> robot.addDevice(PioneerFrontSonars(maxRange=4.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Gripper()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(PioneerFrontLightSensors(maxRange=1.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Camera()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.brain = lambda self: self.move(1, 1)
>>> sim = Simulator(robot, worldf) >>> for i in range(10): ... sim.step() ... sim.canvas.save("canvas%d.svg" % i)
-
makeCanvas
()[source]¶ >>> def worldf(physics): ... physics.addBox(0, 5, 10, 0) >>> sim = Simulator(worldf=worldf) >>> sim.makeCanvas() <jyro.simulator.canvas.Canvas object at ...>
-
movie
(poses, function, movie_name=None, start=0, stop=None, step=1, loop=0, optimize=True, duration=100, embed=False, mp4=True)[source]¶ Make a movie from a list of poses and a function.
function(simulator, index) and returns a displayable.
>>> from jyro.simulator import (Pioneer, Simulator, Camera, ... PioneerFrontSonars, Gripper, ... PioneerFrontLightSensors) >>> def worldf(sim): ... sim.addBox(0, 0, 10, 10, fill="white", wallcolor="grey") # meters ... sim.addBox(1, 1, 2, 2, "purple") ... sim.addBox(7, 7, 8, 8, "purple") ... ## brightness of 1 is radius 1 meter ... sim.addLight(7, 7, 4.25, color=Color(255, 255, 0, 64))
>>> robot = Pioneer("Pioneer", 5.00, 5.00, math.pi / 2) # meters, radians >>> robot.addDevice(PioneerFrontSonars(maxRange=4.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Gripper()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(PioneerFrontLightSensors(maxRange=1.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Camera()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.brain = lambda self: self.move(1, 1) >>> sim = Simulator(robot, worldf)
>>> from IPython.display import SVG >>> def function(simulator, index): ... cam_image = simulator.get_image() ... return simulator.canvas.render("pil") >>> sim.movie([(0,0,0), (0,1,0)], function, movie_name="/tmp/movie.gif", mp4=False) <IPython.core.display.Image object>
-
playback
(poses, function, play_rate=0.0)[source]¶ Playback a list of poses.
function(simulator) and returns displayable(s).
>>> from jyro.simulator import (Pioneer, Simulator, Camera, ... PioneerFrontSonars, Gripper, ... PioneerFrontLightSensors) >>> def worldf(sim): ... sim.addBox(0, 0, 10, 10, fill="white", wallcolor="grey") # meters ... sim.addBox(1, 1, 2, 2, "purple") ... sim.addBox(7, 7, 8, 8, "purple") ... ## brightness of 1 is radius 1 meter ... sim.addLight(7, 7, 4.25, color=Color(255, 255, 0, 64))
>>> robot = Pioneer("Pioneer", 5.00, 5.00, math.pi / 2) # meters, radians >>> robot.addDevice(PioneerFrontSonars(maxRange=4.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Gripper()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(PioneerFrontLightSensors(maxRange=1.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Camera()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.brain = lambda self: self.move(1, 1) >>> sim = Simulator(robot, worldf)
>>> from IPython.display import SVG >>> def function(simulator, index): ... cam_image = simulator.get_image() ... return (simulator.canvas.render("pil"), ... cam_image.resize((cam_image.size[0] * 4, ... cam_image.size[1] * 4))) >>> sv = sim.playback([(0,0,0), (0,1,0)], function)
-
-
class
jyro.simulator.simulator.
VSimulator
(robot=None, worldf=None, size=None, gamepad=False, trace=False)[source]¶ Bases:
jyro.simulator.simulator.Simulator
>>> from jyro.simulator import (Pioneer, Simulator, Camera, ... PioneerFrontSonars, Gripper, ... PioneerFrontLightSensors) >>> def worldf(sim): ... sim.addBox(0, 0, 10, 10, fill="white", wallcolor="grey") # meters ... sim.addBox(1, 1, 2, 2, "purple") ... sim.addBox(7, 7, 8, 8, "purple") ... ## brightness of 1 is radius 1 meter ... sim.addLight(7, 7, 4.25, color=Color(255, 255, 0, 64))
>>> robot = Pioneer("Pioneer", 5.00, 5.00, math.pi / 2) # meters, radians >>> robot.addDevice(PioneerFrontSonars(maxRange=4.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Gripper()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(PioneerFrontLightSensors(maxRange=1.0)) <jyro.simulator.robot.Pioneer object at ...> >>> robot.addDevice(Camera()) <jyro.simulator.robot.Pioneer object at ...> >>> robot.brain = lambda self: self.move(1, 1)
>>> sim = VSimulator(robot, worldf) VBox(...) >>> for i in range(10): ... sim.step() ... sim.canvas.save("canvas%d.svg" % i)
-
jyro.simulator.simulator.
gif2mp4
(filename)[source]¶ Convert an animated gif into a mp4, to show with controls.