yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #23236
[Question #691026]: Loading the stored the position of plank, but it wrong
New question #691026 on Yade:
https://answers.launchpad.net/yade/+question/691026
Dear friend:
It is me again. Sorry. The new problem.
I design five plank(window), and they rotates around a axis. So I storage the position of them, and hope display the rotation process of them, but the reload location is wrong.
# (1) Define the plank:
temp = [
Vector3(widthHydr * i, wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_1, wind_z_1),
Vector3(widthHydr * i, wind_y_1, wind_z_1)
]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, capEnd=True)
Wind2 = pack.sweptPolylines2gtsSurface([positionWind[1]], capStart=True, capEnd=True)
Wind3 = pack.sweptPolylines2gtsSurface([positionWind[2]], capStart=True, capEnd=True)
Wind4 = pack.sweptPolylines2gtsSurface([positionWind[3]], capStart=True, capEnd=True)
Wind5 = pack.sweptPolylines2gtsSurface([positionWind[4]], capStart=True, capEnd=True)
WindList = IDWind1 + IDWind2 +IDWind3 + IDWind4 + IDWind5
# (2) Rotation the plank(window) in the O.engines
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind[0], zeroPoint=positionWind[0][2],
label='RotationW1'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind[1], zeroPoint=positionWind[1][2],
label='RotationW2'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind[2], zeroPoint=positionWind[2][2],
label='RotationW3'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind[3], zeroPoint=positionWind[3][2],
label='RotationW4'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind[4], zeroPoint=positionWind[4][2],
label='RotationW5'),
# (3) Control the speed and direction of the windows
def WindowsAction(IDWind):
global WinAction, windPosition
RotationW = [RotationW1, RotationW2, RotationW3, RotationW4, RotationW5]
for nW in range(0, numWinds):
## action
Pos_z = sum(O.bodies[i].state.pos[2] for i in IDWind[nW]) / len(IDWind[nW])
if WinAction[nW] == 0:
RotationW[nW].angularVelocity = -VelocityWindNegative
else:
RotationW[nW].angularVelocity = VelocityWindPositive
NegtiveStop = (RotationW[nW].angularVelocity > 0) & (Pos_z <= windLowerBoundary)
PostiveStop = (RotationW[nW].angularVelocity < 0) & (Pos_z >= windUpperBoundary)
if NegtiveStop: windPosition[nW] = windPositionNegative
elif PostiveStop: windPosition[nW] = windPositionPositive
else: windPosition[nW] = 0
if NegtiveStop | PostiveStop:
RotationW[nW].angularVelocity = 0
# (4) save the location of windows
def SaveProcessLocation(Episode, iter):
global WindList
outputDir = "Output/location/"
if not os.path.exists(outputDir):
os.makedirs(outputDir)
PositonWind = []
for i in WindList:
temp = [i, o.bodies[i].state.pos]
PositonWind.append(temp)
wind_name = outputDir + 'wind_' + str(Episode) + '_' + str(iter)
np.save(wind_name, PositonWind)
#(5) display the location of the windows
def Relocation():
global nEpisode, nIter, index
path = 'Output/location/'
wind_name = path + 'wind_' + str(nEpisode) + '_' + str(nIter) + '.npy'
if nIter >= index[nEpisode, 1]:
nIter = 0
nEpisode += 1
else:
nIter += 1
if nEpisode >= len(index):
O.pause()
locationWind = np.load(wind_name, allow_pickle=True)
for i in range(0, len(locationWind)):
n = locationWind[i][0]
o.bodies[n].state.pos = locationWind[i][1]
print(locationWind[i][1])
Problem: the each window constitute of 2 triangle. So if reload the location, the 2 triangles comes off. and the rotation angle does not look right.
Thank you very much
--
You received this question notification because your team yade-users is
an answer contact for Yade.