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
bc716265
Commit
bc716265
authored
Feb 24, 2021
by
Julian Zobel
🦄
Browse files
Removed the doubled state machine of UAVCOntroller and UAVTopologyComponent
parent
e42f2c0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/api/topology/component/ControllableLocationActuator.java
View file @
bc716265
...
...
@@ -22,13 +22,11 @@ package de.tud.kom.p2psim.api.topology.component;
import
java.util.LinkedList
;
import
de.tud.kom.p2psim.impl.topology.component.BaseTopologyComponent
;
import
de.tud.kom.p2psim.impl.topology.component.UAVTopologyComponent.UAVstate
;
import
de.tud.kom.p2psim.impl.topology.placement.UAVBasePlacement
;
import
de.tud.kom.p2psim.impl.topology.util.PositionVector
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.location.LocationSensor
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.Actuator
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseConnectionCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BaseDisconnectedCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.BatteryReplacementCallback
;
import
de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocationCallback
;
...
...
@@ -40,7 +38,7 @@ import de.tudarmstadt.maki.simonstrator.api.uavsupport.callbacks.ReachedLocation
* @author Julian Zobel
*
*/
public
interface
ControllableLocationActuator
extends
Actuator
{
public
interface
ControllableLocationActuator
extends
Actuator
,
LocationSensor
{
public
boolean
isActive
();
...
...
@@ -73,6 +71,8 @@ public interface ControllableLocationActuator extends Actuator {
public
void
setTargetLocationRoute
(
LinkedList
<
PositionVector
>
route
,
ReachedLocationCallback
cb
);
public
void
removeAllTargetLocations
();
public
void
batteryReplacement
(
BatteryReplacementCallback
cb
);
public
void
returnToBase
(
double
velocity
,
ReachedLocationCallback
cb
);
...
...
@@ -90,5 +90,7 @@ public interface ControllableLocationActuator extends Actuator {
public
double
estimatePowerConsumptionWatt
(
double
velocity
);
public
double
estimateFlightDistance
(
double
velocity
,
double
batterylevel
,
double
batterythreshold
);
public
double
estimateFlightDistance
(
double
velocity
,
double
batterylevel
,
double
batterythreshold
);
public
double
getOptimalMovementSpeed
();
}
src/de/tud/kom/p2psim/impl/topology/component/UAVTopologyComponent.java
View file @
bc716265
...
...
@@ -57,7 +57,7 @@ import de.tudarmstadt.maki.simonstrator.api.uavsupport.communication.UAVToBaseIn
*/
public
class
UAVTopologyComponent
extends
AbstractTopologyComponent
implements
SimUAVLocationActuator
{
public
enum
UAVstate
{
OFFLINE
,
BASE_CONNECTION
,
BASE_CONNECTION_READY
,
ACTION
,
RETURN
,
CRASHED
}
public
enum
UAVstate
{
OFFLINE
,
BASE_CONNECTION
,
BASE_CONNECTION_READY
,
ACTION
,
RETURN
,
LANDING
,
CRASHED
}
private
UAVMovementModel
movement
;
...
...
@@ -290,7 +290,9 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
@Override
public
void
returnToBase
(
double
velocity
,
ReachedLocationCallback
cb
)
{
if
(!
isActive
())
return
;
if
(!
isActive
())
return
;
this
.
setState
(
UAVstate
.
RETURN
);
movement
.
setTargetVelocity
(
velocity
);
movement
.
setTargetLocation
(
getBaseReturnLocation
(),
cb
);
}
...
...
@@ -300,7 +302,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
if
(!
isActive
())
return
false
;
if
(
isOverBaseLocation
())
{
this
.
setState
(
UAVstate
.
RETURN
);
this
.
setState
(
UAVstate
.
LANDING
);
ReachedLocationCallback
landedCallback
=
new
ReachedLocationCallback
()
{
...
...
@@ -344,7 +346,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
}
p
rivate
void
batteryReplacement
(
BatteryReplacementCallback
cb
)
{
p
ublic
void
batteryReplacement
(
BatteryReplacementCallback
cb
)
{
if
(
state
!=
UAVstate
.
BASE_CONNECTION
)
{
throw
new
UnsupportedOperationException
(
"Cannot recharge if not connected to base!"
);
...
...
@@ -357,8 +359,7 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
}
public
void
setControllerInterface
(
UAVToBaseInterface
controllerInterface
)
{
this
.
controllerInterface
=
controllerInterface
;
this
.
controllerInterface
.
setDeploymentArea
(
topology
.
getWorldDimensions
());
this
.
controllerInterface
=
controllerInterface
;
connectToBase
(
null
);
}
...
...
@@ -446,6 +447,10 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
return
distance
;
}
public
double
getOptimalMovementSpeed
()
{
return
movement
.
estimateOptimalSpeed
();
}
@Override
public
PositionVector
getBaseLocation
()
{
return
getBaseReturnLocation
();
...
...
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