Skip to content

Commit f7fee10

Browse files
committed
Configure Kite through plugin TOML
1 parent 9d51f5f commit f7fee10

3 files changed

Lines changed: 102 additions & 88 deletions

File tree

config/plugin/GeoData.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ name = "Campus"
8585
easting = 507047.64631626336
8686
northing = 5398555.900845651
8787
altitude = 450.0
88+
89+
90+
[[datasets]]
91+
name = "Kite ground station"
92+
easting = 507047.64631626336
93+
northing = 5398555.900845651
94+
altitude = 450.0
95+
trueNorth = 0.0

config/plugin/KitePlugin.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Model = "/data/MERIDIONAL/kitedata/kite.stl"
2+
CSV = "/data/MERIDIONAL/kitedata/flight.csv"
3+
4+
ShowGround = false
5+
GroundPosX = 0.0
6+
GroundPosY = 0.0
7+
GroundPosZ = 0.0
8+
9+
WorldScale = 1.0

src/OpenCOVER/plugins/hlrs/Kite/KitePlugin.cpp

Lines changed: 85 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "KitePlugin.h"
99

10-
#include <config/CoviseConfig.h>
1110
#include <cover/coVRAnimationManager.h>
1211
#include <cover/coVRFileManager.h>
1312
#include <cover/coVRPluginSupport.h>
@@ -83,8 +82,22 @@ static osg::Matrix geoTransformMatrix(const osg::Vec3 &pos, float scale, float y
8382

8483
bool KitePlugin::init()
8584
{
86-
auto modelEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.Model", "");
87-
m_csvPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.CSV", "");
85+
const auto configEntries = config()->entries("");
86+
const auto hasConfigEntry = [&configEntries](const std::string &name) {
87+
return std::find(configEntries.begin(), configEntries.end(), name) != configEntries.end();
88+
};
89+
const auto configStringValue = [this](const std::string &name, const std::string &defaultValue = "") {
90+
return configString("", name, defaultValue)->value();
91+
};
92+
const auto configFloatValue = [this](const std::string &name, double defaultValue) {
93+
return configFloat("", name, defaultValue)->value();
94+
};
95+
const auto configBoolValue = [this](const std::string &name, bool defaultValue) {
96+
return configBool("", name, defaultValue)->value();
97+
};
98+
99+
auto modelEntry = configStringValue("Model");
100+
m_csvPath = configStringValue("CSV");
88101

89102
auto toLowerCopy = [](std::string s) {
90103
std::transform(s.begin(), s.end(), s.begin(),
@@ -113,95 +126,92 @@ bool KitePlugin::init()
113126
return false;
114127
};
115128

116-
const std::string nedEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.NED", "");
117-
if (!nedEntry.empty())
129+
if (hasConfigEntry("NED"))
118130
{
119-
m_useNedFrame = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.NED", m_useNedFrame);
131+
m_useNedFrame = configBoolValue("NED", m_useNedFrame);
120132
m_frameAuto = false;
121133
}
122-
const std::string frameEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.Frame", "");
134+
const std::string frameEntry = configStringValue("Frame");
123135
if (!frameEntry.empty())
124136
applyFrameMode(frameEntry);
125-
m_rollSign = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RollSign", m_rollSign);
126-
m_pitchSign = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PitchSign", m_pitchSign);
127-
m_yawSign = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.YawSign", m_yawSign);
128-
m_rollOffsetDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RollOffset", m_rollOffsetDeg);
129-
m_pitchOffsetDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PitchOffset", m_pitchOffsetDeg);
130-
m_yawOffsetDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.YawOffset", m_yawOffsetDeg);
131-
m_rollScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RollScale", (float)m_rollScale);
132-
m_pitchScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PitchScale", (float)m_pitchScale);
133-
m_limitAttitude = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.LimitAttitude", m_limitAttitude);
134-
m_maxAbsRollDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.MaxAbsRollDeg", (float)m_maxAbsRollDeg);
135-
m_maxAbsPitchDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.MaxAbsPitchDeg", (float)m_maxAbsPitchDeg);
136-
m_smoothPose = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.SmoothPose", m_smoothPose);
137-
m_posSmoothAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PositionSmoothing", (float)m_posSmoothAlpha);
138-
m_rotSmoothAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RotationSmoothing", (float)m_rotSmoothAlpha);
139-
m_despikeOrientation = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.DespikeOrientation", m_despikeOrientation);
140-
m_despikeYawOnly = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.DespikeYawOnly", m_despikeYawOnly);
141-
m_despikeJumpDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.DespikeJumpDeg", (float)m_despikeJumpDeg);
142-
m_despikeSettleDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.DespikeSettleDeg", (float)m_despikeSettleDeg);
143-
m_knotFollowTether = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.KnotFollowTether", m_knotFollowTether);
137+
m_rollSign = configFloatValue("RollSign", m_rollSign);
138+
m_pitchSign = configFloatValue("PitchSign", m_pitchSign);
139+
m_yawSign = configFloatValue("YawSign", m_yawSign);
140+
m_rollOffsetDeg = configFloatValue("RollOffset", m_rollOffsetDeg);
141+
m_pitchOffsetDeg = configFloatValue("PitchOffset", m_pitchOffsetDeg);
142+
m_yawOffsetDeg = configFloatValue("YawOffset", m_yawOffsetDeg);
143+
m_rollScale = configFloatValue("RollScale", m_rollScale);
144+
m_pitchScale = configFloatValue("PitchScale", m_pitchScale);
145+
m_limitAttitude = configBoolValue("LimitAttitude", m_limitAttitude);
146+
m_maxAbsRollDeg = configFloatValue("MaxAbsRollDeg", m_maxAbsRollDeg);
147+
m_maxAbsPitchDeg = configFloatValue("MaxAbsPitchDeg", m_maxAbsPitchDeg);
148+
m_smoothPose = configBoolValue("SmoothPose", m_smoothPose);
149+
m_posSmoothAlpha = configFloatValue("PositionSmoothing", m_posSmoothAlpha);
150+
m_rotSmoothAlpha = configFloatValue("RotationSmoothing", m_rotSmoothAlpha);
151+
m_despikeOrientation = configBoolValue("DespikeOrientation", m_despikeOrientation);
152+
m_despikeYawOnly = configBoolValue("DespikeYawOnly", m_despikeYawOnly);
153+
m_despikeJumpDeg = configFloatValue("DespikeJumpDeg", m_despikeJumpDeg);
154+
m_despikeSettleDeg = configFloatValue("DespikeSettleDeg", m_despikeSettleDeg);
155+
m_knotFollowTether = configBoolValue("KnotFollowTether", m_knotFollowTether);
144156

145157
// Rope config (optional)
146-
m_ropeEnabled = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.RopeEnabled", m_ropeEnabled);
147-
// m_ropeRadius = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeRadius", m_ropeRadius);
148-
m_ropeRadius = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeRadius", m_ropeRadius);
158+
m_ropeEnabled = configBoolValue("RopeEnabled", m_ropeEnabled);
159+
m_ropeRadius = configFloatValue("RopeRadius", m_ropeRadius);
149160
if (m_ropeRadius <= 0.f)
150161
m_ropeRadius = 0.05f; // force visible default
151162

152-
m_ropeSagFactor = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSagFactor", m_ropeSagFactor);
153-
m_ropeSagMax = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSagMax", m_ropeSagMax);
154-
m_ropeSamplesMain = (int)coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSamplesMain", (float)m_ropeSamplesMain);
155-
m_ropeSamplesBridle = (int)coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSamplesBridle", (float)m_ropeSamplesBridle);
163+
m_ropeSagFactor = configFloatValue("RopeSagFactor", m_ropeSagFactor);
164+
m_ropeSagMax = configFloatValue("RopeSagMax", m_ropeSagMax);
165+
m_ropeSamplesMain = (int)configFloatValue("RopeSamplesMain", m_ropeSamplesMain);
166+
m_ropeSamplesBridle = (int)configFloatValue("RopeSamplesBridle", m_ropeSamplesBridle);
156167

157-
m_drawFullTether = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.DrawFullTether", m_drawFullTether);
158-
m_fullTetherAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.FullTetherAlpha", m_fullTetherAlpha);
159-
m_focusTetherAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.FocusTetherAlpha", m_focusTetherAlpha);
168+
m_drawFullTether = configBoolValue("DrawFullTether", m_drawFullTether);
169+
m_fullTetherAlpha = configFloatValue("FullTetherAlpha", m_fullTetherAlpha);
170+
m_focusTetherAlpha = configFloatValue("FocusTetherAlpha", m_focusTetherAlpha);
160171

161-
m_tetherFade = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.TetherFade", m_tetherFade);
162-
m_tetherNearLen_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherNearLen_m", m_tetherNearLen_m);
172+
m_tetherFade = configBoolValue("TetherFade", m_tetherFade);
173+
m_tetherNearLen_m = configFloatValue("TetherNearLen_m", m_tetherNearLen_m);
163174

164-
m_tetherSagBoost = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherSagBoost", m_tetherSagBoost);
165-
m_tetherSagMaxLong_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherSagMaxLong_m", m_tetherSagMaxLong_m);
175+
m_tetherSagBoost = configFloatValue("TetherSagBoost", m_tetherSagBoost);
176+
m_tetherSagMaxLong_m = configFloatValue("TetherSagMaxLong_m", m_tetherSagMaxLong_m);
166177

167-
m_tetherLineWidthNear = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherLineWidthNear", m_tetherLineWidthNear);
168-
m_tetherLineWidthFar = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherLineWidthFar", m_tetherLineWidthFar);
178+
m_tetherLineWidthNear = configFloatValue("TetherLineWidthNear", m_tetherLineWidthNear);
179+
m_tetherLineWidthFar = configFloatValue("TetherLineWidthFar", m_tetherLineWidthFar);
169180

170-
m_tetherAlphaNear = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherAlphaNear", m_tetherAlphaNear);
171-
m_tetherAlphaFar = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherAlphaFar", m_tetherAlphaFar);
181+
m_tetherAlphaNear = configFloatValue("TetherAlphaNear", m_tetherAlphaNear);
182+
m_tetherAlphaFar = configFloatValue("TetherAlphaFar", m_tetherAlphaFar);
172183

173-
m_snapAnchorsToSurface = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.SnapAnchorsToSurface", m_snapAnchorsToSurface);
174-
m_anchorLift_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.AnchorLift_m", m_anchorLift_m);
175-
m_snapRayUp_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.SnapRayUp_m", m_snapRayUp_m);
176-
m_snapRayDown_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.SnapRayDown_m", m_snapRayDown_m);
184+
m_snapAnchorsToSurface = configBoolValue("SnapAnchorsToSurface", m_snapAnchorsToSurface);
185+
m_anchorLift_m = configFloatValue("AnchorLift_m", m_anchorLift_m);
186+
m_snapRayUp_m = configFloatValue("SnapRayUp_m", m_snapRayUp_m);
187+
m_snapRayDown_m = configFloatValue("SnapRayDown_m", m_snapRayDown_m);
177188

178-
m_groundPos.x() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundPosX", m_groundPos.x());
179-
m_groundPos.y() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundPosY", m_groundPos.y());
180-
m_groundPos.z() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundPosZ", m_groundPos.z());
181-
m_showGround = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.ShowGround", m_showGround);
182-
m_worldScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.WorldScale", m_worldScale);
183-
m_targetTether_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TargetTether_m", m_targetTether_m);
184-
const std::string groundSizeEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.GroundSize_m", "");
185-
if (!groundSizeEntry.empty())
189+
m_groundPos.x() = configFloatValue("GroundPosX", m_groundPos.x());
190+
m_groundPos.y() = configFloatValue("GroundPosY", m_groundPos.y());
191+
m_groundPos.z() = configFloatValue("GroundPosZ", m_groundPos.z());
192+
m_showGround = configBoolValue("ShowGround", m_showGround);
193+
m_worldScale = configFloatValue("WorldScale", m_worldScale);
194+
m_targetTether_m = configFloatValue("TargetTether_m", m_targetTether_m);
195+
if (hasConfigEntry("GroundSize_m"))
186196
{
187-
m_groundSize_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundSize_m", m_groundSize_m);
197+
m_groundSize_m = configFloatValue("GroundSize_m", m_groundSize_m);
188198
m_groundSizeAuto = false;
189199
}
190-
m_focusMode = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.FocusMode", m_focusMode);
191-
m_focusTetherLen_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.FocusTetherLen_m", m_focusTetherLen_m);
192-
193-
m_geoModelPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.GeoModel", "");
194-
m_geoPos.x() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoPosX", m_geoPos.x());
195-
m_geoPos.y() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoPosY", m_geoPos.y());
196-
m_geoPos.z() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoPosZ", m_geoPos.z());
197-
m_geoScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoScale", m_geoScale);
198-
m_geoYawDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoYawDeg", m_geoYawDeg);
199-
m_geoAutoCenter = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.GeoAutoCenter", m_geoAutoCenter);
200-
m_geoAutoGround = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.GeoAutoGround", m_geoAutoGround);
201-
202-
m_junctionLocal.x() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.JunctionLocalX", m_junctionLocal.x());
203-
m_junctionLocal.y() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.JunctionLocalY", m_junctionLocal.y());
204-
m_junctionLocal.z() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.JunctionLocalZ", m_junctionLocal.z());
200+
m_focusMode = configBoolValue("FocusMode", m_focusMode);
201+
m_focusTetherLen_m = configFloatValue("FocusTetherLen_m", m_focusTetherLen_m);
202+
203+
m_geoModelPath = configStringValue("GeoModel");
204+
m_geoPos.x() = configFloatValue("GeoPosX", m_geoPos.x());
205+
m_geoPos.y() = configFloatValue("GeoPosY", m_geoPos.y());
206+
m_geoPos.z() = configFloatValue("GeoPosZ", m_geoPos.z());
207+
m_geoScale = configFloatValue("GeoScale", m_geoScale);
208+
m_geoYawDeg = configFloatValue("GeoYawDeg", m_geoYawDeg);
209+
m_geoAutoCenter = configBoolValue("GeoAutoCenter", m_geoAutoCenter);
210+
m_geoAutoGround = configBoolValue("GeoAutoGround", m_geoAutoGround);
211+
212+
m_junctionLocal.x() = configFloatValue("JunctionLocalX", m_junctionLocal.x());
213+
m_junctionLocal.y() = configFloatValue("JunctionLocalY", m_junctionLocal.y());
214+
m_junctionLocal.z() = configFloatValue("JunctionLocalZ", m_junctionLocal.z());
205215

206216
auto envToBool = [](const char *name, bool value) {
207217
if (const char *env = std::getenv(name))
@@ -237,19 +247,6 @@ bool KitePlugin::init()
237247
return value;
238248
};
239249

240-
if (modelEntry.empty())
241-
{
242-
modelEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.Model", "");
243-
}
244-
if (m_csvPath.empty())
245-
{
246-
m_csvPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.CSV", "");
247-
}
248-
if (m_geoModelPath.empty())
249-
{
250-
m_geoModelPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.GeoModel", "");
251-
}
252-
253250
if (std::getenv("KITE_NED"))
254251
{
255252
m_useNedFrame = envToBool("KITE_NED", m_useNedFrame);
@@ -309,9 +306,9 @@ bool KitePlugin::init()
309306
m_geoAutoCenter = envToBool("KITE_GEO_AUTO_CENTER", m_geoAutoCenter);
310307
m_geoAutoGround = envToBool("KITE_GEO_AUTO_GROUND", m_geoAutoGround);
311308

312-
double modelRollDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.ModelOffsetRoll", 0.0);
313-
double modelPitchDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.ModelOffsetPitch", 0.0);
314-
double modelYawDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.ModelOffsetYaw", 0.0);
309+
double modelRollDeg = configFloatValue("ModelOffsetRoll", 0.0);
310+
double modelPitchDeg = configFloatValue("ModelOffsetPitch", 0.0);
311+
double modelYawDeg = configFloatValue("ModelOffsetYaw", 0.0);
315312
modelRollDeg = envToDouble("KITE_MODEL_OFFSET_ROLL", modelRollDeg);
316313
modelPitchDeg = envToDouble("KITE_MODEL_OFFSET_PITCH", modelPitchDeg);
317314
modelYawDeg = envToDouble("KITE_MODEL_OFFSET_YAW", modelYawDeg);

0 commit comments

Comments
 (0)