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
12e538a4
Commit
12e538a4
authored
Nov 01, 2021
by
Julian Zobel
🦄
Browse files
Adapted a hover and fly state for fixed wing Uavs
parent
aed6fe63
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/energy/components/StatefulActuatorComponent.java
View file @
12e538a4
...
...
@@ -43,7 +43,7 @@ public class StatefulActuatorComponent implements ActuatorComponent {
*
* TODO More states reflecting a more accurate energy consumption?
*/
public
final
EnergyState
OFF
,
FLY
,
MAX
;
public
final
EnergyState
OFF
,
HOVER
,
MIN
,
MAX
;
private
EnergyState
currentState
;
...
...
@@ -53,9 +53,10 @@ public class StatefulActuatorComponent implements ActuatorComponent {
private
double
actuatorLoad
;
public
StatefulActuatorComponent
(
int
numberOfActuators
,
double
volt
,
double
hoverAmp
,
double
maxAmp
)
{
public
StatefulActuatorComponent
(
int
numberOfActuators
,
double
volt
,
double
hoverAmp
,
double
minAmp
,
double
maxAmp
)
{
OFF
=
new
DefaultEnergyState
(
"OFF"
,
0
);
FLY
=
new
DefaultEnergyState
(
"FLY"
,
numberOfActuators
*
(
hoverAmp
*
volt
)
*
Battery
.
uJconverison
);
HOVER
=
new
DefaultEnergyState
(
"HOVER"
,
numberOfActuators
*
(
hoverAmp
*
volt
)
*
Battery
.
uJconverison
);
MIN
=
new
DefaultEnergyState
(
"MIN"
,
numberOfActuators
*
(
minAmp
*
volt
)
*
Battery
.
uJconverison
);
MAX
=
new
DefaultEnergyState
(
"MAX"
,
numberOfActuators
*
(
maxAmp
*
volt
)
*
Battery
.
uJconverison
);
this
.
currentState
=
OFF
;
...
...
@@ -74,9 +75,16 @@ public class StatefulActuatorComponent implements ActuatorComponent {
@Override
public
double
calculateEnergyConsumation
(
EnergyState
state
,
long
timeInState
)
{
if
(
state
.
equals
(
FLY
))
{
double
consumationDelta
=
MAX
.
getEnergyConsumption
()
-
FLY
.
getEnergyConsumption
();
double
consumation
=
FLY
.
getEnergyConsumption
()
+
consumationDelta
*
actuatorLoad
;
if
(
state
.
equals
(
HOVER
))
{
return
HOVER
.
getEnergyConsumption
()
*
(
(
double
)
timeInState
/
(
double
)
Time
.
SECOND
);
}
else
if
(
state
.
equals
(
MIN
))
{
double
consumationDelta
=
MAX
.
getEnergyConsumption
()
-
MIN
.
getEnergyConsumption
();
double
consumation
=
MIN
.
getEnergyConsumption
()
+
consumationDelta
*
actuatorLoad
;
return
consumation
*
(
(
double
)
timeInState
/
(
double
)
Time
.
SECOND
);
}
else
if
(
state
.
equals
(
MAX
))
{
double
consumation
=
0.5
*
MAX
.
getEnergyConsumption
()
+
MAX
.
getEnergyConsumption
()
*
actuatorLoad
;
return
consumation
*
(
(
double
)
timeInState
/
(
double
)
Time
.
SECOND
);
}
else
...
...
@@ -84,12 +92,20 @@ public class StatefulActuatorComponent implements ActuatorComponent {
}
public
void
useActuator
(
double
load
)
{
if
(
load
<
0
||
load
>
1.0
)
{
throw
new
AssertionError
(
"Actuator load
must be between 0 and 1
!"
);
}
else
{
if
(
load
<
0
)
{
throw
new
AssertionError
(
"Actuator load
cannot be < 0.0
!"
);
}
else
{
this
.
actuatorLoad
=
load
;
doStateChange
(
FLY
);
if
(
load
==
0
)
{
doStateChange
(
HOVER
);
}
else
if
(
load
<=
1.0
)
{
doStateChange
(
MIN
);
}
else
if
(
load
>
1.0
)
{
doStateChange
(
MAX
);
}
}
}
...
...
@@ -99,8 +115,20 @@ public class StatefulActuatorComponent implements ActuatorComponent {
* @return Energy consumption in J/s
*/
public
double
estimateEnergyConsumptionWatt
(
double
load
)
{
double
consumationDelta
=
MAX
.
getEnergyConsumption
()
-
FLY
.
getEnergyConsumption
();
double
estimation
=
FLY
.
getEnergyConsumption
()
+
consumationDelta
*
load
;
double
estimation
=
-
1
;
if
(
load
==
0
)
{
estimation
=
HOVER
.
getEnergyConsumption
();
}
else
if
(
load
<=
1.0
)
{
double
consumationDelta
=
MAX
.
getEnergyConsumption
()
-
MIN
.
getEnergyConsumption
();
estimation
=
MIN
.
getEnergyConsumption
()
+
consumationDelta
*
load
;
}
else
if
(
load
>
1.0
)
{
estimation
=
0.5
*
MAX
.
getEnergyConsumption
()
+
MAX
.
getEnergyConsumption
()
*
load
;
}
// System.out.println("MAX " + ((MAX.getEnergyConsumption() / 14.8) / Battery.uJconverison));
// System.out.println("MIN" + ((FLY.getEnergyConsumption() / 14.8) / Battery.uJconverison));
...
...
@@ -129,7 +157,7 @@ public class StatefulActuatorComponent implements ActuatorComponent {
public
boolean
turnOn
()
{
if
(
isAvailable
())
{
if
(
currentState
.
equals
(
OFF
))
{
doStateChange
(
FLY
);
doStateChange
(
MIN
);
}
return
true
;
}
...
...
src/de/tud/kom/p2psim/impl/energy/configs/StatefulActuatorConfiguration.java
View file @
12e538a4
...
...
@@ -35,11 +35,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
private
int
numberOfActuators
;
private
double
volt
;
private
double
hoverAmp
;
// in ampere
private
double
flyAmp
;
// in ampere
private
double
minAmp
;
// in ampere
private
double
maxAmp
;
// in ampere
@Override
public
StatefulActuatorComponent
getConfiguredEnergyComponent
(
SimHost
host
)
{
return
new
StatefulActuatorComponent
(
numberOfActuators
,
volt
,
hoverAmp
,
fly
Amp
);
return
new
StatefulActuatorComponent
(
numberOfActuators
,
volt
,
hoverAmp
,
minAmp
,
max
Amp
);
}
@Override
...
...
@@ -50,7 +51,7 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
@Override
public
boolean
isWellConfigured
()
{
if
(
numberOfActuators
>=
1
&&
volt
>
0
&&
hoverAmp
>
0
&&
fly
Amp
>
0
)
&&
hoverAmp
>
0
&&
minAmp
>
0
&&
max
Amp
>
0
)
return
true
;
return
false
;
...
...
@@ -64,8 +65,12 @@ public class StatefulActuatorConfiguration implements EnergyConfiguration<Statef
this
.
hoverAmp
=
ampereHovering
;
}
public
void
setFlyAmp
(
double
ampereFlying
)
{
this
.
flyAmp
=
ampereFlying
;
public
void
setMinAmp
(
double
minamp
)
{
this
.
minAmp
=
minamp
;
}
public
void
setMaxAmp
(
double
maxamp
)
{
this
.
maxAmp
=
maxamp
;
}
public
void
setVolt
(
double
voltage
)
{
...
...
src/de/tud/kom/p2psim/impl/topology/component/UAVTopologyComponent.java
View file @
12e538a4
...
...
@@ -108,6 +108,14 @@ public class UAVTopologyComponent extends AbstractTopologyComponent implements S
// retrieve base location
baseLocation
=
UAVBasePlacement
.
base
.
position
.
clone
();
System
.
out
.
println
(
"optimal velocity: "
+
getOptimalMovementSpeed
());
System
.
out
.
println
(
"flight distance @opt: "
+
estimateFlightDistance
(
getOptimalMovementSpeed
(),
1
,
0
));
System
.
out
.
println
(
"flight distance @5m/s: "
+
estimateFlightDistance
(
5.0
,
1
,
0
));
System
.
out
.
println
(
"flight distance @"
+
getMaxMovementSpeed
()+
"m/s: "
+
estimateFlightDistance
(
getMaxMovementSpeed
(),
1
,
0
));
System
.
out
.
println
(
"Hover time: "
+
(((
battery
.
getMaximumEnergy
())
/
Battery
.
uJconverison
)
/
estimatePowerConsumptionWatt
(
0
))
/
60
);
System
.
out
.
println
();
}
private
void
setState
(
UAVstate
newState
)
{
...
...
src/de/tud/kom/p2psim/impl/topology/movement/aerial/MulticopterMovement.java
View file @
12e538a4
...
...
@@ -86,7 +86,7 @@ public class MulticopterMovement implements UAVMovementModel {
this
.
dragCoefficient
=
UAVDragCoefficient
;
this
.
maximumPitchAngleAllowed
=
maximumPitchAngleAllowed
;
this
.
maximumDecentVelocityAllowed
=
maximumDecentVelocityAllowed
;
this
.
maximumTurnAngle
=
maximumTurnAngle
;
this
.
maximumTurnAngle
=
maximumTurnAngle
;
}
boolean
first
=
true
;
...
...
src/de/tud/kom/p2psim/impl/topology/movement/aerial/SimpleMulticopterMovement.java
View file @
12e538a4
...
...
@@ -53,15 +53,18 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
private
double
minimumHorizontalVelocity
;
private
double
minimumVerticalVelocity
;
private
double
optimalHorizontalVelocity
;
private
LinkedList
<
PositionVector
>
route
=
new
LinkedList
<>();
private
Map
<
PositionVector
,
ReachedLocationCallback
>
locationCallbacks
=
new
LinkedHashMap
<>();
private
StatefulActuatorComponent
motor
;
public
SimpleMulticopterMovement
(
UAVTopologyComponent
topologyComponent
,
double
maximumHorizontalVelocity
,
public
SimpleMulticopterMovement
(
UAVTopologyComponent
topologyComponent
,
double
maximumHorizontalVelocity
,
double
optimalHorizontalVelocity
,
double
maximumVerticalVelocity
,
double
minimumHorizontalVelocity
,
double
minimumVerticalVelocity
)
{
this
.
topologyComponent
=
topologyComponent
;
this
.
maximumHorizontalVelocity
=
maximumHorizontalVelocity
;
this
.
optimalHorizontalVelocity
=
optimalHorizontalVelocity
;
this
.
maximumVerticalVelocity
=
maximumVerticalVelocity
;
this
.
minimumHorizontalVelocity
=
minimumHorizontalVelocity
;
this
.
minimumVerticalVelocity
=
minimumVerticalVelocity
;
...
...
@@ -101,7 +104,14 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
PositionVector
newPosition
=
new
PositionVector
(
currentPosition
);
newPosition
.
add
(
direction
);
motor
.
useActuator
(
1
);
if
(
velocity
<=
optimalHorizontalVelocity
)
{
motor
.
useActuator
(
1.0
);
}
else
{
motor
.
useActuator
(
2.0
);
}
topologyComponent
.
updateCurrentLocation
(
newPosition
);
}
else
if
(
motor
.
isOn
())
{
...
...
@@ -194,8 +204,11 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
if
(
velocity
==
0
)
{
wattage
=
motor
.
estimateEnergyConsumptionWatt
(
0
);
}
else
{
wattage
=
motor
.
estimateEnergyConsumptionWatt
(
1.0
);
else
if
(
velocity
<=
optimalHorizontalVelocity
){
wattage
=
motor
.
estimateEnergyConsumptionWatt
(
1
);
}
else
{
wattage
=
motor
.
estimateEnergyConsumptionWatt
(
2
);
}
return
wattage
;
...
...
@@ -234,6 +247,12 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
public
void
setMaximumHorizontalVelocity
(
double
maximumHorizontalVelocity
)
{
this
.
maximumHorizontalVelocity
=
maximumHorizontalVelocity
;
}
private
double
optimalHorizontalVelocity
=
10
;
public
void
setOptimalHorizontalVelocity
(
double
optimalHorizontalVelocity
)
{
this
.
optimalHorizontalVelocity
=
optimalHorizontalVelocity
;
}
private
double
maximumVerticalVelocity
=
5
;
...
...
@@ -254,13 +273,13 @@ public class SimpleMulticopterMovement implements UAVMovementModel {
}
public
UAVMovementModel
createComponent
(
UAVTopologyComponent
topologyComponent
)
{
return
new
SimpleMulticopterMovement
(
topologyComponent
,
maximumHorizontalVelocity
,
return
new
SimpleMulticopterMovement
(
topologyComponent
,
maximumHorizontalVelocity
,
optimalHorizontalVelocity
,
maximumVerticalVelocity
,
minimumHorizontalVelocity
,
minimumVerticalVelocity
);
}
}
@Override
public
double
estimateOptimalSpeed
()
{
return
maximum
HorizontalVelocity
;
return
optimal
HorizontalVelocity
;
}
}
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