def __init__(self): Lucy.__init__(self) self.comm_tty = CommSerial() self.comm_tty.connect() self.actuator = Actuator(self.comm_tty) self.defaultSpeed = 600 #TODO change this, use configuration files self.initialPoses = {} #checking communication with motors for joint in self.joints: jointID = self.robotConfiguration.loadJointId(joint) print jointID self.initialPoses[joint] = self.actuator.get_position(jointID).toDegrees() print jointID, joint, self.initialPoses[joint] time.sleep(0.1) self.actuator.led_state_change(jointID, 1) time.sleep(0.1) time.sleep(1) for joint in self.joints: self.actuator.led_state_change(self.robotConfiguration.loadJointId(joint), 0)
# but WITHOUT ANY WARRANTY; without even the implied warranty of # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import time import Communication from Communication import CommSimulator from Communication import CommSerial import Actuator from compiler.ast import Print #comm = CommSimulator() #TODO read a configuration file to use the correct parameters for CommSimulator comm_tty = CommSerial( ) #TODO read a configuration file to use the correct parameters for CommSimulator #comm.connect() comm_tty.connect() #actuator = Actuator.Actuator(comm) actuator_tty = Actuator.Actuator(comm_tty) motor_id = 6 print "actuator_tty.set_AngleLimit(motor_id, 0x0000, 0x0000)" actuator_tty.set_AngleLimit(motor_id, 0x0000, 0x0000) time.sleep(1) print "actuator_tty.setTorque(motor_id, False)" actuator_tty.setTorque(motor_id, False) time.sleep(1)
# it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import time import Communication from Communication import CommSerial import Actuator #comm = CommSimulator() #TODO read a configuration file to use the correct parameters for CommSimulator comm_tty = CommSerial() #TODO read a configuration file to use the correct parameters for CommSimulator #comm.connect() comm_tty.connect() #actuator = Actuator.Actuator(comm) actuator_tty = Actuator.Actuator(comm_tty) #actuator_tty.setear_id(1) idMotor = 6 #actuator_tty.setear_id(6) #actuator_tty.reset(idMotor) actuator_tty.test(idMotor)
''' Created on May 7, 2013 @author: matias ''' import time from Communication import CommSerial import Actuator comm_tty = CommSerial() comm_tty.connect() actuator = Actuator.Actuator(comm_tty) motor_id = 99 actuator.reset(0xfe) time.sleep(2) actuator.setear_id(motor_id) for i in range(1, 50): if (i%2 == 0): actuator.led_state_change(motor_id, 1) else: actuator.led_state_change(motor_id, 0) time.sleep(.1) #
class PhysicalLucy(Lucy): def __init__(self): Lucy.__init__(self) self.comm_tty = CommSerial() self.comm_tty.connect() self.actuator = Actuator(self.comm_tty) self.defaultSpeed = 600 #TODO change this, use configuration files self.initialPoses = {} #checking communication with motors for joint in self.joints: jointID = self.robotConfiguration.loadJointId(joint) print jointID self.initialPoses[joint] = self.actuator.get_position(jointID).toDegrees() print jointID, joint, self.initialPoses[joint] time.sleep(0.1) self.actuator.led_state_change(jointID, 1) time.sleep(0.1) time.sleep(1) for joint in self.joints: self.actuator.led_state_change(self.robotConfiguration.loadJointId(joint), 0) def getPosesExecutedByStepQty(self): return 1 def executePose(self, pose): #set positions and wait that the actuator reaching that position #TODO tener en cuenta los motores que están invertidos, creo que los únicos que están quedando son los de los hombros for joint in self.RobotImplementedJoints: if joint == "L_Hip_Pitch": angle = pose.getValue(joint) print "el angulo es: ", angle angleAX = AXAngle() angleAX.setDegreeValue(300 - angle) #TODO implement method for setting position of all actuators at the same time self.actuator.move_actuator(self.robotConfiguration.loadJointId(joint), int(angleAX.getValue()), self.defaultSpeed) self.poseExecuted = self.poseExecuted + 1 print "pose executed!" time.sleep(0.2) ''' for joint in self.RobotImplementedJoints: print "el joint se reporta como: ", joint angle = pose.getValue(joint) angleAX = AXAngle() angleAX.setDegreeValue(angle) #TODO implement method for setting position of all actuators at the same time self.actuator.move_actuator(self.robotConfiguration.loadJointId(joint), int(angleAX.getValue()), self.defaultSpeed) self.poseExecuted = self.poseExecuted + 1 print "pose executed!" time.sleep(0.05) ''' def stopLucy(self): pass ''' for joint in self.joints: self.actuator.move_actuator(self.robotConfiguration.loadJointId(joint), self.initialPoses[joint], self.defaultSpeed) ''' def getFrame(self): error = False pose = {} for joint in self.joints: value = self.actuator.get_position(self.robotConfiguration.loadJointId(joint)) pose[joint] = value return error, pose def getFitness(self, secuenceLength, concatenationGap): return 0 def isLucyUp(self): return True
class PhysicalLucy(Lucy): def __init__(self): Lucy.__init__(self) self.comm_tty = CommSerial() self.comm_tty.connect() self.actuator = Actuator.Actuator(self.comm_tty) self.defaultSpeed = 600 # TODO change this, use configuration files self.initialPoses = {} # checking communication with motors for joint in self.joints: jointID = self.robotConfiguration.loadJointId(joint) print jointID self.initialPoses[joint] = self.actuator.get_position(jointID).toDegrees() print jointID, joint, self.initialPoses[joint] time.sleep(0.1) self.actuator.led_state_change(jointID, 1) time.sleep(0.1) time.sleep(1) for joint in self.joints: self.actuator.led_state_change(self.robotConfiguration.loadJointId(joint), 0) def executePose(self, pose): # set positions and wait that the actuator reaching that position dontSupportedJoints = self.sysConf.getVrepNotImplementedBioloidJoints() RobotImplementedJoints = [] for joint in self.joints: if joint not in dontSupportedJoints: RobotImplementedJoints.append(joint) for joint in RobotImplementedJoints: angle = pose.getValue(joint) angleAX = AXAngle() angleAX.setDegreeValue(angle) # TODO implement method for setting position of all actuators at the same time self.actuator.move_actuator( self.robotConfiguration.loadJointId(joint), int(angleAX.getValue()), self.defaultSpeed ) self.poseExecuted = self.poseExecuted + 1 time.sleep(3) def stopLucy(self): for joint in self.joints: self.actuator.move_actuator( self.robotConfiguration.loadJointId(joint), self.initialPoses[joint], self.defaultSpeed ) def getFrame(self): error = False pose = {} for joint in self.joints: value = self.actuator.get_position(self.robotConfiguration.loadJointId(joint)) pose[joint] = value return error, pose def getFitness(self, endFrameExecuted=False): return 0 def isLucyUp(self): return True