-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: More E2s controlling TA database
- Loading branch information
1 parent
c8fc83f
commit ec4a967
Showing
8 changed files
with
287 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
@name TA Active point scanner | ||
@inputs | ||
@outputs Piece:entity Position:vector | ||
@persist Scanner:entity [F U C S Position]:vector | ||
@persist Delta ScanDepth ScanSizeW ScanSizeH PntCount Stage | ||
@trigger none | ||
@model models/props_phx/construct/metal_wire1x1.mdl | ||
|
||
@outputs StepDistant DstU DstD S:vector | ||
@outputs [SufU SufD]:vector | ||
|
||
if(first() || dupefinished()) | ||
{ | ||
# Scan size. Most rails are more wider than higher | ||
# For PHX two bean rails W > H | ||
ScanSizeW = 80 # Scans across left/right with sensors up/down | ||
ScanSizeH = 40 # Scans across up/down with sensors left/right | ||
|
||
# Scanning depth | ||
ScanDepth = 8 | ||
|
||
# How fast it will scan the piece edge | ||
Delta = 0.1 | ||
|
||
# Local oriantation vectors | ||
F = vec(0,0,1) | ||
U = vec(1,0,0) | ||
C = vec(0,0,0) | ||
S = vec(0,0,0) | ||
|
||
# Automatic stuff | ||
runOnTick(1) | ||
Stage = 0 # Must start from zero ( initialization stage ) | ||
PntCount = 0 # Howm many points are registered for avarage | ||
StepDistant = 0 # The current distrance while scanning. Resets in every stage | ||
Scanner = entity() | ||
|
||
holoCreate(1), holoColor(1,vec(255,0,0)), holoScale(1,0.1*vec(1,1,1)) holoModel(1,"cone") | ||
holoCreate(2), holoColor(2,vec(0,0,255)), holoScale(2,0.1*vec(1,1,1)) holoModel(2,"cone") | ||
holoCreate(3), holoColor(3,vec(0,0,255)), holoScale(3,0.1*vec(1,1,1)) holoModel(3,"cube") | ||
} | ||
|
||
|
||
An = Scanner:angles() | ||
Fw = F:rotate(An) | ||
Up = U:rotate(An) | ||
Rg = Fw:cross(Up) | ||
Cn = C:rotate(An) + Scanner:pos() | ||
|
||
if(Stage == 0) | ||
{ | ||
Stage++ | ||
StepDistant = 0 | ||
} | ||
elseif(Stage == 1) | ||
{ | ||
Stage++ | ||
StepDistant = (-ScanSizeW / 2) | ||
} | ||
elseif(Stage == 2) | ||
{ | ||
SyzeH2 = (ScanSizeH / 2) | ||
|
||
PosU = Cn + StepDistant * Rg + ScanDepth * Fw + SyzeH2 * Up | ||
PosD = Cn + StepDistant * Rg + ScanDepth * Fw - SyzeH2 * Up | ||
|
||
holoPos(1,PosU) | ||
holoAng(1,(-Up):toAngle(-Fw):rotateAroundAxis(Rg,90)) | ||
holoPos(2,PosD) | ||
holoAng(2, Up:toAngle(-Fw):rotateAroundAxis(Rg,-90)) | ||
|
||
DstU = rangerOffset(SyzeH2, PosU, -Up):distance() | ||
DstD = rangerOffset(SyzeH2, PosD, Up):distance() | ||
|
||
if(DstU < SyzeH2) | ||
{ | ||
SufU = (-DstU * Up) + PosU | ||
S = S + (-DstU * Up) | ||
PntCount++ | ||
} | ||
|
||
if(DstD < SyzeH2) | ||
{ | ||
SufD = (DstD * Up) + PosD | ||
S = S + (DstD * Up) | ||
PntCount++ | ||
} | ||
|
||
|
||
if(StepDistant > (ScanSizeW / 2)) | ||
{ | ||
Position = -(S / PntCount) + Cn | ||
holoPos(3,Position) | ||
PntCount = 0 | ||
S = vec(0,0,0) | ||
StepDistant = (-ScanSizeH / 2) | ||
Stage++ | ||
} | ||
else | ||
{ | ||
StepDistant = StepDistant + Delta | ||
} | ||
} | ||
elseif(Stage == 3) | ||
{ | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@name | ||
@inputs UCS:wirelink | ||
@outputs T:string | ||
@persist | ||
@trigger | ||
@model models/props_phx/trains/tracks/track_1x.mdl | ||
|
||
T = entity():trackasmlibGenActivePointINS(UCS:entity(),"Test","Test",1,"AAA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
@name TA_curve_rotator | ||
@inputs | ||
@inputs | ||
@outputs | ||
@persist [O V R]:vector2 SignAng Length Iter | ||
@trigger | ||
@persist [O V R]:vector SignAng Length Iter | ||
@trigger | ||
|
||
runOnTick(1) | ||
|
||
if(first() || dupefinished()) | ||
{ | ||
# The length of the curve goes here | ||
Length = 198.5 | ||
|
||
# The angle sign it will be rotated to | ||
SignAng = -1 | ||
|
||
# Origin of the rotation | ||
O = vec2(Length,0) | ||
|
||
# Initial vector to be rotated | ||
V = vec2(-Length,0) | ||
|
||
# Do not touch | ||
print("\n\n") | ||
print("R 225: "+toString(V:rotate(SignAng * 22.5) + O)) | ||
print("R 450: "+toString(V:rotate(SignAng * 45.0) + O)) | ||
print("R 900: "+toString(V:rotate(SignAng * 90.0) + O)) | ||
|
||
########## Globals part ! ########## | ||
E = entity():isConstrainedTo("weld") | ||
EA = E:angles() | ||
EP = E:pos() | ||
########## Parameter section ########## | ||
# Local rotation axis | ||
X = vec(0,0,1) | ||
# Rotation origin from the primary edge | ||
# Usually where point ID 1 is located | ||
O = vec(0, -2048, 0) | ||
# Point location as local vector | ||
P = vec(0,-46,6.625) | ||
# How much amgle to apply | ||
D = 45 | ||
|
||
|
||
########## Formula for the local arm vector roatated ########## | ||
V = (P - O):rotate(EA) | ||
|
||
########## Automatic part ! ########## | ||
RO = O:rotate(EA) | ||
RX = X:rotate(EA) | ||
RP = P:rotate(EA) | ||
PO = RO + E:pos() | ||
print("Str: "+toString(V)+" <"+toString(E:toLocal(V+PO))+">") | ||
|
||
|
||
RA = EA:rotateAroundAxis(RX,D) | ||
V = V:rotate(RA) | ||
print("End: "+toString(V)) | ||
V = E:toLocal(V+PO) | ||
print("Out: "+toString(V)) | ||
|
||
selfDestruct() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
@name Test Rail Angler | ||
@inputs [Rail]:wirelink | ||
@outputs Pitch PitchSign Roll RollSign Yaw [RailPos]:vector | ||
@outputs Err:vector [AngSet RAngle UAngle]:angle | ||
@outputs [BF BR BU TF TR TU]:vector | ||
@outputs [BaF BaR BaU TrF TrR TrU AngEx]:angle | ||
@persist [Base Track]:entity Ang:angle [Off Err]:vector | ||
@trigger | ||
@model models/props_phx/trains/monorail1.mdl | ||
|
||
|
||
if(first() || dupefinished()) | ||
{ | ||
runOnTick(1) | ||
Base = entity() | ||
Track = Rail:entity() | ||
#Ang = ang(0,180,0) | ||
#Off = vec(0.080 , 605.6, -13.153) | ||
Track:setMass(1000) | ||
holoCreate(1,vec(1,1,1),0.3*vec(1,1,1)) | ||
holoCreate(2,vec(1,1,1),0.2*vec(1,1,1)) | ||
holoCreate(3,vec(1,1,1),0.2*vec(1,1,1)) | ||
holoCreate(4,vec(1,1,1),0.2*vec(1,1,1)) | ||
} | ||
BF = Base:forward() | ||
BU = Base:up() | ||
BR = BF:cross(BU) | ||
|
||
AxisLen = 40 | ||
|
||
Dest = (250 * BF + 13.4405 * BU) + Base:pos() | ||
holoPos(1,Dest) | ||
Dest = Dest + (Off:x() * BF + Off:y() * BR + Off:z() * BU) | ||
#Track:setPos(Dest) | ||
|
||
#Err = (Dest - Track:pos()) | ||
#Track:applyForce(25000*Err + 38000*$Err) | ||
|
||
Vec = Base:pos() + 50*BU + AxisLen*BF | ||
holoPos(2,Vec) | ||
holoAng(2,BF:toAngle()) | ||
holoColor(2,vec(255,0,0)) | ||
|
||
Vec = Base:pos() + 50*BU + AxisLen*BR | ||
holoPos(3,Vec) | ||
holoAng(3,BR:toAngle()) | ||
holoColor(3,vec(0,255,0)) | ||
|
||
Vec = Base:pos() + 50*BU + AxisLen*BU | ||
holoPos(4,Vec) | ||
holoAng(4,BR:toAngle()) | ||
holoColor(4,vec(0,0,255)) | ||
|
||
|
||
#Track:setAng(ang(0,0,0)) | ||
TF = vec(1,1,0):rotate(Track:angles()) | ||
TU = vec(0,0,1):rotate(Track:angles()) | ||
TR = TF:cross(TU) | ||
#Base | ||
|
||
|
||
BaF = BF:toAngle() | ||
BaR = BR:toAngle() | ||
BaU = BU:toAngle() | ||
|
||
TrF = TF:toAngle() | ||
TrR = TR:toAngle() | ||
TrU = TU:toAngle() | ||
|
||
|
||
#Pitch | ||
Pitch = -BaF:pitch() | ||
#Yaw | ||
Yaw = BaF:yaw() | ||
# Roll | ||
Roll = BaR:pitch() | ||
UAngOff = ang(Pitch,Yaw,-Roll) | ||
######################### | ||
|
||
|
||
|
||
|
||
BaF:setYaw(-BaF:yaw()) | ||
|
||
|
||
|
||
AngSet = angnorm(ang(0,0,0)) | ||
|
||
# Track:setAng(AngSet) | ||
TF = vec(1,1,0):rotate(Track:angles()) | ||
TU = vec(0,0,1):rotate(Track:angles()) | ||
TR = TF:cross(TU) | ||
|
||
|
||
AngEx = vec(0,0,100):getAngleEx(vec(0,0,0)) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters