Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
9ae96887
Commit
9ae96887
authored
3 years ago
by
adfis
Browse files
Options
Downloads
Patches
Plain Diff
Fisher - Final Project
parent
3b81bb10
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/MV3500ProjectFisher.java
+101
-47
101 additions, 47 deletions
...021JulySeptember/projects/Fisher/MV3500ProjectFisher.java
with
101 additions
and
47 deletions
assignments/src/MV3500Cohort2021JulySeptember/projects/Fisher/MV3500ProjectFisher.java
+
101
−
47
View file @
9ae96887
...
...
@@ -10,6 +10,9 @@
*/
package
MV3500Cohort2021JulySeptember.projects.Fisher
;
import
edu.nps.moves.dis7.entities.afg.lifeform.land.CivilianAdultMalewCellPhone
;
import
edu.nps.moves.dis7.entities.usa.lifeform.land.*
;
import
edu.nps.moves.dis7.entities.usa.platform.land.M1281CloseCombatWeaponsCarrierJLTVCCWC
;
import
edu.nps.moves.dis7.enumerations.*
;
// match any
import
edu.nps.moves.dis7.pdus.*
;
// match any of the PDU classes, easier than listing individually
import
edu.nps.moves.dis7.utilities.DisThreadedNetworkInterface
;
...
...
@@ -55,82 +58,114 @@ public class MV3500ProjectFisher
int
simulationLoopCount
=
0
;
// variable, initialized at 0
boolean
simulationComplete
=
false
;
// sentinel variable as termination condition,, are we done yet?
// TODO reset clock to zero each time for consistent outputs
// Your model setup: define participants. who's who in this zoo?
// Assuming you keep track of entity objects... here is some support for for Entity 1.
// create PDU objects and set their values.
// This is an example of the not to good way to do things
// entityType_1.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); // 225 = USA
// entityType_1.setEntityKind(EntityKind.PLATFORM);
// entityType_1.setCategory(6); //Small wheeled utility vehicle
// entityType_1.setSubCategory(30); // JLTV
// entityType_1.setSpecific(37); // Up armored with M240
//Entity 1 is a US JLTV traveling down the road with a M240
EntityID
entityID_1
=
new
EntityID
();
entityID_1
.
setEntityID
(
1
);
// made-up example ID;
// create PDU objects and set their values.
EntityID
entityID_2
=
new
EntityID
();
entityID_2
.
setEntityID
(
2
);
// TODO someday, use enumerations; is there a unique site triplet for MOVES Institute?
EntityType
entityType_1
=
new
EntityType
();
entityType_1
.
setCountry
(
Country
.
UNITED_STATES_OF_AMERICA_USA
);
// 225 = USA
entityType_1
.
setEntityKind
(
EntityKind
.
PLATFORM
);
entityType_1
.
setCategory
(
6
);
//Small wheeled utility vehicle
entityType_1
.
setSubCategory
(
30
);
// JLTV
entityType_1
.
setSpecific
(
37
);
// Up armored with M240
entityID_1
.
setEntityID
(
1
);
// made-up example ID;
EntityStatePdu
entityStatePdu_1
=
pduFactory
.
makeEntityStatePdu
();
entityStatePdu_1
.
setEntityType
(
new
M1281CloseCombatWeaponsCarrierJLTVCCWC
());
// create new object vice using the class
Vector3Float
pEntityLinearVelocity
=
new
Vector3Float
();
pEntityLinearVelocity
.
setX
(
1
);
pEntityLinearVelocity
.
setY
(
0
);
pEntityLinearVelocity
.
setZ
(
0
);
pEntityLinearVelocity
.
setX
(
1
).
setY
(
0
).
setZ
(
0
);
entityStatePdu_1
.
setEntityLinearVelocity
(
pEntityLinearVelocity
);
entityStatePdu_1
.
setEntityID
(
entityID_1
);
entityStatePdu_1
.
getEntityLocation
().
setX
(
0
).
setY
(
0
).
setZ
(
0
);
entityStatePdu_1
.
setForceId
(
ForceID
.
FRIENDLY
);
entityStatePdu_1
.
set
EntityType
(
entityType_1
);
entityStatePdu_1
.
set
AlternativeEntityType
(
new
_762x51mmM240E4M240BGPMG
()
);
EntityType
entityType_2
=
new
EntityType
();
entityType_2
.
setCountry
(
Country
.
AFGHANISTAN_AFG
);
entityType_2
.
setEntityKind
(
EntityKind
.
LIFE_FORM
);
entityType_2
.
setCategory
(
1
);
// civilian male with cellphone
entityType_2
.
setSubCategory
(
171
);
// personal electronic
entityType_2
.
setSubCategory
(
1
);
// cell phone
// Again, example of the not so good way to do things
// EntityType entityType_2 = new EntityType();
// entityType_2.setCountry(Country.AFGHANISTAN_AFG);
// entityType_2.setEntityKind(EntityKind.LIFE_FORM);
// entityType_2.setCategory(1); // civilian male with cellphone
// entityType_2.setSubCategory(171); // personal electronic
// entityType_2.setSubCategory(1); // cell phone
// Entity 2 is an enemy Afghan male with cell phone.
EntityID
entityID_2
=
new
EntityID
();
entityID_2
.
setEntityID
(
2
);
EntityStatePdu
entityStatePdu_2
=
pduFactory
.
makeEntityStatePdu
();
entityStatePdu_2
.
setEntityType
(
new
CivilianAdultMalewCellPhone
());
entityStatePdu_2
.
setEntityID
(
entityID_2
);
entityStatePdu_2
.
getEntityLocation
().
setX
(
10
).
setY
(
0
).
setZ
(
100
);
entityStatePdu_2
.
setForceId
(
ForceID
.
OPPOSING
);
entityStatePdu_2
.
setEntityType
(
entityType_2
);
FirePdu
firePdu_1a
=
pduFactory
.
makeFirePdu
();
// for entity 1 first weapon (if any)
// should we customize this munition? what is it for your simulation?
EntityType
fireType
=
new
EntityType
();
// 762 munition to be fired from M240
FirePdu
firePdu_1a
=
pduFactory
.
makeFirePdu
();
MunitionDescriptor
fireDescriptor
=
new
MunitionDescriptor
();
fireType
.
setCountry
(
Country
.
UNITED_STATES_OF_AMERICA_USA
);
fireType
.
setEntityKind
(
EntityKind
.
PLATFORM
);
fireType
.
setCategory
(
11
);
//US Army
fireType
.
setSubCategory
(
35
);
//Machine gun
fireType
.
setSpecific
(
59
);
//M240
EntityType
munitionType
=
new
EntityType
();
munitionType
.
setCountry
(
Country
.
UNITED_STATES_OF_AMERICA_USA
);
munitionType
.
setEntityKind
(
EntityKind
.
MUNITION
);
munitionType
.
setCategory
(
2
);
// ballistic
munitionType
.
setSubCategory
(
2
);
//762
munitionType
.
setSpecific
(
4
);
// _762x51mm4balland1tracerlinked
//fireDescriptor.setMunitionType(new _762x51mm4balland1tracerlinked());
firePdu_1a
.
setFiringEntityID
(
entityID_1
);
firePdu_1a
.
setTargetEntityID
(
entityID_2
);
firePdu_1a
.
setRange
(
1000.0f
);
// range 1000m
fireDescriptor
.
setMunitionType
(
fireType
);
fireDescriptor
.
setRate
(
200
);
//rate 200 rounds per minute
Vector3Float
pVelocity
=
new
Vector3Float
();
pVelocity
.
setX
(
0.0f
);
pVelocity
.
setY
(
0.0f
);
pVelocity
.
setZ
(
100.0f
);
firePdu_1a
.
setVelocity
(
pVelocity
);
fireDescriptor
.
setMunitionType
(
munitionType
);
firePdu_1a
.
setDescriptor
(
fireDescriptor
);
// TODO simulation management PDUs for startup, planning to design special class support
//Pdu for impacts of 762 on the dirt before making contact with enemy
DetonationPdu
fireDetPdu1
=
pduFactory
.
makeDetonationPdu
();
fireDetPdu1
.
getLocationInWorldCoordinates
().
setX
(
12
).
setY
(
0
).
setZ
(
0
);
fireDetPdu1
.
setDetonationResult
(
DetonationResult
.
GROUND_IMPACT
);
fireDetPdu1
.
setSourceEntityID
(
entityID_1
).
setTargetEntityID
(
entityID_2
);
// Pdu for impacts of 762 on the enemy
DetonationPdu
fireDetPdu2
=
pduFactory
.
makeDetonationPdu
();
fireDetPdu2
.
getLocationInWorldCoordinates
().
setX
(
12
).
setY
(
0
).
setZ
(
0
);
fireDetPdu2
.
setDetonationResult
(
DetonationResult
.
ENTITY_IMPACT
);
fireDetPdu2
.
setSourceEntityID
(
entityID_1
).
setTargetEntityID
(
entityID_2
);
// IED blast and detonation details
MunitionDescriptor
pDescriotor
=
new
MunitionDescriptor
();
pDescriotor
.
setWarhead
(
MunitionDescriptorWarhead
.
HE_FRAGMENTATION
);
//High explosive frag
pDescriotor
.
setQuantity
(
2
);
EntityType
iedMunitionType
=
new
EntityType
();
iedMunitionType
.
setCountry
(
Country
.
OTHER
);
iedMunitionType
.
setEntityKind
(
EntityKind
.
MUNITION
);
iedMunitionType
.
setCategory
(
3
);
// fixed
iedMunitionType
.
setSubCategory
(
3
);
//PipeBombPVC
//pDescriotor.setMunitionType(new PipeBombPVC());
pDescriotor
.
setFuse
(
MunitionDescriptorFuse
.
COMMAND_ELECTRONIC_REMOTELY_SET
);
//command detonated
DetonationPdu
detonationPdu
=
pduFactory
.
makeDetonationPdu
();
detonationPdu
.
getLocationInWorldCoordinates
().
setX
(
12
).
setY
(
0
).
setZ
(
0
);
pDescriotor
.
setMunitionType
(
iedMunitionType
);
detonationPdu
.
setDescriptor
(
pDescriotor
);
detonationPdu
.
getLocationInWorldCoordinates
().
setX
(
10
).
setY
(
0
).
setZ
(
0
);
detonationPdu
.
setExplodingEntityID
(
entityID_1
).
setSourceEntityID
(
entityID_2
).
setTargetEntityID
(
entityID_1
);
detonationPdu
.
setDetonationResult
(
DetonationResult
.
ENTITY_PROXIMATE_DETONATION
);
detonationPdu
.
setSourceEntityID
(
entityID_2
).
setTargetEntityID
(
entityID_1
);
// User chooses cases to see effects based on det probability
float
probabilityOfDetonation
=
0.2f
;
// experiment with munition reliability
if
(
0.0f
<
probabilityOfDetonation
&&
probabilityOfDetonation
<=
0.8f
)
{
detonationPdu
.
setDetonationResult
(
DetonationResult
.
ENTITY_PROXIMATE_DETONATION
);
}
else
if
(
probabilityOfDetonation
>
0.8f
)
{
detonationPdu
.
setDetonationResult
(
DetonationResult
.
ENTITY_IMPACT
);
// worst case IED direct hit
}
else
if
(
probabilityOfDetonation
==
0.0f
)
{
detonationPdu
.
setDetonationResult
(
DetonationResult
.
NONE_OR_NO_DETONATION_DUD
);
// best case IED dud
}
// loop the simulation while allowed, programmer can set additional conditions to break out and finish
while
(
simulationLoopCount
<
SIMULATION_MAX_LOOP_COUNT
)
// are we done yet?
...
...
@@ -182,16 +217,35 @@ public class MV3500ProjectFisher
System
.
out
.
println
(
"... [PDUs successfully sent for this loop]"
);
int
contactCounter
=
0
;
// When entity reaches a point on the route detonate IED and
// begin firing at the enemy
if
(
entityStatePdu_1
.
getEntityLocation
().
getX
()
==
10
)
{
sendSinglePdu
(
detonationPdu
);
sendCommentPdu
(
otherComment
,
"IED detonated near Entity 1"
);
// This would show the 4 bursts to be shot at the enemy. We can adjust
// how quicly we get effects on target.
while
(
contactCounter
<
4
)
{
contactCounter
++;
sendSinglePdu
(
entityStatePdu_2
);
sendSinglePdu
(
firePdu_1a
);
sendCommentPdu
(
otherComment
,
"Entity 2 is hit"
);
// To be changed by anyone, if we assume our first 2 bursts will not hit the enemy
// Can be changes to reflect better marksmanship or worse.
if
(
contactCounter
<
2
)
{
contactCounter
++;
sendSinglePdu
(
entityStatePdu_2
);
sendSinglePdu
(
firePdu_1a
);
sendSinglePdu
(
fireDetPdu1
);
sendCommentPdu
(
otherComment
,
"Missed entity 2!"
);
}
else
{
contactCounter
++;
sendSinglePdu
(
entityStatePdu_2
);
sendSinglePdu
(
firePdu_1a
);
sendSinglePdu
(
fireDetPdu2
);
sendCommentPdu
(
otherComment
,
"Entity 2 is hit!"
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment