Skip to content
Snippets Groups Projects
Commit 8cc5b44e authored by Reeves, David E's avatar Reeves, David E
Browse files

* convoy setup orientations

* set up timing
* returning
* reclaiming
parent 796529dc
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,8 @@
<DataKey>toNotify,java.lang.String,name of entity to notify on completion</DataKey>
<DataKey>msgToSend,java.lang.String,name of message to send</DataKey>
<DataKey>formationName,java.lang.String,name of formation</DataKey>
<DataKey>orientation,java.lang.Double,final orientation</DataKey>
<DataKey>useOrientation,java.lang.Boolean,use orientation or not</DataKey>
</DataMap>
<Code IsFile="false" />
<Import />
......@@ -26,6 +28,9 @@ import mtry.cxxi.model.HierarchicalTaskNetwork.HTNUtilities as HTNUtilities
locs = _gt_activeNode.getParam("locs")
speed = _gt_activeNode.getParam("speed")
formName = _gt_activeNode.getParam("formationName")
useOrient = _gt_activeNode.getParam("useOrientation")
orientation = _gt_activeNode.getParam("orientation")
prims=Vector()
......@@ -35,6 +40,9 @@ if formName != None and formName != "" and formName != "None":
for l in locs:
prims.add(OrderUtilities.createMovePrimitiveFromLatLon(l.getLatitude(), l.getLongitude(), l.getElevation(), speed))
prims.add(OrderUtilities.createStopPrimitive())
if useOrient:
prims.add(OrderUtilities.createChangeOrientationPrimitive(orientation))
ordr=orders.createOrder("HTN Plan Auto Generated", 0.0, prims)
orders.preemptAllOrders(ordr)
......@@ -90,13 +98,13 @@ if state.getLastTrigger() == "doAtAControlMeasure" and state.getLastTriggerParam
<Import />
<HTNNode AllowMsg="false" Name="moveCompleted" Type="GOAL">
<Parent>isAtAControlMeasure</Parent>
<Code IsFile="false">from HTNBehaviors import SendBehaviorMsg
<Code IsFile="false">from HTNBehaviors import SendEntityEventDelay
toNotify = _gt_activeNode.getParam("toNotify")
msgToSend = _gt_activeNode.getParam("msgToSend")
params = [info.getMyAssignedName(), goalWP.getLocation()]
SendBehaviorMsg(toNotify, msgToSend, params)
SendEntityEventDelay(toNotify, msgToSend, params, 5.0)
printMessage("SENDING MSG TO:"+toNotify+" MSG:"+msgToSend, True)
......
......@@ -18,6 +18,8 @@ printMessage("Convoy started", True)
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_MoveToPoint", ["ASSEMBLE", "ASSEMBLY_LOCATION"], 5.0)
borg.delay=1.0
borg.redUnitStatus[state.getCurrentUnitName()] = 0
</Code>
<Import />
</HTNNode>
......@@ -32,6 +34,9 @@ borg.delay=1.0
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_MoveToPoint")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_MoveCompleted")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ConvoySetup")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ConvoySetupComplete")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ConvoyReturn")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ReturnCompleted")
</Code>
<Import />
</HTNNode>
......@@ -164,33 +169,101 @@ from HTNBehaviors import ConvertToJavaList
printMessage("Starting convoy setup", True)
nlocs = state.getCurrentUnit().getMembers().size()
formName = borg.redFormsByUnit[state.getCurrentUnit().getName()]
formDesc = [
54.46232, 86.02325,
83.64552, 22.136,
130.8151, 29.06888,
133.7455, 96.89685,
60.80969, 102.5195,
88.9792, 137.5218,
97.86741, 138.8065,
126.8186, 111.8,
]
al = ConvertToJavaList(formDesc)
setupLocs = PythonTerrain._py_createFormation(info.getMySelf(), al)
setupLocs = PythonTerrain._py_createFormation(info.getMySelf(), borg.formationsByName[formName])
#setupLocs = PythonTerrain._py_createBox(info.getMySelf(), -90, 50, 50, 50, nlocs)
#def CreateBasicMove(locList, speed, formation, entityToMove, toNotify, msgTo, goalStack):
if setupLocs.size()&lt;nlocs:
nlocs = setupLocs.size()
borg.delay=5
for i in range(nlocs):
member = state.getCurrentUnit().getMembers().get(i)
loc = setupLocs.get(i)
CreateBasicMove([loc], 3.0, None, member.getAssignedName(), info.getMyAssignedName(), "GoalTracker_ConvoySetupComplete", "MOVE", borg.delay)
orientation = borg.formationsByName[formName][i*4+2]
CreateBasicMove([loc], 3.0, None, True, orientation, member.getAssignedName(), info.getMyAssignedName(), "GoalTracker_ConvoySetupComplete", "MOVE", borg.delay)
borg.delay+=5.0
printMessage("Convoy setup for "+str(len(formDesc)/2)+" vehicles", True)
_gt_activeNode.putVar("setupNum", nlocs)
printMessage("Convoy setup for "+str(borg.formationsByName[formName].size()/2)+" vehicles", True)
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="isGoalTracker_ConvoySetup" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger() == "doGoalTracker_ConvoySetupComplete":
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="convoySetupComplete" Type="INTERRUPT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities
from HTNBehaviors import SendEntityEventDelay
borg.redUnitStatus[state.getCurrentUnitName()] = borg.redUnitStatus[state.getCurrentUnitName()] + 1
setupNum = _gt_activeNode.getVar("setupNum")
#printMessage("Setup completed", True)
if borg.redUnitStatus[state.getCurrentUnitName()]==setupNum:
rn = PythonUtilities._py_getRandomNumber("UNIFORM", [0.0, 1.0])
rn = (1.5 + rn * 2.5) * 14400.0
rn = 60.0
SendEntityEventDelay(info.getMyAssignedName(), "GoalTracker_ConvoyReturn", [], rn)
printMessage("Convoy setup complete: "+str(state.getCurrentUnitName()), True)
borg.delay=0
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="isGoalTracker_ConvoyReturn" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger() == "doGoalTracker_ConvoyReturn":
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="convoyReturn" Type="INTERRUPT">
<Parent>isGoalTracker_ConvoyReturn</Parent>
<Code IsFile="false">printMessage("Need to return", True)
borg.redUnitStatus[state.getCurrentUnitName()]=0
for m in state.getCurrentUnit().getMembers():
CreateNetworkMove(
m.getPhysicalState().getGroundTruthLocation(),
["ASSEMBLY_LOCATION"],
3.0,
None,
m.getAssignedName(),
info.getMyAssignedName(),
"GoalTracker_ReturnCompleted",
"MOVE",
borg.delay)
borg.delay+=5.0
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="isReturnCompleted" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger() == "doGoalTracker_ReturnCompleted":
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="returnCompleted" Type="INTERRUPT">
<Parent>New Node</Parent>
<Code IsFile="false">import cxxi.model.behavior.PythonUtilities as PythonUtilities
from HTNBehaviors import SendEntityEventDelay
borg.redUnitStatus[state.getCurrentUnitName()] = borg.redUnitStatus[state.getCurrentUnitName()] + 1
#setupNum = _gt_activeNode.getVar("setupNum")
#printMessage("Setup completed", True)
if borg.redUnitStatus[state.getCurrentUnitName()]==state.getCurrentUnit().getMembers().size():
printMessage("Convoy return", True)
SendEntityEventDelay("RFC", "GoalTracker_ReclaimConvoy", [state.getCurrentUnitName()], 1.0)
</Code>
<Import />
</HTNNode>
......
......@@ -15,6 +15,114 @@
<Code IsFile="false">borg.delay=1
borg.redConvoysWaiting=dict()
borg.redConvoyDest=dict()
borg.redFormsByUnit=dict()
borg.redUnitStatus=dict()
</Code>
<Import />
</HTNNode>
<HTNNode AllowMsg="true" Name="createFormations" Type="DEFAULT">
<Parent>createRoadNetwork</Parent>
<Code IsFile="false">from HTNBehaviors import ConvertToJavaList
borg.formationsByName=dict()
## direction, distance, orientation, desired profile
## CIRCLE
borg.formationsByName["circle"]=ConvertToJavaList([
54.46232, 86.02325, 135.0, "SUPPORT",
83.64552, 22.136, 180.0, "FIRE_CTRL_RADAR",
130.8151, 29.06888, 180.0, "TGT_ACQ_RADAR",
133.7455, 96.89685, 225.0, "C2",
60.80969, 102.5195, 45.0, "SUPPORT",
88.9792, 137.5218, 0.0, "HEAVY_TEL",
97.86741, 138.8065, 0.0, "TELAR",
126.8186, 111.8, 315.0, "SUPPORT",
])
## BOX
borg.formationsByName["box"]=ConvertToJavaList([
90.0, 47.0, 135.0, "SUPPORT",
136.8001, 68.65859, 180.0, "FIRE_CTRL_RADAR",
154.8485, 110.5849, 180.0, "TGT_ACQ_RADAR",
162.6134, 157.2864, 225.0, "C2",
90.0, 100.0, 45.0, "SUPPORT",
116.588, 111.8258, 0.0, "HEAVY_TEL",
135.0286, 141.4921, 0.0, "TELAR",
146.3276, 180.3608, 315.0, "SUPPORT",
])
## ELLIPSE
borg.formationsByName["ellipse"]=ConvertToJavaList([
70.47498, 44.88084, 135.0, "SUPPORT",
125.425, 32.52034, 180.0, "FIRE_CTRL_RADAR",
157.1215, 68.16224, 180.0, "TGT_ACQ_RADAR",
156.4604, 105.9136, 225.0, "C2",
77.48914, 69.2442, 45.0, "SUPPORT",
103.0074, 83.74892, 0.0, "HEAVY_TEL",
127.5822, 102.968, 0.0, "TELAR",
145.1548, 118.3139, 315.0, "SUPPORT",
])
## BIG CIRCLE
borg.formationsByName["bigcircle"]=ConvertToJavaList([
90.0, 8.25, 135.0, "SUPPORT",
119.2488, 5.730618, 180.0, "FIRE_CTRL_RADAR",
145.4077, 8.806957, 180.0, "TGT_ACQ_RADAR",
141.1702, 13.1577, 225.0, "C2",
90.0, 11.25, 45.0, "SUPPORT",
100.9295, 14.76787, 0.0, "HEAVY_TEL",
116.565, 16.21149, 0.0, "TELAR",
132.337, 15.21923, 315.0, "SUPPORT",
99.92625, 16.24315, 135.0, "SUPPORT",
114.3765, 17.56595, 45.0, "SUPPORT",
128.6598, 4.482187, 315.0, "SUPPORT",
154.2307, 8.050621, 225.0, "SUPPORT",
79.69515, 8.385255, 180.0, "SUPPORT",
82.40536, 11.34956, 180.0, "SUPPORT",
136.2454, 16.2673, 0.0, "SUPPORT",
144.9263, 14.35705, 0.0, "SUPPORT",
])
## BIG BOX
borg.formationsByName["bigbox"]=ConvertToJavaList([
90.0, 49.75, 135.0, "SUPPORT",
136.0457, 71.67722, 180.0, "FIRE_CTRL_RADAR",
152.1852, 106.6187, 180.0, "TGT_ACQ_RADAR",
161.1593, 154.0542, 225.0, "C2",
90.0, 79.05, 135.0, "SUPPORT",
123.1346, 94.40054, 180.0, "HEAVY_TEL",
140.0275, 123.0504, 180.0, "TELAR",
151.5343, 165.851, 225.0, "SUPPORT",
90.0, 112.6, 45.0, "SUPPORT",
106.6152, 117.5063, 0.0, "HEAVY_TEL",
134.7957, 158.6758, 0.0, "TELAR",
142.3214, 184.2184, 315.0, "SUPPORT",
90.0, 145.6, 45.0, "SUPPORT",
102.9946, 149.4266, 0.0, "SUPPORT",
127.5191, 183.5718, 0.0, "SUPPORT",
135.0393, 206.051, 315.0, "SUPPORT",
])
## BIG ELLIPSE
borg.formationsByName["bigellipse"]=ConvertToJavaList([
70.47498, 44.88084, 135.0, "SUPPORT",
125.425, 32.52034, 180.0, "FIRE_CTRL_RADAR",
157.1215, 68.16224, 180.0, "TGT_ACQ_RADAR",
156.4604, 105.9136, 225.0, "C2",
77.48914, 69.2442, 45.0, "SUPPORT",
103.0074, 83.74892, 0.0, "HEAVY_TEL",
127.5822, 102.968, 0.0, "TELAR",
145.1548, 118.3139, 315.0, "SUPPORT",
102.3213, 88.33466, 0.0, "SUPPORT",
126.0432, 106.7311, 0.0, "SUPPORT",
131.2425, 28.59322, 180.0, "SUPPORT",
161.101, 66.37839, 180.0, "SUPPORT",
157.4958, 110.5156, 225.0, "SUPPORT",
146.4916, 122.4507, 315.0, "SUPPORT",
64.3634, 46.91887, 135.0, "SUPPORT",
73.2852, 70.58222, 45.0, "SUPPORT",
])
</Code>
<Import />
</HTNNode>
......@@ -117,6 +225,7 @@ while len(dismounts)&gt;0:
al = ArrayList()
al.add("circle")
al.add("FIRE_CONTROL_RADAR")
al.add("TELAR")
al.add("TELAR")
......@@ -134,6 +243,25 @@ UtilityFuncsExp.scheduleEvent(
0.001,
al)
al = ArrayList()
al.add("bigellipse")
al.add("FIRE_CONTROL_RADAR")
al.add("FIRE_CONTROL_RADAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
UtilityFuncsExp.scheduleEvent(
dm,
info.getMyAssignedName(),
......@@ -141,6 +269,34 @@ UtilityFuncsExp.scheduleEvent(
5,
al)
al = ArrayList()
al.add("bigbox")
al.add("FIRE_CONTROL_RADAR")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("SPT_VEH")
al.add("TELAR")
al.add("TELAR")
al.add("TELAR")
UtilityFuncsExp.scheduleEvent(
dm,
info.getMyAssignedName(),
......@@ -158,6 +314,7 @@ UtilityFuncsExp.scheduleEvent(
# goal tracker events
#goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_Event")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_CreateConvoy")
goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_ReclaimConvoy")
</Code>
<Import />
</HTNNode>
......@@ -185,6 +342,9 @@ goalContainer.getCurrentExecutingStack().addReplanTrigger("GoalTracker_CreateCon
convoyIndex = _gt_activeNode.getVar("convoyIndex")
profiles = state.getLastTriggerParams()[0]
formName = profiles.get(0)
profiles.remove(0)
memberList = ArrayList()
for profile in profiles:
......@@ -208,11 +368,33 @@ borg.redConvoysWaiting[tu.getName()] = []
destName = "PATH_DEST"+str(convoyIndex+1)
borg.redConvoyDest[tu.getName()] = destName
borg.redFormsByUnit[tu.getName()] = formName
_gt_activeNode.putVar("convoyIndex", convoyIndex+1)
printMessage("Convoy created: "+str(tu.getName())+" DEST: "+destName, True)
</Code>
<Import />
</HTNNode>
</HTNNode>
<HTNNode AllowMsg="true" Name="isReclaimConvoy" Type="DEFAULT">
<Parent>printGoalTrackerEvent</Parent>
<Code IsFile="false">if state.getLastTrigger() == "doGoalTracker_ReclaimConvoy":
_htn_precon_ret=1
</Code>
<Import />
<HTNNode AllowMsg="true" Name="reclaimConvoy" Type="INTERRUPT">
<Parent>isCreateConvoy</Parent>
<Code IsFile="false">import cxxi.model.knowledge.group.holders.NewUnitHolder as NewUnitHolder
unit = NewUnitHolder.retrieveUnitByName(state.getLastTriggerParams()[0].get(0))
for m in unit.getMembers():
borg.redProfiles[m.getProfile().getName()].append(m.getAssignedName())
unit.dismissMember(m)
printMessage("Unit reclaimed", True)
</Code>
<Import />
</HTNNode>
......
......@@ -29,7 +29,7 @@ def SendUnitEventDelay(entityName, msg, data, delay):
HTNUtilities._py_scheduleEventForUnit(entityName, msg, delay, params)
# create a basic move tree and assign it
def CreateBasicMove(locList, speed, formation, entityToMove, toNotify, msgTo, goalStack, delay):
def CreateBasicMove(locList, speed, formation, useOr, orient, entityToMove, toNotify, msgTo, goalStack, delay):
al = ArrayList()
for loc in locList:
......@@ -47,7 +47,7 @@ def CreateBasicMove(locList, speed, formation, entityToMove, toNotify, msgTo, go
delay,
__BASIC_MOVE_PATH__,
goalStackName,
[al, speed, toNotify, msgTo, formation],
[al, speed, toNotify, msgTo, formation, orient, useOr],
None)
# create a network move tree and assign it
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment