def __init__(self, simulator=None, camera=False): """Constructeur de la classe Cherry Param : simulator -- Mettre simulator='vrep' si vous voulez utiliser Vrep (None par défault) camera -- Utilisation de la camera ou non (True par défault) """ if simulator is not None: self.robot = PoppyHumanoid(simulator='vrep') self.isCamera = False else: # TODO : Changer avec robot = PoppyTorso() self.robot = from_json( "../resource/mandatory/poppy_torso_config.json") self.robot.start_sync() for m in self.robot.motors: m.moving_speed = 60 for m in self.robot.torso: m.compliant = False if camera: imagePath = "../utils/img/" cascadePath = "../utils/haarcascade_frontalface_default.xml" self.camera = Camera(self.robot, imagePath, cascadePath) self.isCamera = True else: self.isCamera = False
class Cherry(): # TODO : Voir avec pierre si Cherry() puis self.robot ou Cherry(PoppyTorso) def __init__(self, simulator=None, camera=False): """Constructeur de la classe Cherry Param : simulator -- Mettre simulator='vrep' si vous voulez utiliser Vrep (None par défault) camera -- Utilisation de la camera ou non (True par défault) """ if simulator is not None: self.robot = PoppyHumanoid(simulator='vrep') self.isCamera = False else: # TODO : Changer avec robot = PoppyTorso() self.robot = from_json("../resource/mandatory/poppy_torso_config.json") self.robot.start_sync() for m in self.robot.motors: m.moving_speed = 60 for m in self.robot.torso: m.compliant = False if camera: imagePath = "../utils/img/" cascadePath = "../utils/haarcascade_frontalface_default.xml" self.camera = Camera( self.robot, imagePath, cascadePath) self.isCamera = True else: self.isCamera = False def setup(self): """ Initialisation de Cherry. Attachements des primitives, initialisation de la camera si besoin """ robot = self.robot for m in robot.motors: m.compliant_behavior = 'safe' m.goto_behavior = 'minjerk' attach_primitives(self, self.isCamera)
class Cherry(): # TODO : Voir avec pierre si Cherry() puis self.robot ou Cherry(PoppyTorso) def __init__(self, simulator=None, camera=False): """Constructeur de la classe Cherry Param : simulator -- Mettre simulator='vrep' si vous voulez utiliser Vrep (None par défault) camera -- Utilisation de la camera ou non (True par défault) """ if simulator is not None: self.robot = PoppyHumanoid(simulator='vrep') self.isCamera = False else: # TODO : Changer avec robot = PoppyTorso() self.robot = from_json( "../resource/mandatory/poppy_torso_config.json") self.robot.start_sync() for m in self.robot.motors: m.moving_speed = 60 for m in self.robot.torso: m.compliant = False if camera: imagePath = "../utils/img/" cascadePath = "../utils/haarcascade_frontalface_default.xml" self.camera = Camera(self.robot, imagePath, cascadePath) self.isCamera = True else: self.isCamera = False def setup(self): """ Initialisation de Cherry. Attachements des primitives, initialisation de la camera si besoin """ robot = self.robot for m in robot.motors: m.compliant_behavior = 'safe' m.goto_behavior = 'minjerk' attach_primitives(self, self.isCamera)
def __init__(self, simulator=None, camera=False): """Constructeur de la classe Cherry Param : simulator -- Mettre simulator='vrep' si vous voulez utiliser Vrep (None par défault) camera -- Utilisation de la camera ou non (True par défault) """ if simulator is not None: self.robot = PoppyHumanoid(simulator='vrep') self.isCamera = False else: # TODO : Changer avec robot = PoppyTorso() self.robot = from_json("../resource/mandatory/poppy_torso_config.json") self.robot.start_sync() for m in self.robot.motors: m.moving_speed = 60 for m in self.robot.torso: m.compliant = False if camera: imagePath = "../utils/img/" cascadePath = "../utils/haarcascade_frontalface_default.xml" self.camera = Camera( self.robot, imagePath, cascadePath) self.isCamera = True else: self.isCamera = False
def __init__(self, simulator=None): if simulator is not None: self.robot = PoppyHumanoid(simulator='vrep') self.isCamera = False #Vrai : else: self.robot = from_json("../utils/poppy_torso_config.json") self.robot.start_sync() for m in self.robot.motors: m.moving_speed = 60 for m in self.robot.torso: m.compliant = False imagePath = "../utils/img/" cascadePath = "haarcascade_frontalface_default.xml" self.camera = Camera( self.robot, imagePath, cascadePath) self.isCamera = True
# http://nbviewer.jupyter.org/github/jjehl/poppy_balance/blob/master/test_balance_2.ipynb from poppy.creatures import PoppyHumanoid poppy = PoppyHumanoid(simulator='vrep') %pylab inline import time list_pos_x = [] list_pos_y = [] list_pos_z = [] t= [] #poppy.r_hip_y.goto_position(-50, 4) #poppy.r_knee_y.goto_position(50, 4) poppy.l_shoulder_y.goto_behavior = 'minjerk' poppy.r_shoulder_y.goto_behavior = 'minjerk' poppy.l_shoulder_x.goto_behavior = 'minjerk' poppy.r_shoulder_x.goto_behavior = 'minjerk' poppy.l_shoulder_x.goto_position(10, 2, wait=True) poppy.l_shoulder_y.goto_position(10, 2, wait=True) poppy.r_shoulder_x.goto_position(-10, 2, wait=True) poppy.r_shoulder_y.goto_position(10, 2, wait=True) poppy.l_shoulder_y.goto_position(80, 4) poppy.r_shoulder_y.goto_position(80, 4)
import socket import itertools import time import serial import pypot.vrep from pypot.vrep import from_vrep from poppy.creatures import PoppyHumanoid HOST = '127.0.0.1' PORT = 50007 # Arbitrary non-privileged port pypot.vrep.close_all_connections() poppy = PoppyHumanoid(simulator='vrep') #connection à simulateur print ('Connection reussi avec POPPY HUMANOID') poppy.compliant = False poppy.power_up() # Change PID of Dynamixel MX motors for m in filter(lambda m: hasattr(m, 'pid'), poppy.motors): m.pid = (1, 8, 0) for m in poppy.torso: m.pid = (6, 2, 0) # Reduce max torque to keep motor temperature low for m in poppy.motors: m.torque_limit = 70
# http://nbviewer.jupyter.org/github/jjehl/poppy_balance/blob/master/balance_leg.ipynb http://nbviewer.jupyter.org/github/jjehl/poppy_balance/blob/master/balance_leg_math.ipynb """ A method to use the present_load to balance the leg of poppy """ from poppy.creatures import PoppyHumanoid poppy = PoppyHumanoid(simulator='vrep') %pylab inline #import time """ Populating the interactive namespace from numpy and matplotlib A trick to switch from real time to simulated time using time function (because my VREP is not in real time - about 3 times slower) """ import time as real_time class time: def __init__(self,robot): self.robot=robot def time(self): t_simu = self.robot.current_simulation_time return t_simu def sleep(self,t): t0 = self.robot.current_simulation_time while (self.robot.current_simulation_time - t0) < t-0.01: real_time.sleep(0.001) time = time(poppy) print time.time()
class Cherry(): def __init__(self, simulator=None): if simulator is not None: self.robot = PoppyHumanoid(simulator='vrep') self.isCamera = False #Vrai : else: self.robot = from_json("../utils/poppy_torso_config.json") self.robot.start_sync() for m in self.robot.motors: m.moving_speed = 60 for m in self.robot.torso: m.compliant = False imagePath = "../utils/img/" cascadePath = "haarcascade_frontalface_default.xml" self.camera = Camera( self.robot, imagePath, cascadePath) self.isCamera = True def setup(self): robot = self.robot for m in robot.motors: m.compliant_behavior = 'safe' m.goto_behavior = 'minjerk' #Attach your primitive here # robot.attach_primitive(UpperBodyIdleMotion(robot, 50), 'upper_body_idle') # robot.attach_primitive(HeadIdleMotion(robot, 50), "head_idle") # robot.attach_primitive(YesBehave(robot, 50), "yes_behave") # robot.attach_primitive(WaveBehave(robot, 50), "wave_behave") # robot.attach_primitive(NoBehave(robot, 50), "no_behave") # robot.attach_primitive(CrossArmsBehave(robot), "cross_arms_behave") # robot.attach_primitive(CrossHandsBehave(robot), "cross_hands_behave") # robot.attach_primitive(ShowLeftBehave(robot), "show_left_behave") # robot.attach_primitive(ShowRightBehave(robot), "show_right_behave") # robot.attach_primitive(ShowFrontBehave(robot), "show_front_behave") # robot.attach_primitive(TakeHeadBehave(robot), "take_head_behave") # robot.attach_primitive(TakeLeftEarBehave(robot), "take_left_ear_behave") # robot.attach_primitive(TakeRightEarBehave(robot), "take_right_ear_behave") # robot.attach_primitive(RightHandMouvBehave(robot, 50), "right_hand_mouv_behave") # robot.attach_primitive(ComeMouvBehave(robot, 50), "come_mouv_behave") # robot.attach_primitive(KeepFrontMouvBehave(robot, 50), "keep_front_mouv_behave") # robot.attach_primitive(NormalBehave(robot), "normal_behave") # robot.attach_primitive(SaluteBehave(robot), "salute_behave") # robot.attach_primitive(ThinkBehave(robot), "think_behave") # robot.attach_primitive(CopyArmBehave(robot, 50), "copy_arm_behave") # robot.attach_primitive(BowBehave(robot), "bow_behave") # robot.attach_primitive(TalkOneBehave(robot), "talk_one_behave") # robot.attach_primitive(TalkTwoBehave(robot), "talk_two_behave") # robot.attach_primitive(TalkThreeBehave(robot), "talk_three_behave") # robot.attach_primitive(TalkFourBehave(robot), "talk_four_behave") # robot.attach_primitive(TrackingBehave(robot, self.camera, 50), "tracking_behave") # robot.attach_primitive(Speak(robot), "speak") # robot.attach_primitive(SayHello(robot), "say_hello") # robot.attach_primitive(SayText(robot), "say_text") # robot.attach_primitive(SadBehave(robot), "sad_behave") # robot.attach_primitive(RunLook(robot, self.camera, 50), "run_look") # robot.attach_primitive(Speech(robot), "speech") # robot.attach_primitive(Bonnard1(robot), "bonnard_1") # robot.attach_primitive(Bonnard2(robot), "bonnard_2") # robot.attach_primitive(Bonnard3(robot), "bonnard_3") # robot.attach_primitive(Bonnard4(robot), "bonnard_4") # robot.attach_primitive(Bonnard5(robot), "bonnard_5") # robot.attach_primitive(Bonnard6(robot), "bonnard_6") # # robot.attach_primitive(Eyes(robot), "eyes") # # robot.attach_primitive(Get_reaction(robot), "get_reaction") # # robot.attach_primitive(Get_fond(robot), "get_fond") # # robot.attach_primitive(Basic(robot), "basic") # # robot.attach_primitive(Blink(robot), "blink") # # robot.attach_primitive(Neutral2sleep(robot), "neutral2sleep") # # robot.attach_primitive(Sleep2neutral(robot), "sleep2neutral") # # robot.attach_primitive(Neutral2surprise(robot), "neutral2surprise") # # robot.attach_primitive(Surprise2neutral(robot), "surprise2neutral") # # robot.attach_primitive(Surprise(robot), "surprise") # # robot.attach_primitive(Sleepy(robot), "sleepy") # # robot.attach_primitive(Happy(robot), "happy") # # robot.attach_primitive(Neutral2happy(robot), "neutral2happy") # # robot.attach_primitive(Happy2neutral(robot), "happy2neutral") # # robot.attach_primitive(Neutral2sad(robot), "neutral2sad") # # robot.attach_primitive(Sad2neutral(robot), "sad2neutral") # # robot.attach_primitive(Sad(robot), "sad") attach_primitives(self, self.isCamera)
# http://nbviewer.jupyter.org/github/jjehl/poppy_balance/blob/master/test_VREP_force.ipynb from poppy.creatures import PoppyHumanoid poppy = PoppyHumanoid(simulator='vrep',scene='poppy_humanoid_add_force.ttt') %pylab inline import time """ Populating the interactive namespace from numpy and matplotlib """ t0 = time.time() t_simu = poppy.current_simulation_time while time.time()-t0 <10: if poppy.current_simulation_time - t_simu < 1 : time.sleep(0.01) else : poppy.set_VREP_force([7,0,0],'l_forearm_respondable') t_simu = poppy.current_simulation_time while poppy.current_simulation_time - t_simu < 0.025: time.sleep(0.01) poppy.set_VREP_force([0,0,0],'l_forearm_respondable')