Веб интерфейс для корректировки работы ASP, его интеграция с алгоритмами генерации
This commit is contained in:
parent
23edfea360
commit
c1e4b0e0f0
57 changed files with 2969 additions and 290 deletions
16
stability_process_predicate/main.py
Normal file
16
stability_process_predicate/main.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import argparse
|
||||
|
||||
from usecases.stability_check_usecase import StabilityCheckUseCase
|
||||
|
||||
#python3 main.py --aspPath /home/idontsudo/t/framework/asp/out/sdf-generation --buildNumber 3
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--aspPath', help='asp folder generation path')
|
||||
parser.add_argument('--buildNumber', help='FreeCad generation buildNumber')
|
||||
args = parser.parse_args()
|
||||
# args.aspPath
|
||||
# args.buildNumber
|
||||
StabilityCheckUseCase().call( args.aspPath,args.buildNumber )
|
||||
|
||||
|
||||
main()
|
|
@ -0,0 +1,61 @@
|
|||
import numpy as np
|
||||
import pybullet as p
|
||||
import time
|
||||
import pybullet_data
|
||||
import os
|
||||
import json
|
||||
|
||||
|
||||
class StabilityCheckUseCase:
|
||||
def call(self, outPath: str, buildNumber: int, duration=500):
|
||||
DURATION = duration
|
||||
try:
|
||||
assemblyUrdf = json.loads(
|
||||
(open(outPath + 'urdf-generation.json')).read()).get(buildNumber)
|
||||
except:
|
||||
return TypeError('not found urfd file or not found build number')
|
||||
inc = 0
|
||||
urdfs = []
|
||||
|
||||
for el in assemblyUrdf:
|
||||
inc += 1
|
||||
file_to_open = outPath + str(inc) + '.urdf'
|
||||
|
||||
f = open(file_to_open, 'w', encoding='utf-8',
|
||||
errors='ignore')
|
||||
f.write(el)
|
||||
urdfs.append(os.path.abspath(f.name))
|
||||
f.close()
|
||||
|
||||
p.connect(p.DIRECT)
|
||||
|
||||
p.setGravity(0, 0, -10)
|
||||
p.setAdditionalSearchPath(pybullet_data.getDataPath())
|
||||
bulletIds = []
|
||||
for el in urdfs:
|
||||
bulletIds.append(p.loadURDF(el))
|
||||
p.loadURDF("plane.urdf")
|
||||
resultCoords = []
|
||||
for i in range(DURATION):
|
||||
if (i + 200 == DURATION):
|
||||
inc = 0
|
||||
for el in bulletIds:
|
||||
inc += 1
|
||||
pos, rot = p.getBasePositionAndOrientation(el)
|
||||
resultCoords.append({
|
||||
'id': inc,
|
||||
"quaternion": rot,
|
||||
"position": pos
|
||||
})
|
||||
p.stepSimulation()
|
||||
time.sleep(1./240.)
|
||||
|
||||
file_to_open = outPath + buildNumber + "_" + 'stability_coords.json'
|
||||
|
||||
f = open(file_to_open, 'w', encoding='utf-8',
|
||||
errors='ignore')
|
||||
f.write(json.dumps(resultCoords))
|
||||
for el in urdfs:
|
||||
os.remove(el)
|
||||
f.close()
|
||||
p.disconnect()
|
Loading…
Add table
Add a link
Reference in a new issue