Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
9ffd41f2
Commit
9ffd41f2
authored
Sep 14, 2018
by
Julian Zobel
Browse files
SImple topology component fpr the base station
adapted multicopter movement and UAV topology component
parent
9fa50bfd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/component/BaseTopologyComponent.java
0 → 100644
View file @
9ffd41f2
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tud.kom.p2psim.impl.topology.component
;
import
java.util.Set
;
import
de.tud.kom.p2psim.api.common.SimHost
;
import
de.tud.kom.p2psim.api.topology.Topology
;
import
de.tud.kom.p2psim.api.topology.movement.MovementModel
;
import
de.tud.kom.p2psim.api.topology.placement.PlacementModel
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
public
class
BaseTopologyComponent
extends
AbstractTopologyComponent
{
public
BaseTopologyComponent
(
SimHost
host
,
Topology
topology
,
MovementModel
movementModel
,
PlacementModel
placementModel
,
boolean
registerAsInformationProviderInSiS
)
{
super
(
host
,
topology
,
movementModel
,
placementModel
,
registerAsInformationProviderInSiS
);
// TODO Auto-generated constructor stub
}
@Override
public
double
getMinMovementSpeed
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
getMaxMovementSpeed
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
double
getMovementSpeed
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setMovementSpeed
(
double
speed
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
Set
<
AttractionPoint
>
getAllAttractionPoints
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setTargetAttractionPoint
(
AttractionPoint
targetAttractionPoint
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
AttractionPoint
getCurrentTargetAttractionPoint
()
{
throw
new
UnsupportedOperationException
();
}
}
src/de/tud/kom/p2psim/impl/topology/component/UAVTopologyComponent.java
View file @
9ffd41f2
...
...
@@ -20,6 +20,8 @@
package
de.tud.kom.p2psim.impl.topology.component
;
import
java.util.HashSet
;
import
java.util.LinkedList
;
import
java.util.Set
;
import
de.tud.kom.p2psim.api.common.SimHost
;
...
...
@@ -32,11 +34,13 @@ import de.tud.kom.p2psim.api.topology.movement.SimUAVLocationActuator;
import
de.tud.kom.p2psim.api.topology.movement.UAVMovementModel
;
import
de.tud.kom.p2psim.api.topology.placement.PlacementModel
;
import
de.tud.kom.p2psim.impl.energy.components.ActuatorEnergyComponent
;
import
de.tud.kom.p2psim.impl.topology.util.PositionVector
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.overlay.OverlayComponent
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.battery.BatterySensor
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.AttractionPoint
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback
;
/**
* Topology component used for UAVs.
...
...
@@ -85,26 +89,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
System
.
err
.
println
(
"No Battery Component was found!"
);
}
}
@Override
public
void
setTargetAttractionPoint
(
AttractionPoint
targetAttractionPoint
)
throws
UnsupportedOperationException
{
// TODO Auto-generated method stub
}
@Override
public
Set
<
AttractionPoint
>
getAllAttractionPoints
()
{
// TODO Auto-generated method stub
return
null
;
}
@Override
public
AttractionPoint
getCurrentTargetAttractionPoint
()
{
// TODO Auto-generated method stub
return
null
;
}
public
void
setUAVComponent
(
OverlayComponent
uavOverlayComponent
)
{
this
.
uavOverlayComponent
=
uavOverlayComponent
;
}
...
...
@@ -150,23 +135,16 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
}
@Override
public
Location
getCurrentLocation
()
{
// TODO Auto-generated method stub
return
null
;
public
PositionVector
getCurrentLocation
()
{
return
position
.
clone
();
}
@Override
public
double
getCurrentBatteryLevel
()
{
// TODO Auto-generated method stub
return
0
;
}
@Override
public
void
moveToLocation
(
Location
targetLocation
)
{
// TODO Auto-generated method stub
return
battery
.
getCurrentPercentage
();
}
@Override
public
UAVMovementModel
getUAVMovement
()
{
return
movement
;
...
...
@@ -188,6 +166,55 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
actuator
.
useActuator
(
actuatorLoad
);
}
@Override
public
Set
<
AttractionPoint
>
getAllAttractionPoints
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setTargetLocation
(
PositionVector
targetLocation
,
ReachedLocationCallback
cb
)
{
movement
.
setTargetLocation
(
new
PositionVector
(
targetLocation
),
cb
);
}
@Override
public
void
addTargetLocation
(
PositionVector
targetLocation
,
ReachedLocationCallback
cb
)
{
movement
.
addTargetLocation
(
new
PositionVector
(
targetLocation
),
cb
);
}
@Override
public
void
setTargetLocationRoute
(
LinkedList
<
PositionVector
>
route
,
ReachedLocationCallback
cb
)
{
LinkedList
<
PositionVector
>
positionvectorlist
=
new
LinkedList
<>();
for
(
Location
loc
:
route
)
{
positionvectorlist
.
add
(
new
PositionVector
(
loc
));
}
movement
.
setTargetLocationRoute
(
positionvectorlist
,
cb
);
}
@Override
public
void
removeAllTargetLocations
()
{
movement
.
removeTargetLocations
();
}
@Override
public
void
setTargetAttractionPoint
(
AttractionPoint
targetAttractionPoint
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
AttractionPoint
getCurrentTargetAttractionPoint
()
{
throw
new
UnsupportedOperationException
();
}
@Override
public
LinkedList
<
PositionVector
>
getTargetLocations
()
{
return
movement
.
getTargetLocations
();
}
...
...
src/de/tud/kom/p2psim/impl/topology/movement/aerial/SimpleMutlicopterMovement.java
View file @
9ffd41f2
...
...
@@ -24,13 +24,10 @@ import java.util.HashMap;
import
java.util.LinkedList
;
import
java.util.Map
;
import
de.tud.kom.p2psim.api.topology.movement.UAVMovementModel
;
import
de.tud.kom.p2psim.impl.energy.components.ActuatorEnergyComponent
;
import
de.tud.kom.p2psim.impl.simengine.Simulator
;
import
de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent
;
import
de.tud.kom.p2psim.impl.topology.util.PositionVector
;
import
de.tudarmstadt.maki.simonstrator.api.Time
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback
;
/**
* Local movement logic specifically designs the movement for multicopter UAVs.
...
...
@@ -48,8 +45,8 @@ public class SimpleMutlicopterMovement implements UAVMovementModel {
private
double
preferredCruiseSpeed
;
private
double
currentSpeed
;
private
LinkedList
<
Location
>
waypoints
=
new
LinkedList
<>();
private
Map
<
Location
,
?
>
locationCallbacks
=
new
HashMap
<>();
// TODO callback interface
private
LinkedList
<
PositionVector
>
route
=
new
LinkedList
<>();
private
Map
<
PositionVector
,
ReachedLocationCallback
>
locationCallbacks
=
new
HashMap
<>();
// TODO callback interface
public
SimpleMutlicopterMovement
(
UAVTopologyComponent
topologyComponent
,
double
maxCruiseSpeed
,
double
minCruiseSpeed
)
{
...
...
@@ -57,10 +54,7 @@ public class SimpleMutlicopterMovement implements UAVMovementModel {
this
.
maxCruiseSpeed
=
maxCruiseSpeed
;
this
.
minCruiseSpeed
=
minCruiseSpeed
;
this
.
preferredCruiseSpeed
=
this
.
maxCruiseSpeed
;
waypoints
.
add
(
new
PositionVector
(
100
,
100
,
100
));
waypoints
.
add
(
new
PositionVector
(
600
,
600
,
15
));
waypoints
.
add
(
new
PositionVector
(
200
,
500
,
70
));
}
@Override
...
...
@@ -82,21 +76,23 @@ public class SimpleMutlicopterMovement implements UAVMovementModel {
public
double
getCurrentSpeed
()
{
return
currentSpeed
;
}
@Override
public
void
move
(
long
timeBetweenMovementOperations
)
{
if
(!
waypoints
.
isEmpty
()
&&
topologyComponent
.
isActive
()
)
{
if
(!
route
.
isEmpty
()
&&
topologyComponent
.
isActive
()
)
{
PositionVector
currentPosition
=
topologyComponent
.
getRealPosition
();
Location
targetLocation
=
waypoints
.
getFirst
();
PositionVector
targetPosition
=
new
PositionVector
(
targetLocation
);
PositionVector
targetPosition
=
route
.
getFirst
();
Double
distanceToTargetPosition
=
targetPosition
.
distanceTo
(
currentPosition
);
// If target point is reached within a 1 meter margin, we remove that point from the list
if
(
distanceToTargetPosition
<
1
||
distanceToTargetPosition
<
currentSpeed
)
if
(
distanceToTargetPosition
<
0.
1
||
distanceToTargetPosition
<
currentSpeed
)
{
waypoints
.
add
(
waypoints
.
removeFirst
());
locationReached
(
targetPosition
);
route
.
add
(
route
.
removeFirst
());
topologyComponent
.
updateCurrentLocation
(
targetPosition
,
0
);
currentSpeed
=
0
;
return
;
...
...
@@ -117,10 +113,65 @@ public class SimpleMutlicopterMovement implements UAVMovementModel {
}
//System.out.println(Simulator.getFormattedTime(Simulator.getCurrentTime()) + " | " + topologyComponent);
}
/**
* Trigger the callback function, if there is a valid callback
*
* @param position
*/
private
void
locationReached
(
PositionVector
position
)
{
if
(
locationCallbacks
.
containsKey
(
position
))
{
locationCallbacks
.
get
(
position
).
reachedLocation
();
}
}
@Override
public
void
setTargetLocation
(
PositionVector
target
,
ReachedLocationCallback
reachedLocationCallback
)
{
route
.
clear
();
route
.
add
(
target
);
if
(
reachedLocationCallback
!=
null
)
locationCallbacks
.
put
(
target
,
reachedLocationCallback
);
// System.out.println(Simulator.getFormattedTime(Simulator.getCurrentTime()) + " | " + topologyComponent);
}
@Override
public
void
setTargetLocationRoute
(
LinkedList
<
PositionVector
>
route
,
ReachedLocationCallback
reachedLocationCallback
)
{
this
.
route
.
clear
();
this
.
route
.
addAll
(
route
);
if
(
reachedLocationCallback
!=
null
)
locationCallbacks
.
put
(
route
.
getLast
(),
reachedLocationCallback
);
}
@Override
public
void
addTargetLocation
(
PositionVector
target
,
ReachedLocationCallback
reachedLocationCallback
)
{
route
.
add
(
target
);
if
(
reachedLocationCallback
!=
null
)
locationCallbacks
.
put
(
target
,
reachedLocationCallback
);
}
@Override
public
LinkedList
<
PositionVector
>
getTargetLocations
()
{
LinkedList
<
PositionVector
>
copy
=
new
LinkedList
<>();
for
(
PositionVector
pv
:
route
)
{
copy
.
add
(
pv
.
clone
());
}
return
copy
;
}
@Override
public
void
removeTargetLocations
()
{
route
.
clear
();
locationCallbacks
.
clear
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment