def Generate_Brain(self): pyrosim.Start_NeuralNetwork("brain" + str(self.myID) + ".nndf") # pyrosim.Send_Sensor_Neuron(name=0, linkName="Torso") # pyrosim.Send_Sensor_Neuron(name=1, linkName="BackLeg") # pyrosim.Send_Sensor_Neuron(name=2, linkName="FrontLeg") # pyrosim.Send_Motor_Neuron(name=3, jointName="Torso_BackLeg") # pyrosim.Send_Motor_Neuron(name=4, jointName="Torso_FrontLeg") pyrosim.Send_Sensor_Neuron(name=0, linkName="FrontLowerLeg") pyrosim.Send_Sensor_Neuron(name=1, linkName="BackLowerLeg") pyrosim.Send_Sensor_Neuron(name=2, linkName="LeftLowerLeg") pyrosim.Send_Sensor_Neuron(name=3, linkName="RightLowerLeg") pyrosim.Send_Motor_Neuron(name=4, jointName="Torso_BackLeg") pyrosim.Send_Motor_Neuron(name=5, jointName="Torso_FrontLeg") pyrosim.Send_Motor_Neuron(name=6, jointName="Torso_LeftLeg") pyrosim.Send_Motor_Neuron(name=7, jointName="Torso_RightLeg") pyrosim.Send_Motor_Neuron(name=8, jointName="BackLeg_BackLowerLeg") pyrosim.Send_Motor_Neuron(name=9, jointName="FrontLeg_FrontLowerLeg") pyrosim.Send_Motor_Neuron(name=10, jointName="LeftLeg_LeftLowerLeg") pyrosim.Send_Motor_Neuron(name=11, jointName="RightLeg_RightLowerLeg") for currentRow in range(c.numSensorNeurons): for currentColumn in range(c.numMotorNeurons): pyrosim.Send_Synapse( sourceNeuronName=currentRow, targetNeuronName=currentColumn + c.numSensorNeurons, weight=self.weights[currentRow][currentColumn]) pyrosim.End() while not os.path.exists("brain" + str(self.myID) + ".nndf"): time.sleep(0.01)
def generate_brain(self): pyrosim.Start_NeuralNetwork("brains/brain" + str(self.myID) + ".nndf") linkNames = pyrosim.Get_Link_Names("body.urdf") SensorNames = [name for name in linkNames if "Lower" in name] jointNames = pyrosim.Get_Joint_Names("body.urdf") self.numSensorNeuron = len(SensorNames) self.numMotorNeuron = len(jointNames) NextAvailableName = 0 for link in range(self.numSensorNeuron): pyrosim.Send_Sensor_Neuron(name=NextAvailableName, linkName=SensorNames[link]) NextAvailableName += 1 for joint in range(self.numMotorNeuron): pyrosim.Send_Motor_Neuron(name=NextAvailableName, jointName=jointNames[joint]) NextAvailableName += 1 for sensor in range(self.numSensorNeuron): for motor in range(self.numMotorNeuron): pyrosim.Send_Synapse(sourceNeuronName=sensor, targetNeuronName=motor + self.numSensorNeuron, weight=self.weight[sensor, motor]) pyrosim.End()
def generate_brain(): pyrosim.Start_NeuralNetwork("brain.nndf") pyrosim.Send_Sensor_Neuron(name=0, linkName="Torso") pyrosim.Send_Sensor_Neuron(name=2, linkName="LegFront") pyrosim.Send_Sensor_Neuron(name=1, linkName="LegBack") pyrosim.Send_Motor_Neuron(name=3, jointName="Torso_Leg_B") pyrosim.Send_Motor_Neuron(name=4, jointName="Torso_Leg_F") for sensor in range(3): for motor in range(2): pyrosim.Send_Synapse(sourceNeuronName=sensor, targetNeuronName=motor + 3, weight=(random.random() - 0.5) * 2)
def Generate_Brain(): pyrosim.Start_NeuralNetwork("brain.nndf") pyrosim.Send_Sensor_Neuron(name = 0, linkName = "Torso") pyrosim.Send_Sensor_Neuron(name = 1, linkName = "BackLeg") pyrosim.Send_Sensor_Neuron(name = 2, linkName = "FrontLeg") pyrosim.Send_Motor_Neuron(name = 3, jointName = "Torso_BackLeg") pyrosim.Send_Motor_Neuron(name = 4, jointName = "Torso_FrontLeg") # pyrosim.Send_Synapse( sourceNeuronName=0, targetNeuronName=3, weight=-1.0 ) # pyrosim.Send_Synapse( sourceNeuronName=1, targetNeuronName=3, weight=-1.0 ) # pyrosim.Send_Synapse( sourceNeuronName=0, targetNeuronName=4, weight=-1.0 ) # pyrosim.Send_Synapse( sourceNeuronName=2, targetNeuronName=4, weight=-1.0 ) for i in {0, 1, 2}: for j in {3, 4}: pyrosim.Send_Synapse( sourceNeuronName=i, targetNeuronName=j, weight=random.uniform(-1, 1) ) pyrosim.End()
def Generate_Brain(): pyrosim.Start_NeuralNetwork("brain.nndf") pyrosim.Send_Sensor_Neuron(name=0, linkName="Torso") pyrosim.Send_Sensor_Neuron(name=1, linkName="BackLeg") pyrosim.Send_Sensor_Neuron(name=2, linkName="FrontLeg") pyrosim.Send_Motor_Neuron(name=3, jointName="Torso_BackLeg") pyrosim.Send_Motor_Neuron(name=4, jointName="Torso_FrontLeg") # Synapses # pyrosim.Send_Synapse(sourceNeuronName=0, targetNeuronName=3, weight=-0.5) # pyrosim.Send_Synapse(sourceNeuronName=1, targetNeuronName=3, weight=-1.0) # pyrosim.Send_Synapse(sourceNeuronName=0, targetNeuronName=4, weight=-1.0) # pyrosim.Send_Synapse(sourceNeuronName=2, targetNeuronName=4, weight=-0.5) # pyrosim.End() # random research for sensor_neurons in range(0, 3): # iterate over the names of the three sensor neurons. for motor_neurons in range(4, 5): # iterate over each of the two motor neurons pyrosim.Send_Synapse(sourceNeuronName=sensor_neurons, targetNeuronName=motor_neurons, weight=random.randrange(-1, 1)) pyrosim.End()