-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.py
More file actions
55 lines (38 loc) · 1.73 KB
/
generate.py
File metadata and controls
55 lines (38 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pyrosim.pyrosim as pyrosim
import random
length = 1
width = 1
height = 1
x = 0
y = 0
z = 0.5
def Create_World():
pyrosim.Start_SDF("world.sdf")
pyrosim.Send_Cube(name="Box", pos=[4,4,z], size=[length,width,height])
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_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()
Create_World()
Generate_Body()
Generate_Brain()