def Create_World(): # box pyrosim.Start_SDF("world.sdf") # the world pyrosim.Send_Cube(name="Box", pos=[-2, 2, 0.5], size=[length, width, height]) # End pyrosim.End()
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_Body(): pyrosim.Start_URDF("body.urdf") pyrosim.Send_Cube(name="Torso", pos=[1,0,1.5], size=[length,width,height]) pyrosim.Send_Joint(name="Torso_BackLeg", parent="Torso", child="BackLeg", type="revolute", position="0.5 0 1.0") pyrosim.Send_Cube(name="BackLeg", pos=[-0.5,0,-0.5], size=[length,width,height]) pyrosim.Send_Joint(name="Torso_FrontLeg", parent="Torso", child="FrontLeg", type="revolute", position="1.5 0 1.0") pyrosim.Send_Cube(name="FrontLeg", pos=[0.5,0,-0.5], size=[length,width,height]) pyrosim.End()
def Generate_Body(): pyrosim.Start_URDF("body.urdf") # Robot Torso pyrosim.Send_Cube(name="Torso", pos=[1.5, 0, 1.5], size=[length, width, height]) # Connect BackLeg to Torso with one joint pyrosim.Send_Joint(name="Torso_FrontLeg", parent="Torso", child="FrontLeg", type="revolute", position="2.0 0.0 1.0") # Robot FrontLeg pyrosim.Send_Cube(name="FrontLeg", pos=[0.5, 0, -0.5], size=[length, width, height]) # Connect FrontLeg to Torso with a second joint. pyrosim.Send_Joint(name="Torso_BackLeg", parent="Torso", child="BackLeg", type="revolute", position="1.0 0.0 1.0") # The other BackLeg pyrosim.Send_Cube(name="BackLeg", pos=[-0.5, 0, -0.5], size=[length, width, height]) # End pyrosim.End()
def Create_World(): pyrosim.Start_SDF("world.sdf") length = 1 width = 1 height = 1 x = 5 y = 3 z = height / 2 pyrosim.Send_Cube(name="Box", pos=[x, y, z], size=[length, width, height]) 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") # 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 Create_Robot(): pyrosim.Start_URDF("body.urdf") pyrosim.Send_Cube(name="Torso", pos=[0, 0, 1.5], size=[1, 1, 1]) pyrosim.Send_Joint(name="Torso_Leg_F", parent="Torso", child="LegFront", type="revolute", position="0.5 0 1") pyrosim.Send_Cube(name="LegFront", pos=[0.5, 0, -.5], size=[1, 1, 1]) pyrosim.Send_Joint(name="Torso_Leg_B", parent="Torso", child="LegBack", type="revolute", position="-0.5 0 1") pyrosim.Send_Cube(name="LegBack", pos=[-0.5, 0, -.5], size=[1, 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()
def Create_World(): pyrosim.Start_SDF("world.sdf") pyrosim.Send_Cube(name="Box", pos=[4,4,z], size=[length,width,height]) pyrosim.End()
def Create_Body(self): pyrosim.Start_URDF("body.urdf") pyrosim.Send_Cube(name="Torso", pos=[0, 0, 1], size=[1, 1, 1]) pyrosim.Send_Joint(name="Torso_FrontLeg", parent="Torso", child="FrontLeg", type="revolute", position="0.0 0.5 1.0", jointAxis="1 0 0") pyrosim.Send_Cube(name="FrontLeg", pos=[0, 0.5, 0], size=[0.2, 1, 0.2]) pyrosim.Send_Joint(name="Torso_BackLeg", parent="Torso", child="BackLeg", type="revolute", position="0.0 -0.5 1.0", jointAxis="1 0 0") pyrosim.Send_Cube(name="BackLeg", pos=[0, -0.5, 0], size=[0.2, 1, 0.2]) # Left-leg pyrosim.Send_Joint(name="Torso_LeftLeg", parent="Torso", child="LeftLeg", type="revolute", position="-0.5 0.0 1.0", jointAxis="0 1 0") pyrosim.Send_Cube(name="LeftLeg", pos=[-0.5, 0, 0], size=[1, 0.2, 0.2]) # Right-leg pyrosim.Send_Joint(name="Torso_RightLeg", parent="Torso", child="RightLeg", type="revolute", position="0.5 0.0 1.0", jointAxis="0 1 0") pyrosim.Send_Cube(name="RightLeg", pos=[0.5, 0, 0], size=[1, 0.2, 0.2]) # front lower leg pyrosim.Send_Joint(name="FrontLeg_FrontLowerLeg", parent="FrontLeg", child="FrontLowerLeg", type="revolute", position="0.0 1.0 0.0", jointAxis="1 0 0") pyrosim.Send_Cube(name="FrontLowerLeg", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) # back lower leg pyrosim.Send_Joint(name="BackLeg_BackLowerLeg", parent="BackLeg", child="BackLowerLeg", type="revolute", position="0.0 -1.0 0.0", jointAxis="1 0 0") pyrosim.Send_Cube(name="BackLowerLeg", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) # left lower leg pyrosim.Send_Joint(name="LeftLeg_LeftLowerLeg", parent="LeftLeg", child="LeftLowerLeg", type="revolute", position="-1.0 0.0 0.0", jointAxis="0 1 0") pyrosim.Send_Cube(name="LeftLowerLeg", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) # right lower leg pyrosim.Send_Joint(name="RightLeg_RightLowerLeg", parent="RightLeg", child="RightLowerLeg", type="revolute", position="1.0 0.0 0.0", jointAxis="0 1 0") pyrosim.Send_Cube(name="RightLowerLeg", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) pyrosim.End()
def Create_World(self): pyrosim.Start_SDF("world.sdf") pyrosim.Send_Cube(name="Box", pos=[-2, 2, 0.5], size=[1, 1, 1]) pyrosim.End()
def Create_Robot(self): pyrosim.Start_URDF("body.urdf") pyrosim.Send_Cube(name="Torso", pos=[0, 0, 1], size=[1, 1, 0.5]) #Front Leg pyrosim.Send_Joint(name="Torso_Leg_F", parent="Torso", child="LegFront", type="revolute", position="0 0.5 1", jointAxis='1 0 0') pyrosim.Send_Cube(name="LegFront", pos=[0, 0.5, 0], size=[0.2, 1, 0.2]) pyrosim.Send_Joint(name="Leg_F_Leg_LF", parent="LegFront", child="LegLowerFront", type="revolute", position="0 1 0", jointAxis='0 1 0') pyrosim.Send_Cube(name="LegLowerFront", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) #Back Leg pyrosim.Send_Joint(name="Torso_Leg_B", parent="Torso", child="LegBack", type="revolute", position="0 -0.5 1", jointAxis='1 0 0') pyrosim.Send_Cube(name="LegBack", pos=[0, -0.5, 0], size=[0.2, 1, 0.2]) pyrosim.Send_Joint(name="Leg_B_Leg_LB", parent="LegBack", child="LegLowerBack", type="revolute", position="0 -1 0", jointAxis='0 1 0') pyrosim.Send_Cube(name="LegLowerBack", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) # Right Leg pyrosim.Send_Joint(name="Torso_Leg_R", parent="Torso", child="LegRight", type="revolute", position="0.5 0 1", jointAxis='0 1 0') pyrosim.Send_Cube(name="LegRight", pos=[0.5, 0, 0], size=[1, 0.2, 0.2]) pyrosim.Send_Joint(name="Leg_R_Leg_LR", parent="LegRight", child="LegLowerRight", type="revolute", position="1 0 0", jointAxis='1 0 0') pyrosim.Send_Cube(name="LegLowerRight", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) # Left Leg pyrosim.Send_Joint(name="Torso_Leg_L", parent="Torso", child="LegLeft", type="revolute", position="-0.5 0 1", jointAxis='0 1 0') pyrosim.Send_Cube(name="LegLeft", pos=[-0.5, 0, 0], size=[1, 0.2, 0.2]) pyrosim.Send_Joint(name="Leg_L_Leg_LL", parent="LegLeft", child="LegLowerLeft", type="revolute", position="-1 0 0", jointAxis='1 0 0') pyrosim.Send_Cube(name="LegLowerLeft", pos=[0, 0, -0.5], size=[0.2, 0.2, 1]) pyrosim.End()
import pyrosim.pyrosim as pyrosim pyrosim.Start_SDF("box.sdf") pyrosim.Send_Cube(name="Box", pos=[0,0,0.5] , size=[1,1,1]) pyrosim.End()