-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulation.py
More file actions
41 lines (30 loc) · 1014 Bytes
/
Copy pathsimulation.py
File metadata and controls
41 lines (30 loc) · 1014 Bytes
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
from world import WORLD
from robot import ROBOT
import pybullet_data
import pybullet as p
import constants as c
import pyrosim.pyrosim as pyrosim
import time as t
class SIMULATION:
def __init__(self, directOrGui, solutionID):
self.directOrGui = directOrGui
if self.directOrGui == "DIRECT":
self.physicsClient = p.connect(p.DIRECT)
elif self.directOrGui == "GUI":
self.physicsClient = p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.setGravity(0,0,-9.8)
self.world = WORLD()
self.robot = ROBOT(solutionID)
def Run(self):
for i in range(350):
p.stepSimulation()
self.robot.Sense(i)
self.robot.Think()
self.robot.Act(i)
if self.directOrGui == "GUI":
t.sleep(1/60)
def Get_Fitness(self, solutionID):
self.robot.Get_Fitness(solutionID)
def __del__(self):
p.disconnect()