Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import unittest
from pypot.creatures import PoppyErgoJr
from pypot.primitive import LoopPrimitive
class EmptyPrim(LoopPrimitive):
def setup(self):
pass
def update(self):
pass
def teardown(self):
pass
class TestDummy(unittest.TestCase):
def setUp(self):
self.jr = PoppyErgoJr(simulator='dummy')
def test_dummy_controller(self):
for m in self.jr.motors:
def test_set_once(self):
class Switcher(LoopPrimitive):
def setup(self):
self.current_state = False
self.old_state = self.current_state
def update(self):
if self.current_state != self.old_state:
for m in self.robot.motors:
self.affect_once(m, 'led',
'red' if self.current_state else 'off')
self.old_state = self.current_state
p = Switcher(self.jr, 10)
p.start()
for m in self.jr.motors:
def __init__(self, robot, freq):
pypot.primitive.LoopPrimitive.__init__(self, robot, freq)
sinus_args = [{'motor_list': [self.robot.head_z, ], 'amp': 20, 'freq': 0.05},
{'motor_list': [self.robot.head_z, ], 'amp': 15, 'freq': 0.1},
{'motor_list': [self.robot.head_y, ], 'amp': 20, 'freq': 0.04},
{'motor_list': [self.robot.head_y, ], 'amp': 5, 'freq': 0.09}]
self.head_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
from __future__ import division
import pypot.primitive
from pypot.primitive.utils import Sinus
class UpperBodyIdleMotion(pypot.primitive.LoopPrimitive):
def __init__(self, robot, freq):
pypot.primitive.LoopPrimitive.__init__(self, robot, freq)
sinus_args = [{'motor_list': [self.robot.r_shoulder_x, ], 'amp': 2, 'freq': 0.2, 'offset': -5, 'phase': 66},
{'motor_list': [self.robot.r_shoulder_x, ], 'amp': 0.8, 'freq': 0.5, 'offset': 0, 'phase': 66},
{'motor_list': [self.robot.r_elbow_y, ], 'amp': 2, 'freq': 0.5, 'offset': -25, 'phase': 75},
{'motor_list': [self.robot.r_elbow_y, ], 'amp': 0.3, 'freq': 0.2, 'phase': 75},
{'motor_list': [self.robot.r_arm_z, ], 'amp': 3, 'freq': 0.2, 'phase':78}]
self.all_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def setup(self):
for m in self.robot.r_arm:
m.compliant = False
[all_sinus.start() for all_sinus in self.all_sinus]
self.all_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def setup(self):
for m in self.robot.r_arm:
m.compliant = False
[all_sinus.start() for all_sinus in self.all_sinus]
def teardown(self):
[all_sinus.stop() for all_sinus in self.all_sinus]
def update(self):
pass
class HeadIdleMotion(pypot.primitive.LoopPrimitive):
def __init__(self, robot, freq):
pypot.primitive.LoopPrimitive.__init__(self, robot, freq)
sinus_args = [{'motor_list': [self.robot.head_z, ], 'amp': 20, 'freq': 0.05},
{'motor_list': [self.robot.head_z, ], 'amp': 15, 'freq': 0.1},
{'motor_list': [self.robot.head_y, ], 'amp': 20, 'freq': 0.04},
{'motor_list': [self.robot.head_y, ], 'amp': 5, 'freq': 0.09}]
self.head_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def start(self):
pypot.primitive.LoopPrimitive.start(self)
for m in self.robot.head:
m.compliant = False
self.all_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def setup(self):
for m in self.robot.r_arm:
m.compliant = False
[all_sinus.start() for all_sinus in self.all_sinus]
def teardown(self):
[all_sinus.stop() for all_sinus in self.all_sinus]
def update(self):
pass
class HeadIdleMotion(pypot.primitive.LoopPrimitive):
def __init__(self, robot, freq):
pypot.primitive.LoopPrimitive.__init__(self, robot, freq)
sinus_args = [{'motor_list': [self.robot.head_z, ], 'amp': 20, 'freq': 0.05},
{'motor_list': [self.robot.head_z, ], 'amp': 15, 'freq': 0.1},
{'motor_list': [self.robot.head_y, ], 'amp': 20, 'freq': 0.04},
{'motor_list': [self.robot.head_y, ], 'amp': 5, 'freq': 0.09}]
self.head_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def start(self):
pypot.primitive.LoopPrimitive.start(self)
for m in self.robot.head:
m.compliant = False
def start(self):
pypot.primitive.LoopPrimitive.start(self)
for m in self.robot.head:
m.compliant = False
[hs.start() for hs in self.head_sinus]
def __init__(self, robot, freq):
pypot.primitive.LoopPrimitive.__init__(self, robot, freq)
sinus_args = [{'motor_list': [self.robot.head_z, ], 'amp': 20, 'freq': 0.05},
{'motor_list': [self.robot.head_z, ], 'amp': 15, 'freq': 0.1},
{'motor_list': [self.robot.head_y, ], 'amp': 20, 'freq': 0.04},
{'motor_list': [self.robot.head_y, ], 'amp': 5, 'freq': 0.09}]
self.head_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def start(self):
pypot.primitive.LoopPrimitive.start(self)
for m in self.robot.head:
m.compliant = False
[hs.start() for hs in self.head_sinus]
from __future__ import division
import pypot.primitive
from pypot.primitive.utils import Sinus
class UpperBodyIdleMotion(pypot.primitive.LoopPrimitive):
def __init__(self, robot, freq):
pypot.primitive.LoopPrimitive.__init__(self, robot, freq)
sinus_args = [{'motor_list': [self.robot.r_shoulder_x, ], 'amp': 2, 'freq': 0.2, 'offset': -5, 'phase': 66},
{'motor_list': [self.robot.r_shoulder_x, ], 'amp': 0.8, 'freq': 0.5, 'offset': 0, 'phase': 66},
{'motor_list': [self.robot.r_elbow_y, ], 'amp': 2, 'freq': 0.5, 'offset': -25, 'phase': 75},
{'motor_list': [self.robot.r_elbow_y, ], 'amp': 0.3, 'freq': 0.2, 'phase': 75},
{'motor_list': [self.robot.r_arm_z, ], 'amp': 3, 'freq': 0.2, 'phase':78}]
self.all_sinus = [Sinus(self.robot, 50, **s) for s in sinus_args]
def setup(self):
for m in self.robot.r_arm:
m.compliant = False
[all_sinus.start() for all_sinus in self.all_sinus]